<Josh_2>
I do not have my physical copies with me :(
<hayley>
I only actually have one copy, but I had both my own copy, and had borrowed the university copy for a short period of time.
MajorBiscuit has quit [Quit: WeeChat 3.5]
<hayley>
Coming up on having borrowed the Garbage Collection Handbook without interruptions for a year. Richard Jones told me if I hold out for a few more months, I could get the new edition.
MajorBiscuit has joined #commonlisp
<hayley>
Well, I hope it's a year. I have the little slip of paper that fell out, with "PATTON, HAYLEY 19.07.21" written on it, but the online system says I borrowed it on the 14th. Granted, it took a week for the library to find the book.
Cymew has joined #commonlisp
saura has joined #commonlisp
saura has quit [Ping timeout: 240 seconds]
jmes has joined #commonlisp
Th30n has joined #commonlisp
lisp123 has joined #commonlisp
<Josh_2>
Not a big difference
lisp123 has quit [Ping timeout: 256 seconds]
<CodeBitCookie[m]>
Good Morning Everyone!
rodicm has joined #commonlisp
<rendar>
should i buy that book? :)
<beach>
rendar: The garbage-collection handbook? Sure, if you are interested in automatic memory management. It has a description of all the major techniques and their characteristics. And there is no other book like it.
<hayley>
AMOP or the GC Handbook? I only bought the former, but the latter would be a good investment too.
Brucio-61 has joined #commonlisp
<beach>
rendar: However, it is not very well written, though perhaps the new edition will be better. I suspect not, however.
<hayley>
Though, yes, as beach says, the latter is only useful if you want to work with garbage collection.
<hayley>
The description of the Lisp-2 compaction algorithm is going to be better in the new edition, at least.
<beach>
Good.
<beach>
Though I am referring mostly to the use of the English language.
<rendar>
the art of metaobject protocol, yes
<hayley>
Yeah, I often found I needed to look at the papers cited in order to understand what was going on. But having those references is also useful.
<beach>
hayley: Of course, now that I think about it... I often say that I think that in order for someone to be a good programmer, that someone needs to know about computer architecture and compiler techniques. Maybe I should add "memory management (automatic or manual)" to that list.
<hayley>
In particular, I can never remember the name "Java server performance: a case study of building efficient, scalable Jvms" which is relevant to my current work. The paper on Immix cites a website by IBM that does not exist anymore, but the GC Handbook cites that article instead.
<beach>
rendar: That's a tricky book to understand. I only managed the third time around.
<rendar>
it explains how CL allocates/deallocates/manages object?
<beach>
rendar: But it is a very important book. Alan Kay said it was one of the most important CS books ever written, or something to that effect.
<beach>
rendar: The AMOP book is about how CLOS works.
<hayley>
"The best book anyone's written in the past ten years" I think.
<beach>
Thanks.
<rendar>
wow i see
<rendar>
i have also Lambda over Lambda
<beach>
"Let over Lambda"?
<rendar>
yes
<hayley>
On the other hand, he said it was hard to read if you weren't familiar with Lisp. Which I can understand, honestly, as I think Dylan would have been the only other language with generic functions, in 1997.
<hayley>
LET can be transformed into LAMBDA after all.
attila_lendvai_ is now known as attila_lendvai
<beach>
hayley: Yes, perhaps with some alpha renaming.
scymtym has joined #commonlisp
<beach>
(let ((&rest 10) (x 20)) x) is not the same as ((lambda (&rest x) x) 10 20)
<hayley>
Right.
mon_aaraj has quit [Ping timeout: 244 seconds]
<hayley>
In a Hacker News comment, Alan Kay also gave the praise "I liked the MOP book because they carried the model more deeply into the actual definitions -- I very much liked their metaphor that you want to supply a "region of design and implementation space" rather than a single point."
pjb has quit [Read error: Connection reset by peer]
<pjb>
in any case, it can be dangerous to name your variables with lambda-list keywords…
leeb has quit [Quit: WeeChat 3.0]
Th30n has quit [Ping timeout: 244 seconds]
<_death>
pjb: this error has nothing to do with the &allow-other-keys.. (maybe you confused it with :allow-other-keys)
<pjb>
_death: you're right, I was confused.
jmdaemon has quit [Ping timeout: 240 seconds]
<pjb>
(happily, keywords are constant variables, so you cannot bind them).
epolanski has joined #commonlisp
<_death>
also happily, beach's idea of renaming seems fine, because &rest etc. cannot be declared special by the user.. though I guess if there are some implementation-specific lambda-list-keywords it may be an issue (but sbcl has a package lock on sb-int:&more, so no issue there)
<TMA>
I cannot find whether it is specified for &rest etc. to be present or accessible in the COMMON-LISP package.
<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."
<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.
Algernon69 has joined #commonlisp
<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)
<_death>
it's a conjunction.. it has to (i) begin with an ampersand (ii) be specially recognized in the lambda list
<_death>
well, (i) have a name that begins with an ampersand
<TMA>
_death: it is a conjunction. but there is the ambiguity as to the antecedent of "that"
<TMA>
the ambiguity is whether the ... shall be just x or (symbol-name x)
<_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
X-Scale has quit [Ping timeout: 276 seconds]
X-Scale` is now known as X-Scale
nij- has joined #commonlisp
<nij->
phoe I bought a phys copy of your book on condition system. It's great so far :D Thanks!
<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
<nij->
I have some naive questions though, if you don't mind, phoe.
<nij->
1. I wonder why can't we use if/case forms to handle different conditions. Isn't that simpler?
<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)?
<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?
<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
<TMA>
at least in other standards
<_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 :)
<TMA>
"A list of all the lambda list keywords used in the implementation, including the additional ones used only by macro definition forms."
<TMA>
it still keeps a bit of wiggle room for symbols that are recognized by the implementation but not used in it
<TMA>
those merely recognized need not be on the list
jeosol has quit [Quit: Client closed]
lisp123 has joined #commonlisp
<_death>
what would be the use of such a list then
<pjb>
TMA: note: (defun specially-recognized-in-a-lambda-list-p (x) (member x lambda-list-keywords))
<pjb>
TMA: so really the &-beginning-symbol-p in the definition is only a constraint on what is in lambda-list-keywords.
<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).
<pjb>
Alsok it would be hard to use #:&REST since you'd have to find it in lambda-list-keywords for reference.
<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
<hayley>
evaluation of their arguments.
<_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?
mon_aaraj has quit [Ping timeout: 276 seconds]
treflip has joined #commonlisp
<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.
<lisp123>
nij-: this isn't a question restricted to common lisp
<pjb>
_death: lambda-list-keywords list is more informative than just a predicate.
mon_aaraj has joined #commonlisp
<nij->
hayley 2. What does "unwind" mean? What makes those languages unwind and lose too much info?
<lisp123>
In general you want ordinary control flow through if/case
<lisp123>
and control flow for say _exceptional_ circumstances to flow through the condition system
<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.
<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)
<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?
<lisp123>
hayley: I use macros a lot for that use case
<hayley>
Unwinding means to abandon evaluation of some evaluation. What RETURN-FROM, THROW, etc do.
<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.
<_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
<nij->
lisp123 why do we want the exceptional circ. to flow through the cond. system not if/case?
Th30n has joined #commonlisp
<nij->
hayley: But macros, on the other hand, are not first class citizens. We can not apply things on them..
<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
<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)
<nij->
lisp123 ! I think that makes sense. Yeah, if I use if/case ordinarily, the main body will be crowded with exception handlings.
<lisp123>
exactly
<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
<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.
Algernon69 has quit [Ping timeout: 276 seconds]
<nij->
So yeah phoe 1 is resolved :)
<nij->
What can we apply on macros then? .. While functions are objects, macros are ..?
<Th30n>
Shinmera: gratz on getting the 2nd stretch goal! :D
<lisp123>
you can wrap a macro in a lambda and apply on it
<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.
<Shinmera>
Th30n: thanks!
<jackdaniel>
my head is spinning from all that evaluation
<lisp123>
its hard to understand macros vs functions as a beginner and then one day it clicks
<nij->
jackdaniel keep it spinnin'!
<lisp123>
if you remember that macros are used to create new syntax, thats a good heuristic to guide you
<nij->
I know that macros do not eval their args.. just curious what we can apply on macros meaningfully.
<lisp123>
i.e. if you have lots of code repeat or annoying function calls, a macro may be the answer
<jackdaniel>
it's simple, macros are expanded by the preprocessor, that's how we can define operators that accept any kind of arguments!
<jackdaniel>
#define add(a, b) a+b
aartaka has quit [Ping timeout: 244 seconds]
<nij->
Are there some examples where things are applied on macros, and make things easier?
<Shinmera>
what does that even mean
<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.
<jackdaniel>
nij-: you can't apply "on" a macro, because that would require evaluating the argument
<jackdaniel>
(namely, the list in question)
<nij->
Hmm.. maybe I use the wrong terms. I will think more about it and ask again.
<jackdaniel>
if that weren't the case, we could just (defmacro shmapply (the-macro list-to-be-shmapplied) `(the-macro ,@list-to-be-shmapplied))
<lisp123>
cant believe similar discussions were had in 19886
<jackdaniel>
we are repeating the history with the speed of light; each cycle is slightly worse though ;)
<lisp123>
yeah
<Josh_2>
Welcome to the Kali-yuga
aartaka has joined #commonlisp
<Josh_2>
"frustrate would-be implementors of portable code walkers." beach :joy:
<Josh_2>
Only known 40 years ago
mon_aaraj has quit [Ping timeout: 240 seconds]
<beach>
nij-: If you still have questions, maybe I can provide some perspective. Or did you have all your questions answered?
igemnace has quit [Remote host closed the connection]
mon_aaraj has joined #commonlisp
<beach>
nij-: What hayley said is right, but I am not sure you were satisfied with some of the answers.
treflip has quit [Remote host closed the connection]
<pjb>
_death: but lambda-list-keywords IS exhaustive!
<pjb>
nij-: you can apply macros! Instead of using apply you use macroexpand-1.
<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))) |#
<pjb>
nij-: macros are first-class objects in lisp.
<beach>
nij-: I guess maybe some other time. The discussion seems to have moved on.
<_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
<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.
<jackdaniel>
tagbody labels ,)
<beach>
pjb: Comments, places.
<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.
<pjb>
_death: and there's a single interpretation.
<_death>
pjb: I suggest checking the channel log
<pjb>
I've followed it!
<pjb>
_death: Mmm. you mean the "used only by macro definition forms." part. I see now.
mon_aaraj has quit [Ping timeout: 272 seconds]
lisp123 has quit [Remote host closed the connection]
mon_aaraj has joined #commonlisp
<pjb>
_death: the only form that is not a macro definition that uses &-symbols is destructuring-bind!
tyson2 has joined #commonlisp
Algernon69 has joined #commonlisp
<pjb>
_death: so if an implementation has additionnal special &-symbols specific to destructuring-bind lambda-lists, then indeed they won't be listed anywhere.
<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, …
<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.
<_death>
no, that's not what I meant
<_death>
also, DEFUN, for example, is not a macro definition form...
<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.
<pjb>
Right, DEFUN is a definition macro forms; I mixed it with macro definition forms.
<pjb>
_death: IMO, this is all some mixup in the standard, they didn't meant that IMO.
<pjb>
I see no point in restricting lambda-list-keywords to only defmacro.
<_death>
pjb: you should pay attention to TMA's arguments.. I argued against that interpretation by a very mild form of reductio ad absurdum
<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.
<_death>
pjb: description of lambda-list-keywords doesn't restrict to defmacro.. it says the list should _also_ include those symbols
<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!
<pjb>
Therefore lambda-list-keywords is exhaustive and all is good.
<pjb>
Now since it's exhaustive, the glossary definition can be reduced to lambda list keyword = member of lambda-list-keywords.
mon_aaraj has quit [Ping timeout: 244 seconds]
<pjb>
Just adding somewhere the specification that (every (lambda (s) (aref (symbol-name s) 0) = #\&) lambda-list-keyword).
<pjb>
and there is no ambiguity.
<_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
<_death>
<pjb>
Nope. I argue against that. Starting from the precise definition of lambda-list-keywords that you helped me understand.
<pjb>
Normalcy restaured.
<pjb>
s/au/o/
lisp123 has joined #commonlisp
<nij->
beach Thanks, I was away. I need to think of a better question.
<_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
<nij->
pjb I didn't mean "apply macros", but "apply on macros". Something like (higher-order-op #'a-macro)
<beach>
nij-: Sure. I found your questions pertinent, but perhaps could use a more precise phrasing.
<_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
<beach>
nij-: That would be using a macro as a first-class object. You can use the "macro function" as a first-class object.
jmes has quit [Remote host closed the connection]
<nij->
I think I'm looking for interesting cases where macros are applied on.
<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.
<nij->
For functions, we have higher operations like #'compose.
<nij->
(apply #'and t t)
<nij->
Sorry, wrong place..
<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.
<nij->
I understand that part.
<beach>
Ah, OK. Good.
<nij->
I'm just worried about the limit of macros in general.
<nij->
We know that higher order operations are useful.
<nij->
I wonder if higher order operations can't be meaningfully operated on macros.
<beach>
nij-: I think your comparison between functions and macros in that respect is not justified.
<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.
<nij->
Hmm.. I'd rather say I think both of them are objects, so should be transformable in meaningful or interesting ways.
<nij->
It makes the whole language more modular.
<beach>
nij-: What higher-order operations do you know for (say) numbers?
<nij->
s/makes/could make/
lisp123 has quit [Quit: Leaving...]
<nij->
By a higher order operation I mean a function that acts on functions.
Oddity has quit [Ping timeout: 240 seconds]
<nij->
So are there meaningful cases where a function acts on macros?
<beach>
?
<beach>
Sure.
<beach>
Not macros, but macro functions.
mon_aaraj has joined #commonlisp
<beach>
Macros themselves are not first-class objects, but macro functions are.
azimut has joined #commonlisp
<nij->
(I'm quickly looking up what their difference is.)
<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.
<nij->
I'd say that's not what I think..
<beach>
nij-: When you define a macro, what really happens is (setf (macro-function <name>) (lambda (form environment) <the-body-of-the-macro>))
<nij->
To start with, what's the diff between a macro and macro function?
<beach>
nij-: You can get this function back by calling (macro-function <name>).
attila_lendvai has quit [Ping timeout: 276 seconds]
<nij->
Oh ok! I see.
<nij->
Rephrased: Are there meaningful cases where a function acts on macro functions?
<beach>
You can then do (funcall (macro-function 'when) '(when x y z) nil).
<nij->
meaningful/interesting/cool.. etc
<beach>
Not really.
<nij->
hmm :(
<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.
<beach>
nij-: They are different animals. Functions work at run time. Macros work at compile time.
<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"
<nij->
It suggests that such lack is a drawback, making wonder if they were functions (ofc they cant be).. what would be different?
<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.
<beach>
nij-: I do not think he meant replacing binding forms by functions.
<hayley>
I think phoe mentioned a lack of "introspection" functions for handlers in his OLM presentation.
<beach>
Ah, that's possible.
<nij->
That's another subsection.
<nij->
4. (phoe) Are there any ready-to-use portable condition system that's based on CLOS ;) ?
<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.
<beach>
nij-: You mean one that is different from the standard one?
<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.
<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?
<beach>
nij-: So you mean as an implementation strategy?
<beach>
nij-: That might be for historical reasons and because of the way bootstrapping is done in must existing Common Lisp implementations.
<nij->
beach I mean has someone written a portable condition system for Lisp that's based on CLOS
<nij->
The book shows part of how it can be implemented in chapter 3.
<hayley>
I think phoe wrote one?
<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.
<hayley>
More precisely, phoe updated Kent Pitman's CLtL1 implementation.
<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.
<hayley>
(I remember I made a lazy attempt at updating Pitman's code before, but got bored of it quickly.)
<nij->
:) oh this is ready to use :O ?! hayley
<nij->
I thought it's just for educational purpose.
<jackdaniel>
I don't know how about other implementations, but in ecl define-condition is defclass under the hood
MajorBiscuit has quit [Quit: WeeChat 3.5]
<jackdaniel>
and make-condition is make-instance (after processing arguments to have the proper shape)
<nij->
jackdaniel yeah I think he mentioned that most impls uses CLOS, but at least one popular impl doesnt
<jackdaniel>
sbcl doesn't do that, and it is the only one I think
<nij->
:OOOOOOOOO
<beach>
nij-: The system written by phoe is basically what SICL uses natively. I made a few changes.
<nij->
Awesome
<beach>
nij-: What phoe wrote was not meant to be used natively, so I had to adapt it in a few ways.
* nij-
wonders if SICL will replace all implementations one day, soon ;)
<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.
cage has joined #commonlisp
<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.
<beach>
But I take it that his advice was not followed.
<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?
Cymew has quit [Ping timeout: 244 seconds]
<beach>
nij-: I don't see why HANDLER-BIND is the basis of the others.
<nij->
What's the basis (I'm very new to C-S..)?
<beach>
nij-: I just told you. Non-local control-transfer primitives and macros.
<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;
<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
<beach>
nij-: Special variables behave very differently from lexical variables.
<dim>
hi there! is Xach still around sometimes? The certificate for www.xach.com expired on 6/15/2022
<nij->
I will move to clschool..
<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.
<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!
Bike has joined #commonlisp
Bike is now known as Bike
<_death>
pjb: construct a list that corresponds to rest-lambda-list-keyword-p
<pjb>
nij-: (apply (macro-function 'and) (list '(and t t) nil)) #| --> (if t (and t)) |#
<pjb>
_death: this is something entirely different.
waleee has joined #commonlisp
<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.
<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))) |#
<pjb>
EVERYBODY: MACROS ARE JUST FUNCTIONS LIKE ANY OTHER LISP FUNCTION !!!!!!!
<pjb>
macroexpand-1 and macroexpand are already two interesting functions acting on macros…
<hayley>
Inside voices please!
Brucio-61 has quit [Ping timeout: 276 seconds]
Psybur has quit [Ping timeout: 246 seconds]
scymtym has quit [Ping timeout: 240 seconds]
anticomputer_ has quit [Remote host closed the connection]
gxt__ has quit [Write error: Connection reset by peer]
anticomputer has joined #commonlisp
gxt__ has joined #commonlisp
rodicm has quit [Ping timeout: 244 seconds]
rodicm has joined #commonlisp
frgo has joined #commonlisp
frgo has quit [Remote host closed the connection]
frgo has joined #commonlisp
causal has quit [Quit: WeeChat 3.5]
Cymew has joined #commonlisp
rodicm has quit [Ping timeout: 240 seconds]
epolanski has quit [Quit: Connection closed for inactivity]
random-nick has quit [Ping timeout: 272 seconds]
Cymew has quit [Ping timeout: 240 seconds]
random-nick has joined #commonlisp
Th30n has quit [Quit: WeeChat 3.5]
fitzsim has joined #commonlisp
azimut has quit [Remote host closed the connection]
azimut has joined #commonlisp
rodicm has joined #commonlisp
attila_lendvai has joined #commonlisp
X-Scale` has joined #commonlisp
igemnace has joined #commonlisp
X-Scale has quit [Ping timeout: 256 seconds]
X-Scale` is now known as X-Scale
attila_lendvai has quit [Ping timeout: 276 seconds]
jeosol has joined #commonlisp
waleee has quit [Ping timeout: 244 seconds]
igemnace has quit [Remote host closed the connection]
rodicm has quit [Ping timeout: 255 seconds]
igemnace has joined #commonlisp
cage has quit [Quit: rcirc on GNU Emacs 27.1]
<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
MajorBiscuit has joined #commonlisp
livoreno has quit [Ping timeout: 244 seconds]
dra has joined #commonlisp
livoreno has joined #commonlisp
notzmv has quit [Ping timeout: 244 seconds]
rodicm has joined #commonlisp
<fitzsim>
jackdaniel: is that supposed to be an SVG file?
<fitzsim>
I get Lisp code when I load it in a browser
kpoeck has joined #commonlisp
epolanski has joined #commonlisp
kpoeck has quit [Client Quit]
kpoeck has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
<White_Flame>
fitzsim: pretty sure it's an svg rendering of lisp code
<White_Flame>
view page source ;)
<jackdaniel>
fitzsim: yes, it is svg generated from mcclim-svg backend
<jackdaniel>
(and the code is generated from the protocol definition)
waleee has joined #commonlisp
<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
<jackdaniel>
(from the mcclim perspective nothing will change, but loading this system alone won't pull numerous clim abstractions)
nij- has left #commonlisp [#commonlisp]
waleee has quit [Ping timeout: 272 seconds]
cage has joined #commonlisp
yauhsien has joined #commonlisp
yauhsien has quit [Remote host closed the connection]
yauhsien has joined #commonlisp
orestarod has joined #commonlisp
yauhsien has quit [Ping timeout: 240 seconds]
Algernon69 has quit [Quit: Leaving]
rodicm has quit [Quit: Leaving]
MajorBiscuit has quit [Quit: WeeChat 3.5]
tyson2 has joined #commonlisp
ttree has joined #commonlisp
igemnace has quit [Ping timeout: 240 seconds]
masinter has joined #commonlisp
mon_aaraj has quit [Ping timeout: 240 seconds]
mon_aaraj has joined #commonlisp
yauhsien has joined #commonlisp
kpoeck has quit [Ping timeout: 252 seconds]
notzmv has joined #commonlisp
yauhsien has quit [Ping timeout: 256 seconds]
Oladon has joined #commonlisp
vassenn has joined #commonlisp
igemnace has joined #commonlisp
nij- has joined #commonlisp
prokhor__ has joined #commonlisp
kpoeck has joined #commonlisp
livoreno has quit [Read error: Connection reset by peer]
<contrapunctus>
Good, so I don't have to copy-paste my NIH version of that in all my projects ^^'
prokhor has quit [Quit: Leaving]
yauhsien has joined #commonlisp
yauhsien has quit [Ping timeout: 240 seconds]
<White_Flame>
contrapunctus: yeah, I still have so much pre-alexandria code to update
<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.
igemnace has quit [Remote host closed the connection]
nij- has quit [Quit: Using Circe, the loveliest of all IRC clients]
Brucio-61 has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
yauhsien has joined #commonlisp
yauhsien has quit [Remote host closed the connection]
jelewis2 has joined #commonlisp
random-nick has quit [Ping timeout: 244 seconds]
lewisje has quit [Ping timeout: 264 seconds]
yauhsien has joined #commonlisp
igemnace has joined #commonlisp
kpoeck has quit [Ping timeout: 252 seconds]
random-nick has joined #commonlisp
cage has quit [Quit: rcirc on GNU Emacs 27.1]
livoreno has quit [Read error: Connection reset by peer]
[deleted] has joined #commonlisp
Oddity has joined #commonlisp
fourier has joined #commonlisp
<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
<fourier>
ye, forgot about reinitialize-instance
vassenn has quit [Remote host closed the connection]
jeosol has quit [Quit: Client closed]
<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
igemnace has quit [Remote host closed the connection]
<Krystof>
(which will catch initialization, reinitialization, change-class and class redefinition)
<fourier>
nice
son0p has joined #commonlisp
attila_lendvai has joined #commonlisp
tyson2 has joined #commonlisp
waleee has joined #commonlisp
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
[deleted] has quit [Ping timeout: 256 seconds]
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
shka has quit [Ping timeout: 244 seconds]
<dlowe>
so the context is making sure a class-slot is initialized to something passed into make-instance
<dlowe>
which seems counter-intuitive to me
<dlowe>
Krystof: that's the method I was reaching for but didn't quite manage to grasp :)
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
<rendar>
can we say that objc with its [name [..]] syntax takes a lot from lisp?
<dlowe>
no, it gets that from smalltalk
<dlowe>
which does take some from lisp
<dlowe>
but that was a long time ago
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
<pjb>
rendar: it's the syntax for smalltalk blocks; ruby also uses it for its blocks.
<rendar>
uhm
<rendar>
so blocks are not s-expressions
<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.
<rendar>
yep
<pjb>
rendar: The syntax for blocks (lambda): [ parameters | local variables | messages … ^ result ]
attila_lendvai has quit [Read error: Connection reset by peer]
<pjb>
often in the code, we use thunks, ie. lambda without parameters: [ | local variables | … ]
jmdaemon has joined #commonlisp
<pjb>
for example: a = b ifElse: [ | d | d := a - b . d print . ^ d ]
<rendar>
wait, CL has [ | ] ?
<pjb>
rendar: now, I implemented a reader macro similar to Objective-C for Common Lisp : Objective-CL
<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).
<pjb>
rendar: reading the sources may be instructive.
attila_lendvai has quit [Read error: Connection reset by peer]
<pjb>
S-expression is a syntax for literal lisp data.
<pjb>
To write a list containing numbers 1 2.3 and the symbol foo: (1 2.3 foo)
<pjb>
We can use such literal lisp data to represent programs: (if (= a b) (princ "equal") (princ "different"))
attila_lendvai has joined #commonlisp
Josh_2 has quit [Ping timeout: 276 seconds]
<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.
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
<pjb>
To represent a function we use the data syntax: (lambda (a b) (if (= a b) (princ "equal") (princ "different")))
<pjb>
And we can compile it: (compile nil (quote (lambda (a b) (if (= a b) (princ "equal") (princ "different"))))) #| --> #<Anonymous Function #x302008B990DF> ; nil ; nil |#
<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" |#
<pjb>
Here the s-expression is a literal (as denoted by the quote operator); but you can also build it with your own programs.
<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!!!
<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.
<pjb>
the REPL is a Read Eval Print Loop that is the basis of interaction with the lisp system.
<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 "(").
<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.
attila_lendvai has quit [Read error: Connection reset by peer]
<pjb>
And all that is wrapped in a LOOP to read the next S-expression.
<pjb>
(there's also printing of a prompt in there).
<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))
attila_lendvai has joined #commonlisp
<rendar>
hmm i see
<pjb>
So you can write (defmethod ifThen ((test T #| generalized boolean |#) thunk) (if test (funcall thunk)))
<rendar>
so s-xpression are even more general than smalltalk blocks
<pjb>
and then: (ifThen (= a b) (lambda () (print "equal")))
<pjb>
indeed.
<pjb>
blocks are just a part of the smalltalk program syntax.
<pjb>
S-expression is the whole syntax for lisp data.
<pjb>
and since we represent lisp program sources as lisp data, you can use S-expressions to write all lisp programs.
<pjb>
(write or generate, it's data, so you can generate it by program! such as macros).
attila_lendvai has quit [Read error: Connection reset by peer]
<pjb>
In almost all other languages, the source is defined as a text file, ie a string of characters.
<pjb>
But in lisp, the source is lisp data (cons cells, atoms, numbers, strings, etc). This is what is processed by EVAL or COMPILE.
<pjb>
Only this lisp data can be read with CL:READ, from the S-expression form (which is also a textual representation).
<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).
attila_lendvai has joined #commonlisp
<pjb>
It's a serialization/deserialization format.
<rendar>
yeah
<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.
<pjb>
But for you own classes of objects, you can define a method on the PRINT-OBJECT generic function to print them readably.
<rendar>
hmm ok, i see
<rendar>
i'm too new to lisp, i have to study more for now :)
attila_lendvai has quit [Read error: Connection reset by peer]
<rendar>
i guess that knowing how parsers work, helps a lot in understanding s-exprs
<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.
<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.
attila_lendvai has joined #commonlisp
<rendar>
hmm, what is CLHS?
<pjb>
The lisp reader algorithm knows only how to read symbols, integers, ratio and floating point numbers.
<pjb>
The Common Lisp Hyper Spec, an transcription of the standard.
yauhsien has quit [Remote host closed the connection]
<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.
<pjb>
rendar: AFAIK nope. There's a copyright on the web site. IIRC gcl had the authorization to make a copy in info format.
<rendar>
i see
<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.
<rendar>
oh, what is a good CL interpreter/runtime for debian?
<pjb>
So: sexp ::= atom | '(' { sexp } ')' .
<pjb>
there, you have the syntax.
<pjb>
atom ::= integer | ratio | float | string | structure | … . all literal lisp object syntaxes specified by the reader macros.
<rendar>
i see
<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!!!
attila_lendvai has quit [Read error: Connection reset by peer]
<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.
attila_lendvai has joined #commonlisp
<rendar>
i see
<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).
<pjb>
rendar: there are a lot of CL implemetnation with advantages and inconvenient.
<rendar>
yeah
<pjb>
But what's nice, is that they all run Common Lisp.
<pjb>
So if you write a conforming CL program, it will run the same on all implementations.
<pjb>
The choice also depends on the target system and processor.
<pjb>
There's also clasp which integrates nicely with C++.
<rendar>
thanks
<rendar>
i think sbcl is great
<pjb>
And there are commercial implementations too.
attila_lendvai has joined #commonlisp
<pjb>
I really don't like it changing every months. It's too often.
<Alfr>
rendar, the whole hyperspec can be obtained from the lispwroks website.
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
<Alfr>
rendar, in case you asked for a pdf to use offline.
<pjb>
as html
<pjb>
Then you can process this html into whatever you want.
<pjb>
But you cannot redistribute it, since it's copyrighted.
yauhsien has joined #commonlisp
<rendar>
ok
tankrim has joined #commonlisp
<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).
attila_lendvai has quit [Ping timeout: 256 seconds]
causal has joined #commonlisp
tankrim has quit [Ping timeout: 276 seconds]
cosimone has quit [Remote host closed the connection]
cosimone has joined #commonlisp
jeosol has joined #commonlisp
cosimone has quit [Remote host closed the connection]
nij- has joined #commonlisp
tankrim has joined #commonlisp
cosimone has joined #commonlisp
orestarod has quit [Ping timeout: 276 seconds]
epolanski has quit [Quit: Connection closed for inactivity]
azimut has quit [Remote host closed the connection]