freenode/#lisp - IRC Chatlog
Search
8:34:49
p_l
makomo: running a possibly complex lookup from instance reference to physical slot contents
8:35:53
p_l
beach: yes, but if the class redefinition happens *outside* of with-slots block, my idea doesn't even notice any problem
8:36:55
p_l
beach: essentially, when entering a with-slots form, it does the equivalent of (let ((slot-name (compute-effective-slot instance slot-name)) ...)
8:38:31
makomo
never heard of an implementation named PCL so i suppose you're referring to the book?
8:38:48
beach
I know how to do it with accessors, but I don't remember the details of how to make slot-value with a constant slot name fast. It is similar though.
8:39:05
p_l
makomo: no, "Portable Common Loops", which is where most implementations got their CLOS code from
8:42:26
makomo
does anyone know how the "visitor pattern" would scale when you want to do n-dispatch, where n >= 3?
8:42:39
beach
p_l: My guess would be that they turn (slot-value x 'bla) into a slot reader like (slot-value-bla x), and then it can be treated as a slot reader which I know how to optimize.
8:44:22
p_l
isn't visitor pattern just MAP over a collection of OBJECTS calling a LAMBDA that calls something in OBJECT ?
8:46:43
makomo
now let's say you have additional parameters whose types you want to switch on (i.e. n >= 3). i'm interested in how it would be done
8:47:08
makomo
oh, when i said "how many classes would you have to use", i meant "abstract classes" or "interfaces"
8:48:18
makomo
i'm not interested in doing it within CL, since CL has multimethods so we don't need the pattern anyway
8:48:22
p_l
makomo: I mean, I see the problem described, and I see myself do it by implementing "standard protocols" and passing possibly anonymous class instances that compose the specific environment I want
8:48:46
p_l
the CAD drawing example, I'd have standard drawing protocol, and "drivers" implementing different ways of drawing
8:50:09
p_l
then I could pass an object representing the object to draw an instance of already set-up driver (2nd dispatch as I understand you), which could be an anonymous class that delegates everything to a preconfigured specifically instance of another driver (for example it needs an instance of the drawing medium, like a file or GPU handle), which would be 3rd instance
8:50:26
makomo
p_l: hm, would that be almost like CPS? dispatch one, next class, dispatch two, next class, etc.?
8:51:34
makomo
i was only referring to this characteristic of "continuing", rather than the core of what CPS is supposed to be, but i guess it's not a good analogy anyway
8:55:51
makomo
i always have to "relearn" how exactly the visitor pattern does what it does, because it's a bit convoluted
8:59:07
akkad
something not right (map nil #'(lambda (x) (bt:make-thread #'(lambda (x) (format t "~a" x)))) '(1 2 3 4))
8:59:37
makomo
however, visit() has multiple overloads, one for every concrete class of the hierarchy that is being traversed
8:59:55
varjag
interesting.. i have two hosts set up to the same timezone, yet sbcl decode-universal-time gives different results
9:04:21
schweers
akkad: also you might want to either emit an extra newline, or call FINISH-OUTPUT from the threads.
9:06:41
schweers
I first encountered it while reading about what the haskell compiler does (in broad terms)
9:07:24
aeth
You probably want this: (map nil #'(lambda (x) (bt:make-thread #'(lambda () (format t "~a" x)) :initial-bindings `((*standard-output* . ,*standard-output*)))) '(1 2 3 4))
9:08:04
aeth
(The initial bindings part is one of several ways to use SLIME's stdout instead of the default, which isn't SLIME's, assuming you're in SLIME or something similar)
9:08:08
akkad
perfect. (map nil #'(lambda (x) (bt:make-thread #'(lambda () (ql:quickload (ql-dist:name x))))) (ql:system-list))
9:09:31
aeth
oh, (finish-output), too, but SLIME handles it (your inferior lisp might not, which is why it looks like it vanished instead of going there when you didn't bind the stdout)
9:09:36
aeth
(map nil #'(lambda (x) (bt:make-thread #'(lambda () (format t "~a" x) (finish-output)) :initial-bindings `((*standard-output* . ,*standard-output*)))) '(1 2 3 4))
9:10:14
aeth
Of course, to get the phantom numbers to show up there, just do this: (bt:make-thread #'(lambda () (finish-output)))
9:11:44
aeth
mfiano: I was just working with akkad's initial code. My normal style doesn't use #'(lambda
9:11:52
mfiano
The lambda macro expands to (function (lambda ...)) which is the same as #'lambda, just less code. More importantly though, if you're in code position the macro will do the correct thing, or you're in data position and using #'lambda will expand to (function (lambda ...)) which is not evaluated. lambda may not even be cl:lambda so the expansion of (cl:function (pkg:lambda ...)) won't even be valid. So best
9:17:52
aeth
Oh, and if you want 1324 to show up more frequently, perhaps try inserting a sleep. e.g. (map nil (lambda (x) (bt:make-thread #'(lambda () (sleep 1) (format t "~a" x) (finish-output)) :initial-bindings `((*standard-output* . ,*standard-output*)))) '(1 2 3 4))
9:18:41
aeth
Well, I'm working with the initial code snippit in one line, it's becoming difficult to notice style
9:19:53
aeth
Old style guides will say to put the #' there in #'(lambda so it will work on all of them.
9:22:10
aeth
If it was added after CLtL and before ANSI Common Lisp, then there are "Common Lisps" from 1984-1994 without it, as well as potentially unconforming CLs. I suppose that's increasingly irrelevant, though.
9:25:07
mfiano
By using the reader macro to refer to the second namespace, you are A) preventing shadowed lambda symbols from working, and B) sort of makes no sense because lambdas are anonymous, so no need for the second namespace
10:28:20
jmercouris
how could one transform a single dimensional array of 9 elements into a two dimensional array of 3x3?
10:28:44
jmercouris
or some clever way that doesn't involve traversing each element and populating the second array?
10:37:43
schweers
I tried array displacement in a project where performance is really important and it was really horrible. Obviously, YMMV.
10:48:15
ym
Do somebody has "error in process filter: Wrong number of arguments: (0 . 1), 2" messages in emacs 26.1 + slime?
10:54:15
_death
ym: yes, someone mentioned it lately.. the solution was to use slime bleeding edge (clone the repo)
10:56:02
_death
true.. but if you're using bleeding edge emacs, then it's likely that you're doing the same for slime and friends ;)
10:57:29
_death
well, I have patches for slime that fix such issues, and wonder how come no one else had them so they didn't get fixed
11:15:34
jmercouris
I prefer my editor not to crash randomly, I upgraded to 26, but I then upgraded again to 25 :D
11:20:57
schweers
jmercouris: why? did emacs 26.1 crash? I find it to be a tad slow, but seems stable so far.
11:24:05
jmercouris
to be fair, it wasn't a literal crash, but grinding to halt in which C-g repeatedly pressed until I could do something again
11:24:23
schweers
I had a few problems with elfeed, probably due to added records in emacs 26.1, but I could just remove the database. Not perfect, but was good enough for me.
11:39:31
jmercouris
I have an array like this 1,2,3, how might I make an array padded to 6 elements like this, 1,2,3,0,0,0
11:39:44
jmercouris
I tried make-array with initial-element and initial-contents, but you can't use both
11:57:34
shka
so i just ended up using it a lot for code that is supposed to work with both list and arrays
11:57:45
schweers
what I forgot to mention was that I was using simple arrays of a specific type, so a displaced array causes an indirection and possibly bounds-check (I’m speculating her). I expected a mild performance hit, but was quite surprised at how significant it was. I have no idea why it was that much, and sadly don’t have the numbers anymore.
11:59:07
makomo
hm weird. i would expect arrays to just have a dope/stride vector and a pointer to storage (and possibly a reference to the array that owns the underlying storage)
12:01:55
makomo
maybe because i'm just not used to seeing it in other languages (i don't know any language whose standard library comes with such features)
12:02:01
shka
i profiled code with statistical profiler and there was awfull lot of time in functions releated to garbage collection
12:03:13
shka
i suspect that sbcl just ensures that there will be no memory leak on specialized, displaced arrays
12:07:02
shka
well, each value in vector that someone displaces to is potentially about to disappear
12:07:32
shka
if life time of displaced vector is >> to life time of original vector problem may occur
12:16:50
pierpal
doesn't make much sense. a displaced arrays contains a reference to the base array and will prevent the entire array from being collected
12:38:46
pierpal
the content is held there by the fact of being contain e in the array. nothing umusual
13:15:22
xificurC
is using #1= reader macro considered bad taste? This seems to replicate anaphoric macro features in a funny way. (if #1=(+ 2 3) #1# 0)
13:17:13
beach
xificurC: Not very likely. The compiler typically does not take that sharing into account.
13:18:07
beach
But it is traversing it twice, and compiling similar but duplicate code for it each time.
13:19:38
beach
If you are lucky, it could use common sub-expression elimination, but it would do that even if you duplicate the expression.
13:20:05
beach
However, on today's architectures, it is not clear that common sub-expression elimination is worth the effort.
13:47:13
makomo
beach: "If you are lucky, it could use common sub-expression elimination, but it would do that even if you duplicate the expression." -- meaning that this elimination usually happens on some lower form, like IR?
13:50:44
Xof
I just spent 5 minutes trying to find a reference and failed, so my feeling might be wrong
13:52:00
Xof
I mean specifically list structure, but, again, I'm failing to find a reference so I might well be wrong
13:52:24
Xof
(and I use (do ((x #1=(complicated thing) #1#)) ...) all the time, so I'm a hypocrite as well)
13:54:19
schweers
I can’t help but think that its more readable to use a local binding (i.e. with a name) instead, at least in most cases
13:56:31
Bike
infinitely deep or long code is banned somewhere, i think, but i doubt structure sharing is banned in general
13:56:51
Bike
macroexpansion can get you that pretty easily, and e.g. the clhs page on load-time-value talks about the possibliity
14:25:22
beach
makomo: Yes, common sub-expression elimination is usually done on the level of a flow graph.
14:27:18
beach
ym: You can't legally transform proprietary code. It is called "derivative work" and it is subject to the restrictions of copyright law.
14:30:29
ym
What do you mean telling "transform"? I can use the proprietary code as a textbook and write my own free implementation of principals I learned.
14:31:40
Bike
it's "intellectual" property because it's tied to actual ideas, not some kind of physical labor
14:32:28
beach
ym: That's debatable. And that is also the reason why people who write free software avoid looking at proprietary code as much as possible.
14:33:44
flip214
clean-room implementations typically go the route of a description that's surely "different enough"
14:34:28
Bike
i don't think using the leaked code as a textbook would really be clean room reimplementation
14:36:01
flip214
Bike: no, surely not. you'd need a transcription step inbetween, eg. via an english text.
16:15:13
skidd0
I'm looking for a framework that's "lispy" to help me learn lisp, but hopefully without a lot of boilerplate
16:15:50
skidd0
for html/templating, I'd like to stay on the traditional HTML side, so something like Clip
16:16:37
skidd0
i've looked at hunchentoot but that seems to be best as a server, not an app framework
16:18:04
skidd0
from people with experience in them, not just my superficial overviews from project homepages
16:26:14
beach
skidd0: You can ask Shinmera about Radiance, since he wrote it. But he has his own channel I think. Can't remember the name.
16:42:48
on_ion
https://github.com/quakerquickoats/hoovy/blob/master/nova-js/parenscript-additions.lisp
16:52:32
on_ion
skidd0: i forget, that was a few years ago =) it felt like i had puppet strings on top of javascript though, which is my main aim with LISP, do more effect with less cause
16:52:46
on_ion
like setting up a bunch of gears to move the world but only having to turn a little wheel =P
16:53:24
skidd0
i am attracted to the bottom up, top down programming that Paul Graham's talked about in some of his essays
16:53:39
on_ion
human time and effort is precious , may as well get the machine working as we designed them (, prolog too)
16:54:15
on_ion
yes me too, and the idea of starting out prototype dynamically, then working toward (molding/guiding) a static implementation of whatever we are doing
16:56:24
skidd0
it's really nice to just "have an idea" > "make a basic prototype of idea" > "refine that" > "have another idea"
16:58:02
on_ion
yes =) when i pick up a guitar or piano, i just play, realtime improv, no premeditated design tech spec to implement, just let creation happen joyfully
17:13:19
on_ion
skidd0: certainly two sides of the same coin, as creation destroys and destruction creates, but in fun or not may decide which side we are looking at=)
18:09:35
ZigPaw
as I long time ViM user I found doom-emacs config for emacs and sly for common lisp interaction quite sleek and functional (and I can use org-mode as an added bonus).
18:30:08
sukaeto
(granted, there's no requirement to use Djula with caveman2, but it comes along for the ride when you ql:quickload caveman2)
18:32:35
sukaeto
also also: if you really want to get experience with Lisp. Eitaro Fukamachi's (the guy who wrote caveman) documentation tends to be pretty Spartan - usually a simple crash course on possible uses of the library. For the rest of it, you've got to look at his code.