libera/#commonlisp - IRC Chatlog
Search
14:26:21
random-nick
there's an emacs package for interaction with scheme called geiser which is in some ways similar to slime
14:30:26
lucerne
pjb: So to confirm my understanding; I'll create a clojure that sets the var in the parent scope, then I can pass this closure around, and anyone can set the aforementioned var?
14:33:19
beach
lucerne: yes, but then there is no violation of modularity. The creator of the closure grants permission to modify the variable.
14:52:28
beach
Right, it didn't occur to me that greyrat perhaps didn't know about special variables.
15:01:07
pjb
lucerne: it's not awsome: we implemented C-like operators, so we get the same problems than in C. eg. cf. example foo* bar* in https://termbin.com/o8at
15:02:04
pjb
beach: it's an old solution, implementation of locative (aka C-pointers) in CL: http://groups.google.com/group/comp.lang.lisp/msg/d141c5636559ba3b http://groups.google.com/group/comp.lang.java.programmer/msg/1c27cc14109db55f
15:03:04
lucerne
beach: I guess what I want is local dynamic vars (the macro pjb has supplied seems exactly this?). I don't like polluting the global env with special vars.
15:03:45
beach
You don't have to "pollute" the global environment. Just declare the variable SPECIAL.
15:03:46
pjb
lucerne: if you want local dynamic variables, then just declare the variable special locally!
15:06:06
pjb
lucerne: it only affects mentions of this variable in the lexical scope of the special declaration.
15:06:50
pjb
special variables name dynamic variables that live in time, while lexical variable live in space.
15:07:06
Nilby
I know beach won't approve of using the words "lexical special" because it's technically incorrect.
15:07:33
lisp123
pjb: special variables name dynamic variables that live in time, while lexical variable live in space. >>> best explanation I have heard yet
15:11:30
Nilby
So what's the proper term? How does differentiate between a defvar and a (let (x) (declare (special x)) ...)
15:11:56
pjb
greyrat: anyways, beach's comment means: Why do you want do that? It's a bad idea, don't do that!
15:13:59
pjb
Nilby: define-symbol-macro is all-encompassing, while (let (x) ...) is a lexical scope.
15:14:16
beach
The difference is whether the variable is special in the global environment or not. Hence my suggested "local".
15:15:40
Nilby
I understand how it works, I just want to use words that won't bother or confuse people.
15:16:23
pjb
Also, lexical scopes are not always contiguous, hence the notion of locality can be topologically strange. Similarly, temporary scopes (dynamic bindings) can be shadowed, and also, when threads are involved, can have strange topologies, since threads represent parallel times.
15:17:07
lisp123
Nilby: Have a think about what lexical means, hopefully that will help explain why that wording doesn't work
15:17:50
pjb
See for example, the lexical scope where functions defined with labels are visible (on the right): http://informatimago.com/~pjb/files/lisp/common-lisp/flet-or-labels.png
15:18:46
Nilby
I do have a fondness for utilizing the thread topologies of "local" or "non-global" specials.
15:22:22
Nilby
lisp123: I don't like thinking. But, these variables are in fact introduced in a lexical scope, and then set somewhat but not totally free, by the declaration, so perhaps one should call them "free-lexicals".
15:23:51
lisp123
I wouldn't do that since the meaning of lexical is most closely associated with the textual region - e.g. definition of lexical scope " Here references to the established entity can occur only within certain program portions that are lexically (that is, textually) contained within the establishing construct. "
15:23:51
Nilby
Of course one doesn't want to imply that they're free in time or space cost, which is the nearly the opposite.
15:24:19
beach
Why would you not use the word "special" to describe a restricted kind of special variable.
15:24:59
beach
An adjective can be used to indicate such a restriction. But to use a completely different noun for it seems just so wrong.
15:29:10
pjb
lisp123: true, but there's an operator that maps between time and space: it's eval (execution in general). The "text" in a lexical scope is evaluated "during" a time period. This is how dynamic environments come alive.
15:30:11
Nilby
I'll just say "local special" from now on. If beach approves, that's good enough for me.
15:31:05
pjb
But granted a symbol that is locally declared special, let you name a dynamic variable temporarily.
15:31:40
pjb
Note that the dynamic variable that is temporarily named depends on the dynamic scope: it can be an outer temporary dynamic variable, or the global dynamic variable.
15:36:10
lisp123
Adding (declare (special g)) gives an error here: (defun compose (f g) #'(lambda (x) (declare (special g)) (funcall f (funcall g x))))
15:40:33
lisp123
Is it because g now has dynamic extent - is it disestablished after the function is defined?
15:43:02
lucerne
lisp123: I don't understand your function at all. Can you explain what it is supposed to do in plain English?
15:45:01
lucerne
pjb: I looked at your examples of failure modes. Indeed, the solution really only works if the names of the original functions are also supplied as strings. And these special vars seem to be just a better fit. I had misremembered `declare special` as global like `defvar`.
15:46:12
lucerne
BTW, can one inspect the "stack" of a special variable? To see what value it has at the grandparent scope, for example.
15:47:04
lisp123
lucerne: I'm not sure if I can explain it that well, https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node43.html goes through it a bit more
15:54:01
beach
lisp123: Yours is a "free declaration" because it is not attached to the lambda-list variable G.
15:54:36
lisp123
beach: Its a bit confusing for me because there are references to both f & g within the funcalls
15:58:39
lisp123
Out of curiosity to see what would happen. From what I understand, f & g have indefinite extent (" The parameter bindings for f and g do not disappear because the returned function, when called, could still refer to those bindings."), so wanted to see what would happen if one adds in a special declaration which gives g dynamic extent? However, both you and Nilby say its a different G, but I can't seem to get my head around that
15:59:43
pjb
lisp123: your lambda is calling now a function that should be bound to a dynamic variable named g. The parameter of compose named g is a lexical variable!
16:00:39
beach
lisp123: Your SPECIAL declaration is not "attached to" the lambda-list variable G, because for that to be the case, it has to be first in the DEFUN body.
16:00:44
pjb
lisp123: if you declare it special: (defun compose (f g) (declare (special g)) #'(lambda (x) (declare (special g)) (funcall f (funcall g x)))) then the lambda will perhaps refer to the same dynamic variable that is now the parameter of compose, but since it's not called WHEN compose is evaluated, it won't be!
16:01:30
beach
lisp123: So it is a "free declaration", and it affects only references, as the Common Lisp HyperSpec page says. Not any binding like the lambda-list variable is.
16:01:35
pjb
lisp123: on the other hand, if you call the anonymous function returned by compose WHEN there is a dynamic variable named g defined that moment (= temporal scope), then then it will be able to call it.
16:01:52
pjb
lisp123: but since in general, random dynamic variables are unbound, you get this error.
16:05:15
pjb
lisp123: you should read more Asimov! eg. "Gimmick Three" https://en.wikipedia.org/wiki/Gimmicks_Three
16:05:54
pjb
lisp123: you cannot emprison the devil in a thick eternal bronze cube. Because he can travel back in time, before the cube existed, and escape!
16:06:14
lisp123
beach & pjb: thanks, it doesn't make too much sense, but if I read it enough times hopefully it will
16:07:01
pjb
lisp123: in the case of this compose function, if you want g to be special, then you don't need it as a parameter to compose.
16:07:52
lisp123
pjb: I was trying to break this "closures can only exist over lexical variables." by making it special
16:12:20
pjb
If you call h in a loop, you can even change the *trace-composed-functions* binding in another thread (or in the body of the loop) >:-}~
16:20:48
Nilby
lisp123: I was first exposed to lisp around the age of 10, and I am very old. I only stopped using other languages about 16 years ago.
16:23:07
Nilby
lisp123: My dad thought it would stop me from getting in trouble to put me in front of a teletype at MIT. He was very wrong.
16:33:31
Nilby
lisp123: In my case it didn't matter since I was born with a severe allergy to academia. It mearly gave me a warped and mostly incorrect ideas about robots, programming languauges, and the future.
16:40:23
etimmons
borodust: I noticed that in CLAW repos you like to include the foreign lib's repo as a submodule. Have you messed around at all with having ASDF build the foreign lib for you?
16:42:25
borodust
etimmons: i do link foreign lib repos in wrapper projects and primary reason is to have specific version of headers
16:43:44
borodust
etimmons: it's hard to get things goind in native way across different platorms (different knobs needed to be triggered to build properly), implementing that in asdf feels like being a total nightmare
16:46:22
etimmons
borodust: That's fair! Kind of just wondering how you ensure the header version matches the lib version if you use the system's lib
16:47:34
borodust
etimmons: btw, also when putting bindings into a quicklisp dist i strip everything foreign - no headers, no c/c++ code, no foreign project as a whole
16:48:18
borodust
meaning user won't be able to build foreign library at all by using system from a dist at all