libera/commonlisp - IRC Chatlog

Search
10:10:06 TMA I cannot find whether it is specified for &rest etc. to be present or accessible in the COMMON-LISP package.
10:11:55 hayley clhs 1.9
10:11:55 specbot Symbols in the COMMON-LISP Package: http://www.lispworks.com/reference/HyperSpec/Body/01_i.htm
10:12:12 hayley clhs 11.1.2.1
10:15:31 TMA ah, I was a bit baffled by the glossary entry "lambda list keyword n. a symbol whose name begins with ampersand and that is specially recognized in a lambda list."
10:17:31 TMA that has two readings, namely that (a) the &-beginning-symbol is specially recognized in a lambda list and (b) that the &-beginning-symbol's name is specially recognized in a lambda list.
10:19:22 TMA the (b) reading would allow (lambda (&rest x) x) and (lambda (#:&rest x) x) be equivalent (in the same spirit as the loop keywords are specified by name only)
10:19:46 _death it's a conjunction.. it has to (i) begin with an ampersand (ii) be specially recognized in the lambda list
10:21:01 _death well, (i) have a name that begins with an ampersand
10:22:30 TMA _death: it is a conjunction. but there is the ambiguity as to the antecedent of "that"
10:23:23 _death where do you find the ambiguity?
10:25:12 TMA lambda-list-keyword(x) === (let ((that ...)) (and (eql (elt (symbol-name x) 0) #\&) (specially-recognized-in-a-lambda-list-p that)))
10:26:02 TMA the ambiguity is whether the ... shall be just x or (symbol-name x)
10:26:16 _death I can see how you could read it as "a symbol whose name (begins ... and that is specially recognized ...)" but only if you remove the context of lambda list parsing as described in the clhs
10:27:44 X-Scale` ** NICK X-Scale
10:28:53 nij- phoe I bought a phys copy of your book on condition system. It's great so far :D Thanks!
10:31:33 TMA _death: well, I can argue against myself that the wording in 6.1.1.2 Loop Keywords is explicit enough that the intended meaning is not the .../(symbol-name x) substitution, because there is not enough of similarly explicit wording for lambda list keywords
10:32:44 nij- I have some naive questions though, if you don't mind, phoe.
10:32:50 nij- 1. I wonder why can't we use if/case forms to handle different conditions. Isn't that simpler?
10:32:54 nij- 2. I've heard many times that Lisp's condition system is better than other langs'. However, Python for example has a debugger too. In what way is the Lisp condition system better than Python's (or any other lang's)?
10:33:02 nij- 3. You mentioned that *-bind are macros but not functions (chapter 4) and therefore cannot be operated functionally. While macros are great for extending Lisp syntax, does this show that macros have their (serious?) limits too?
10:33:20 TMA but the specification lawyer in me cringes, I have been trained to spot those minor ambiguities in standards; it turns out those are lagely intentional loopholes
10:33:40 TMA at least in other standards
10:33:49 _death lambda-list-keywords is a constant variable that contains a list of all the lambda list keywords.. if the definition had been about names, it'd be hard to cons :)
10:36:41 TMA "A list of all the lambda list keywords used in the implementation, including the additional ones used only by macro definition forms."
10:37:43 TMA it still keeps a bit of wiggle room for symbols that are recognized by the implementation but not used in it
10:38:09 TMA those merely recognized need not be on the list
10:43:51 _death what would be the use of such a list then
10:44:15 pjb TMA: note: (defun specially-recognized-in-a-lambda-list-p (x) (member x lambda-list-keywords))
10:44:55 pjb TMA: so really the &-beginning-symbol-p in the definition is only a constraint on what is in lambda-list-keywords.
10:45:32 pjb TMA: so you're right that a #:&REST or a SI:&REST symbol could be in lambda-list-keywords, but we've never seen them. (implementation dependent).
10:45:56 pjb Alsok it would be hard to use #:&REST since you'd have to find it in lambda-list-keywords for reference.
10:46:06 hayley Not phoe but: #1 Conditions are "non-local" in that they interact with code that isn't nested in the forms, like IF and CASE do. 2. The debugger isn't that important in itself, but not unwinding and losing information is important. And (from memory) pdb and similar for Java unwind too much, before entering the debugger. 3. handler-bind and such cannot be functions (while otherwise retaining the same interface), because those forms affect the
10:46:06 hayley evaluation of their arguments.
10:47:03 _death I think TMA is imagining an implementation that has a lambda-list-keyword-p function that checks a symbol's name.. then why provide a lambda-list-keywords list and not such a function to the user?
10:48:00 nij- hayley - thanks: 1. In general we should prevent writing nonlocal codes. It makes me more curious why in some case we choose to use conditions/handlers instead of if/case.
10:48:36 lisp123 nij-: this isn't a question restricted to common lisp
10:48:44 pjb _death: lambda-list-keywords list is more informative than just a predicate.
10:48:46 nij- hayley 2. What does "unwind" mean? What makes those languages unwind and lose too much info?
10:48:47 lisp123 In general you want ordinary control flow through if/case
10:49:07 lisp123 and control flow for say _exceptional_ circumstances to flow through the condition system
10:49:23 hayley Should we? Dynamic variables are the same sort of thing, that passing information through e.g. function arguments is cumbersome. Similarly handling situations "locally" can get cumbersome.
10:49:37 pjb _death: the difference in information is: (let (lambda-list-keywords) (do-symbols (s) (if (lambda-list-keyword-p s) (push s lambda-list-keywords))) lambda-list-keywords)
10:49:38 nij- hayley 3. Yeah, in general many things cannot be functions. So while macros are great, that's one of their limit, isn't it?
10:50:13 lisp123 hayley: I use macros a lot for that use case
10:50:28 hayley Unwinding means to abandon evaluation of some evaluation. What RETURN-FROM, THROW, etc do.
10:51:15 hayley nij-: It's more a limit of functions at face value, that for a function application, all arguments are evaluated before the function is called, so a function has no control of how arguments are evaluated.
10:51:21 _death pjb: the point is that you may want to write a program (say, a code walker) that has to deal with certain lambda list keywords.. if you then find a symbol that's a lambda list keyword that you don't handle, you can signal an error.. so if lambda-list-keywords is not exhaustive, it's not very useful
10:52:35 nij- lisp123 why do we want the exceptional circ. to flow through the cond. system not if/case?
10:53:30 nij- hayley: But macros, on the other hand, are not first class citizens. We can not apply things on them..
10:53:46 lisp123 nij-: because for errors or other exceptional situations, by cleanly segregating the code that handles the normal "business" case and the error case, it is easier to flow through a program and understand what it does
10:54:21 lisp123 you very much want to consider errors on their own and then the main program on its own and then at a combined level how the error protection helps make your program more robust (although jury is out on that one)
10:54:27 nij- lisp123 ! I think that makes sense. Yeah, if I use if/case ordinarily, the main body will be crowded with exception handlings.
10:54:34 lisp123 exactly
10:54:56 lisp123 but its good you are thinking about these things, because now you will be better at making that judgement on when to use what
10:54:56 hayley Sure, they are not first class, but what you are asking for isn't well formed. FUNCALL and APPLY will be called with values that were produced by evaluating other forms. Macros process unevaluated forms.
10:55:10 nij- So yeah phoe 1 is resolved :)
10:56:15 nij- What can we apply on macros then? .. While functions are objects, macros are ..?
10:57:10 Th30n Shinmera: gratz on getting the 2nd stretch goal! :D
10:57:19 lisp123 you can wrap a macro in a lambda and apply on it
10:57:35 hayley Macro functions are functions, and thus in turn objects. But macros are used before evaluation (though the macro function is called, causing more evaluation), whereas functions are used in evaluation.
10:57:52 Shinmera Th30n: thanks!
10:58:04 jackdaniel my head is spinning from all that evaluation
10:58:08 lisp123 its hard to understand macros vs functions as a beginner and then one day it clicks
10:58:18 nij- jackdaniel keep it spinnin'!
10:58:41 lisp123 if you remember that macros are used to create new syntax, thats a good heuristic to guide you
10:59:01 nij- I know that macros do not eval their args.. just curious what we can apply on macros meaningfully.
10:59:04 lisp123 i.e. if you have lots of code repeat or annoying function calls, a macro may be the answer
10:59:20 jackdaniel it's simple, macros are expanded by the preprocessor, that's how we can define operators that accept any kind of arguments!
10:59:30 jackdaniel #define add(a, b) a+b
11:00:54 nij- Are there some examples where things are applied on macros, and make things easier?
11:01:12 Shinmera what does that even mean
11:01:24 nij- In C we cannot apply on functions.. and that's not too convenient. I'm trying to ask if such case is for macros too.
11:02:05 jackdaniel nij-: you can't apply "on" a macro, because that would require evaluating the argument
11:02:15 jackdaniel (namely, the list in question)
11:02:57 nij- Hmm.. maybe I use the wrong terms. I will think more about it and ask again.
11:02:58 jackdaniel if that weren't the case, we could just (defmacro shmapply (the-macro list-to-be-shmapplied) `(the-macro ,@list-to-be-shmapplied))
11:03:29 jackdaniel s/(the-macro/(,the-macro/
11:04:06 _death as an aside, cl-su-ai discussion threads http://cl-su-ai.lisp.se/msg02882.html and http://cl-su-ai.lisp.se/msg02879.html are quite interesting
11:05:49 lisp123 cant believe similar discussions were had in 19886
11:06:37 jackdaniel we are repeating the history with the speed of light; each cycle is slightly worse though ;)
11:06:49 lisp123 yeah
11:12:30 Josh_2 Welcome to the Kali-yuga
11:16:28 Josh_2 "frustrate would-be implementors of portable code walkers." beach :joy:
11:16:38 Josh_2 Only known 40 years ago
11:25:12 beach nij-: If you still have questions, maybe I can provide some perspective. Or did you have all your questions answered?
11:26:31 beach nij-: What hayley said is right, but I am not sure you were satisfied with some of the answers.
11:32:18 pjb _death: but lambda-list-keywords IS exhaustive!
11:33:45 pjb nij-: you can apply macros! Instead of using apply you use macroexpand-1.
11:34:26 pjb nij-: or if you insist on apply/funcall, you can write: (funcall (macro-function 'cond) '(cond ((= x 1) 'hi) (t 'bye)) nil) #| --> (if (= x 1) (progn 'hi) (cond (t 'bye))) |#
11:34:57 pjb nij-: macros are first-class objects in lisp.
11:36:00 beach nij-: I guess maybe some other time. The discussion seems to have moved on.
11:36:09 _death pjb: the discussion started with an ambiguity in the glossary definition of "lambda list keyword".. there were two competing interpretations and one of them implied that lambda-list-keywords could not be exhaustive
11:36:27 pjb There are a few things that are not first class objects in CL: types, multiple-values, and I can think of nothing else right now.
11:36:39 jackdaniel tagbody labels ,)
11:37:13 beach pjb: Comments, places.
11:37:18 pjb _death: I see a single definition: lambda list keyword n. a symbol whose name begins with ampersand and that is specially recognized in a lambda list. Note that no standardized lambda list keyword is in the KEYWORD package.
11:37:34 pjb _death: and there's a single interpretation.
11:37:40 _death pjb: I suggest checking the channel log
11:37:54 pjb I've followed it!
11:39:35 pjb _death: Mmm. you mean the "used only by macro definition forms." part. I see now.
11:42:29 pjb _death: the only form that is not a macro definition that uses &-symbols is destructuring-bind!
11:43:11 pjb _death: so if an implementation has additionnal special &-symbols specific to destructuring-bind lambda-lists, then indeed they won't be listed anywhere.
11:44:20 pjb _death: but destructuring-bind lambda-list are defined with respect to macro lambda-lists: A destructuring lambda list can contain all of the lambda list keywords listed for macro lambda lists except for &environment, …
11:45:09 pjb _death: so we can argue that any non-standard &-symbol used in destructuring-bind should be non-standard &-symbol used macro lambda-lists, and therefore should be in lambda-list-keywords.
11:45:31 _death no, that's not what I meant
11:45:38 _death also, DEFUN, for example, is not a macro definition form...
11:45:47 pjb _death: To have the lambda-lists keywords of destructuring-bind not be a subset of the lambda-lists keywords of macro, you'd have to have a language extension.
11:46:26 pjb Right, DEFUN is a definition macro forms; I mixed it with macro definition forms.
11:46:54 pjb _death: IMO, this is all some mixup in the standard, they didn't meant that IMO.
11:47:09 pjb I see no point in restricting lambda-list-keywords to only defmacro.
11:49:02 _death pjb: you should pay attention to TMA's arguments.. I argued against that interpretation by a very mild form of reductio ad absurdum
11:49:52 pjb _death: so I'd say that there's a problem with the standard, but happily implementations provide an exhaustive list in lambda-list-keywords.
11:50:17 _death pjb: description of lambda-list-keywords doesn't restrict to defmacro.. it says the list should _also_ include those symbols
11:53:32 pjb then lambda-list-keywords = A list of all the lambda list keywords used in the implementation. ; we can ignore the "including clause" since it's included!
11:53:47 pjb Therefore lambda-list-keywords is exhaustive and all is good.
11:54:45 pjb Now since it's exhaustive, the glossary definition can be reduced to lambda list keyword = member of lambda-list-keywords.
11:55:15 pjb Just adding somewhere the specification that (every (lambda (s) (aref (symbol-name s) 0) = #\&) lambda-list-keyword).
11:55:35 pjb and there is no ambiguity.
11:55:36 _death [13:37] <TMA> it still keeps a bit of wiggle room for symbols that are recognized by the implementation but not used in it
11:55:37 _death
11:56:10 pjb Nope. I argue against that. Starting from the precise definition of lambda-list-keywords that you helped me understand.
11:56:12 pjb Normalcy restaured.
11:56:17 pjb s/au/o/
12:05:43 nij- beach Thanks, I was away. I need to think of a better question.
12:05:44 _death imagine if implementation used (defun rest-lambda-list-keyword-p (symbol) (string= symbol "&REST")) to recognize &rest, but only used cl:&rest itself.. then one interpretation is the glossary definition is satisfied, and a lambda-list-keywords list (that is not exhasutive, but contains cl:&rest) is still possible
12:06:04 nij- pjb I didn't mean "apply macros", but "apply on macros". Something like (higher-order-op #'a-macro)
12:07:23 beach nij-: Sure. I found your questions pertinent, but perhaps could use a more precise phrasing.
12:08:14 _death pjb: my argument is that it would be strange to supply a CL user with lambda-list-keywords that's not exhaustive, and in that case a lambda-list-keyword-p function (that is exhaustive) would make more sense.. therefore the interpretation that has such undesirable consequences is unlikely to be the intended one
12:09:19 beach nij-: That would be using a macro as a first-class object. You can use the "macro function" as a first-class object.
12:10:12 nij- I think I'm looking for interesting cases where macros are applied on.
12:10:19 beach nij-: So there is nothing special about using an object to "apply on" as you put it, compared to any other usages of an object.
12:10:26 nij- For functions, we have higher operations like #'compose.
12:11:04 nij- (apply #'and t t)
12:11:08 nij- Sorry, wrong place..
12:12:21 beach nij-: The thing about forms such as HANDLER-BIND is that they can not be functions because the forms in its scope must be evaluated in an environment that is not the same as the one that the form itself is evaluated in.
12:12:44 nij- I understand that part.
12:12:51 beach Ah, OK. Good.
12:12:51 nij- I'm just worried about the limit of macros in general.
12:13:03 nij- We know that higher order operations are useful.
12:13:17 nij- I wonder if higher order operations can't be meaningfully operated on macros.
12:13:32 beach nij-: I think your comparison between functions and macros in that respect is not justified.
12:14:15 beach nij-: Maybe because you sometimes see names of macros as the first element of a compound form, you think they are like functions, so you want them to have the same possibilities.
12:15:02 nij- Hmm.. I'd rather say I think both of them are objects, so should be transformable in meaningful or interesting ways.
12:15:25 nij- It makes the whole language more modular.
12:15:39 beach nij-: What higher-order operations do you know for (say) numbers?
12:15:44 nij- s/makes/could make/
12:16:25 nij- By a higher order operation I mean a function that acts on functions.
12:17:00 nij- So are there meaningful cases where a function acts on macros?
12:17:08 beach ?
12:17:18 beach Sure.
12:17:26 beach Not macros, but macro functions.
12:17:42 beach Macros themselves are not first-class objects, but macro functions are.
12:18:31 nij- (I'm quickly looking up what their difference is.)
12:19:05 beach nij-: Again, I think you want macros to behave like functions because you see them used in similar-looking forms. But they are very different animals, just as numbers are different from functions, which is why I brought up numbers.
12:19:48 nij- I'd say that's not what I think..
12:19:52 beach nij-: When you define a macro, what really happens is (setf (macro-function <name>) (lambda (form environment) <the-body-of-the-macro>))
12:20:04 nij- To start with, what's the diff between a macro and macro function?
12:20:11 beach nij-: You can get this function back by calling (macro-function <name>).
12:20:19 nij- Oh ok! I see.
12:20:41 nij- Rephrased: Are there meaningful cases where a function acts on macro functions?
12:20:48 beach You can then do (funcall (macro-function 'when) '(when x y z) nil).
12:20:51 nij- meaningful/interesting/cool.. etc
12:21:05 beach Not really.
12:21:40 nij- hmm :(
12:22:02 beach nij-: I think you should stop wanting macros or macro functions to be like functions. Just like you don't seem to have any desire to have numbers behave like functions.
12:22:19 beach nij-: They are different animals. Functions work at run time. Macros work at compile time.
12:23:23 nij- I brought up this question because of one of phoe's writing, in 4.5.9 of his book "lack of functional interface for handler and restart"
12:23:56 nij- It suggests that such lack is a drawback, making wonder if they were functions (ofc they cant be).. what would be different?
12:24:29 beach nij-: I don't have in memory what he meant, but I am guessing that he meant something like how (SETF MACRO-FUNCTION) and MACRO-FUNCTION are the functional interface for macros.
12:25:01 beach nij-: I do not think he meant replacing binding forms by functions.
12:25:27 hayley I think phoe mentioned a lack of "introspection" functions for handlers in his OLM presentation.
12:25:38 beach Ah, that's possible.
12:25:52 nij- That's another subsection.
12:26:38 nij- 4. (phoe) Are there any ready-to-use portable condition system that's based on CLOS ;) ?
12:26:55 beach nij-: Sometimes, the standard specifies an underlying function interface to macros, like DEFUN is defined in terms of FDEFINITION and (SETF FDEFINITION). Sometimes it doesn't, like DEFTYPE does not have an underlying interface using functions.
12:27:49 beach nij-: You mean one that is different from the standard one?
12:28:31 nij- Yeah I think what phoe meant in his book is that the standard one is not based on CLOS. And unfortunately in at least one popular implementation it's really not based on CLOS.
12:28:54 hayley Bindings for restarts and handlers have dynamic extent still. Would one have, say, a CALL-WITH-RESTARTS function as a functional analog to RESTART-CASE?
12:30:22 beach nij-: So you mean as an implementation strategy?
12:30:45 beach nij-: That might be for historical reasons and because of the way bootstrapping is done in must existing Common Lisp implementations.
12:31:17 nij- beach I mean has someone written a portable condition system for Lisp that's based on CLOS
12:31:38 nij- The book shows part of how it can be implemented in chapter 3.
12:31:43 hayley I think phoe wrote one?
12:31:50 beach nij-: I just don't know what "based on" means. Whether it somehow exposes CLOS to the user of it, or whether it is just implemented using it.
12:32:07 hayley More precisely, phoe updated Kent Pitman's CLtL1 implementation.
12:32:36 beach nij-: In most Common Lisp implementations, CLOS is "bolted on" at the end. So if they want the condition system to work before that, they can't use CLOS to implement it.
12:33:57 hayley (I remember I made a lazy attempt at updating Pitman's code before, but got bored of it quickly.)
12:34:17 nij- :) oh this is ready to use :O ?! hayley
12:34:25 nij- I thought it's just for educational purpose.
12:34:56 jackdaniel I don't know how about other implementations, but in ecl define-condition is defclass under the hood
12:35:29 jackdaniel and make-condition is make-instance (after processing arguments to have the proper shape)
12:35:35 nij- jackdaniel yeah I think he mentioned that most impls uses CLOS, but at least one popular impl doesnt
12:35:47 jackdaniel sbcl doesn't do that, and it is the only one I think
12:35:53 nij- :OOOOOOOOO
12:35:55 beach nij-: The system written by phoe is basically what SICL uses natively. I made a few changes.
12:36:07 nij- Awesome
12:36:48 beach nij-: What phoe wrote was not meant to be used natively, so I had to adapt it in a few ways.
12:37:27 nij- ACTION wonders if SICL will replace all implementations one day, soon ;)
12:38:21 beach nij-: The point here is that the Common Lisp condition system is very simple. Once you have non-local control transfer in the form of CATCH/THROW, TAGBODY/GO, and BLOCK/RETURN-FROM, and macros, then you can write a complete condition system.
12:39:15 beach nij-: This is why phoe has been arguing in favor of non-local control transfer in WASM. As opposed to including a complicated exception system in the language itself.
12:39:33 beach But I take it that his advice was not followed.
12:39:40 nij- And is it correct to say that if one implements handler-bind, then all other relevant operators in C-S can be impl easily?
12:40:34 beach nij-: I don't see why HANDLER-BIND is the basis of the others.
12:40:49 nij- What's the basis (I'm very new to C-S..)?
12:41:10 beach nij-: I just told you. Non-local control-transfer primitives and macros.
12:41:16 hayley Note that due to https://www.plover.com/~mjd/misc/hbaker-archive/MetaCircular.html only one sort of non-local control transfer is necessary to produce the other two.
12:42:03 beach nij-: Oh, and special variables.
12:42:50 nij- what are special variables?
12:43:04 beach nij-: What you get when you say DEFVAR.
12:44:25 jackdaniel re wasm, some changes are not introduced to it because of the current "stake holders" say that this would require too much work on their end;
12:45:11 jackdaniel that said there is hope if microwasm is adopted (some runtimes already implement it), because it provides better primitives i.e to implement non-local control transfer
12:45:38 jackdaniel (here is some information for interested: http://troubles.md/posts/microwasm/)
12:45:55 nij- beach I always though defvar is how you initialize a variable in top forms.
12:46:14 nij- But this page gets me lost.. http://clhs.lisp.se/Body/d_specia.htm#special I'm no longer sure if that's merely the case.
12:46:46 beach nij-: Special variables behave very differently from lexical variables.
12:46:53 dim hi there! is Xach still around sometimes? The certificate for www.xach.com expired on 6/15/2022
12:47:20 nij- I will move to clschool..
12:53:36 pjb _death: I explained that a predicate makes less sense than a list, because to collect the list, you need to do more work, and the predicate already knows the list! It's not like it was a property of the symbol, it's just an arbitrary set.
12:54:55 pjb nij-: the point is that macro functions are functions like any other, there's no predicate to distinguish them. This is due to the fact, that there's no operator to get a function signature. Any function that takes a form (a proper list), and an environment can be used as a macro-function!
12:55:27 bike ** NICK Bike
12:56:19 _death pjb: construct a list that corresponds to rest-lambda-list-keyword-p
12:56:20 pjb nij-: (apply (macro-function 'and) (list '(and t t) nil)) #| --> (if t (and t)) |#
12:56:41 pjb _death: this is something entirely different.
12:57:13 pjb _death: we mentionned the need of a grammar for the additionnal keywords. sicl uses a parser that allows adding custom grammar rules for lambda-lists.
12:58:21 pjb nij-: (mapcar (macro-function 'and) '((and t t) (and nil t) (and t nil) (and nil nil)) '(nil nil nil nil)) #| --> ((if t (and t)) (if nil (and t)) (if t (and nil)) (if nil (and nil))) |#
12:59:17 pjb nij-: (mapcar (alexandria:compose #'eval (macro-function 'and)) '((and t t) (and nil t) (and t nil) (and nil nil)) '(nil nil nil nil)) #| --> (t nil nil nil) |# DUH!
12:59:49 pjb EVERYBODY: MACROS ARE JUST FUNCTIONS LIKE ANY OTHER LISP FUNCTION !!!!!!!
13:00:51 pjb macroexpand-1 and macroexpand are already two interesting functions acting on macros…
13:00:59 hayley Inside voices please!
14:27:53 X-Scale` ** NICK X-Scale
15:24:27 jackdaniel I'm playing with serializing and expanding protocols to code, here's McCLIM geometry substrate with extensions (the svg document is generated with McCLIM): http://turtleware.eu/static/paste/c5c3e822-proto.svg
15:56:25 fitzsim jackdaniel: is that supposed to be an SVG file?
15:57:07 fitzsim I get Lisp code when I load it in a browser
16:06:10 White_Flame fitzsim: pretty sure it's an svg rendering of lisp code
16:06:31 White_Flame view page source ;)
16:07:48 jackdaniel fitzsim: yes, it is svg generated from mcclim-svg backend
16:08:14 jackdaniel (and the code is generated from the protocol definition)
16:09:32 jackdaniel I'm working on separating a low-level hardware access abstractions (similar to Silica from Genera) as a separate system "silex", so it will be reusable as a portable lisp base for any kind of toolkits
16:10:15 jackdaniel (from the mcclim perspective nothing will change, but loading this system alone won't pull numerous clim abstractions)
17:59:40 contrapunctus ACTION discovers `alexandria:make-keyword`
18:00:22 contrapunctus Good, so I don't have to copy-paste my NIH version of that in all my projects ^^'
18:16:26 White_Flame contrapunctus: yeah, I still have so much pre-alexandria code to update
18:18:14 contrapunctus White_Flame: heh. When I was about to copy-paste it into a third project, I realized that there _had_ to be something for this in some util library somewhere.
19:38:20 dlowe fourier: checking for it in initialize-instance seems to be a reasonable choice, though you might want to check for it in reinitialize-instance too
19:47:24 fourier ye, forgot about reinitialize-instance
19:56:05 Krystof I'm missing context, but if this is about an initarg check for a standard object, you might want to do it in shared-initialize
19:56:27 Krystof (which will catch initialization, reinitialization, change-class and class redefinition)
19:58:06 fourier nice
20:44:12 dlowe so the context is making sure a class-slot is initialized to something passed into make-instance
20:44:20 dlowe which seems counter-intuitive to me
20:44:47 dlowe Krystof: that's the method I was reaching for but didn't quite manage to grasp :)
20:54:52 rendar can we say that objc with its [name [..]] syntax takes a lot from lisp?
20:55:26 dlowe no, it gets that from smalltalk
20:55:42 dlowe which does take some from lisp
20:55:54 dlowe but that was a long time ago
21:13:09 pjb rendar: it's the syntax for smalltalk blocks; ruby also uses it for its blocks.
21:13:26 rendar uhm
21:13:39 rendar so blocks are not s-expressions
21:13:57 pjb rendar: in smalltalk a message is: object message: arg1 msg: arg2 . to send a message named message:msg: with arg1 and arg2 to object.
21:14:20 rendar yep
21:14:30 pjb rendar: The syntax for blocks (lambda): [ parameters | local variables | messages … ^ result ]
21:14:57 pjb often in the code, we use thunks, ie. lambda without parameters: [ | local variables | … ]
21:15:49 pjb for example: a = b ifElse: [ | d | d := a - b . d print . ^ d ]
21:15:55 rendar wait, CL has [ | ] ?
21:16:14 pjb rendar: now, I implemented a reader macro similar to Objective-C for Common Lisp : Objective-CL
21:17:24 rendar wow amazing, but i;m too new
21:17:53 pjb rendar: it would need an overhaul to be able to work with all the Objective-C runtime via all the FFI (ie. CFFI) on all the CL implementations. For now, it works mostly with the Apple runtime on CCL (and CFFI but also some CCL specific FFI).
21:18:07 pjb rendar: reading the sources may be instructive.
21:18:29 rendar i'm interesting in deep understanding the differences between smalltalk/objc blocks vs. s-expressions
21:18:49 pjb S-expression is a syntax for literal lisp data.
21:19:06 pjb To write a list containing numbers 1 2.3 and the symbol foo: (1 2.3 foo)
21:19:49 pjb We can use such literal lisp data to represent programs: (if (= a b) (princ "equal") (princ "different"))
21:20:39 pjb We can write programs called interpreters or compilers, to evaluate such programs. There's CL:EVAL, CL:COMPILE, and CL:COERCE that can convert S-expressions representing programs into lisp execution or compiled lisp functions.
21:21:09 pjb To represent a function we use the data syntax: (lambda (a b) (if (= a b) (princ "equal") (princ "different")))
21:21:24 pjb And we can compile it: (compile nil (quote (lambda (a b) (if (= a b) (princ "equal") (princ "different"))))) #| --> #<Anonymous Function #x302008B990DF> ; nil ; nil |#
21:21:41 pjb We can then call this function: (let ((fun (compile nil (quote (lambda (a b) (if (= a b) (princ "equal") (princ "different"))))))) (funcall fun 1 2)) #| different --> "different" |#
21:22:13 pjb Here the s-expression is a literal (as denoted by the quote operator); but you can also build it with your own programs.
21:22:27 pjb Oh! Note that the program (let ((fun (compile nil (quote (lambda (a b) (if (= a b) (princ "equal") (princ "different"))))))) (funcall fun 1 2)) is also a S-expression!!!
21:23:28 pjb This works because the lisp system contains a REPL and a file compiler and file loader that will read those S-expressions, and pass them to CL:EVAL automatically: (LOAD "file.lisp") or (COMPILE-FILE "file.lisp"), or the REPL.
21:23:46 pjb the REPL is a Read Eval Print Loop that is the basis of interaction with the lisp system.
21:24:15 pjb When you type a S-expression in the REPL, it is first READ, ie the text you type is converted to a lisp data structure (a list if it starts with "(").
21:24:42 pjb THen this lisp data structure is passed to CL:EVAL which will interpret it, and return the result. The result is passed to PRINT which prints it.
21:24:52 pjb And all that is wrapped in a LOOP to read the next S-expression.
21:25:02 pjb (there's also printing of a prompt in there).
21:26:05 pjb rendar: Smalltalk blocks are like lisp anonymous functions. They can be written in S-expression as: (lambda (parameters…) (let ((local) (variables) …) body expressions result))
21:26:40 rendar hmm i see
21:26:49 pjb So you can write (defmethod ifThen ((test T #| generalized boolean |#) thunk) (if test (funcall thunk)))
21:27:00 rendar so s-xpression are even more general than smalltalk blocks
21:27:16 pjb and then: (ifThen (= a b) (lambda () (print "equal")))
21:27:25 pjb indeed.
21:27:42 pjb blocks are just a part of the smalltalk program syntax.
21:27:49 pjb S-expression is the whole syntax for lisp data.
21:28:09 pjb and since we represent lisp program sources as lisp data, you can use S-expressions to write all lisp programs.
21:28:31 pjb (write or generate, it's data, so you can generate it by program! such as macros).
21:28:57 pjb In almost all other languages, the source is defined as a text file, ie a string of characters.
21:29:26 pjb But in lisp, the source is lisp data (cons cells, atoms, numbers, strings, etc). This is what is processed by EVAL or COMPILE.
21:29:45 pjb Only this lisp data can be read with CL:READ, from the S-expression form (which is also a textual representation).
21:30:13 pjb And since there's also a printer CL:PRINT to print S-expressions, we can print and read and print back code (or data).
21:30:27 pjb It's a serialization/deserialization format.
21:30:43 rendar yeah
21:31:14 pjb Now, there are some types of lisp objects that don't have a readable print syntax. Eg. packages: *package* #| --> #<Package "COMMON-LISP-USER"> |# It starts with #< which cannot be read.
21:32:36 pjb But for you own classes of objects, you can define a method on the PRINT-OBJECT generic function to print them readably.
21:32:36 rendar hmm ok, i see
21:32:46 rendar i'm too new to lisp, i have to study more for now :)
21:33:05 rendar i guess that knowing how parsers work, helps a lot in understanding s-exprs
21:33:07 pjb For example, CCL does this for random states: *random-state* #| --> #.(ccl::initialize-mrg31k3p-state 1662898282 955392070 420261365 823417203 431141722 953184299) |# It uses the #. syntax which reads a form and evaluates to read the object.
21:34:02 pjb rendar: yes, and no. The thing is that the grammar is trivial. There's a lexical analysis which is specified in the chapter 2 of CLHS, as the "lisp reader algorith", and all the rest of the syntax is defined as reader macros and dispatching reader macros.
21:34:30 rendar hmm, what is CLHS?
21:34:30 pjb The lisp reader algorithm knows only how to read symbols, integers, ratio and floating point numbers.
21:34:45 pjb The Common Lisp Hyper Spec, an transcription of the standard.
21:34:59 pjb It's the language reference.
21:35:40 rendar there is a pdf vers?
21:35:53 pjb We can give a coarse grammar for S-expr, but this is only what lisp does by default, with the default reader macros. You can install your own reader macros, and change that syntax.
21:36:23 pjb rendar: AFAIK nope. There's a copyright on the web site. IIRC gcl had the authorization to make a copy in info format.
21:37:10 rendar i see
21:37:10 pjb rendar: the ANSI/ISO organization will sell you for dear money a PDF of the standard, which is a bad scanning of a paper printout. It's not worth paying for it, unless you need it for legal reasons.
21:37:22 rendar oh, what is a good CL interpreter/runtime for debian?
21:37:42 pjb So: sexp ::= atom | '(' { sexp } ')' .
21:37:49 pjb there, you have the syntax.
21:38:19 pjb atom ::= integer | ratio | float | string | structure | … . all literal lisp object syntaxes specified by the reader macros.
21:38:25 rendar i see
21:38:56 pjb rendar: I like ccl. sbcl is liked by a lot of people because it generate fast code, but it has the inconvenient of having a new release each month!!!
21:39:18 pjb rendar: abcl is nice if you want to run on the JVM. ecl is nice if you want to embed it with C applications.
21:39:50 rendar i see
21:40:03 pjb rendar: I find clisp nice for newbies, since it contains an interpreter, and some niceties, (but a lot of people don't like it because it has new releases each 10 or 20 years, and compiles to a VM).
21:40:15 pjb rendar: there are a lot of CL implemetnation with advantages and inconvenient.
21:40:24 rendar yeah
21:40:26 pjb But what's nice, is that they all run Common Lisp.
21:40:36 pjb So if you write a conforming CL program, it will run the same on all implementations.
21:41:25 pjb The choice also depends on the target system and processor.
21:41:41 pjb There's also clasp which integrates nicely with C++.
21:41:49 rendar thanks
21:41:59 rendar i think sbcl is great
21:41:59 pjb And there are commercial implementations too.
21:42:32 pjb I really don't like it changing every months. It's too often.
21:42:38 Alfr rendar, the whole hyperspec can be obtained from the lispwroks website.
21:43:09 Alfr rendar, in case you asked for a pdf to use offline.
21:43:11 pjb as html
21:43:20 pjb Then you can process this html into whatever you want.
21:43:33 pjb But you cannot redistribute it, since it's copyrighted.
21:44:59 rendar ok
21:48:59 pjb rendar: note that you may prefer to read some book or lisp tutorial before reading the CLHS, since the later is not pedagogical at all (it's a language reference).