libera/#commonlisp - IRC Chatlog
Search
20:05:00
pjb
also, Casting Spels in Lisp Conrad Barski, M.D. http://www.lisperati.com/casting.html for macros.
20:05:39
pjb
seok: sicp chapter 4 is all about metalinguistic programming in lisp (it uses scheme, but it's the same).
22:35:42
aeth
Common Lisp macros are surprisingly easy if you use separate functions (the catch: the functions have to be in a separate file from the DEFMACRO or they need to be inside of an EVAL-WHEN). Remembering when to gensym can be a bit tricky, too, but you avoid issues like not unquoting with , at the right time (nobody knows how to write ` in `) if you use a lot of functions, or at least a giant LET/FLET
22:37:44
_death
to avoid eval-when you can have the functions and defmacro in a single file, but users of the macro in another
22:38:24
aeth
_death: that works until you have a second macro that expands into the macro you just wrote
22:39:29
aeth
there's one thing that's not obvious at all with fancy macros, though: if you need to produce two forms instead of one (macroexpand-1 on DEFUN in some implementations to see this), you need PROGN
22:40:45
aeth
But I don't think there's any book substitute to just writing macros because it's just a bunch of edge cases you get from experience.
22:42:49
lisp123
its just a bit of experience and your mind starting to memorrie the combos of `,, `, etc
22:45:20
lisp123
splittist, be careful - most companies are very against sharing company materials with private e-mails or accounts
22:45:40
lisp123
its just not worth the hassle (and if they are not paying you, why work extra for the company?)
23:10:22
lisp123
phoe, indeed. I think the trick is to teach what is macro (syntax generating function), how macroexpansion etc works - its always on my list to write such a tutorial but never mustered enough energy to do so
23:14:09
phoe
it has been a three-step process for me - imagine the form before expansion, imagine the form after expansion, write a pure/idempotent function that will translate from the former to the latter
23:14:53
aeth
phoe: the problem comes from when it's too big to cleanly fit inside of just one function... which is why sometimes people nest `s and create a mess
23:15:54
phoe
and then, a macro is just a pure* function; if you need to split it up then factor it like you would any pure function
23:16:04
aeth
although I guess putting bindings probably results in nesting ` if not cleanly organized, since you'd do e.g. `(let ,(mapcar ...
23:18:01
phoe
with https://github.com/phoe/portable-condition-system/blob/master/src/restarts.lisp being probably the heaviest example
1:35:04
lisp123
What are the downsides of representing a buffer as an Array of strings, one for each line?
1:43:28
kakuhen
depends on what you're doing i guess... the buffers I often deal with would make that representation a very inconvenient one...
1:59:26
kakuhen
i usually deal with things like audio samples... which make that representation a bit inconvenient
2:00:14
mfiano
Arrays of arrays (array of strings) cannot be made very efficient either, being an array of pointers.
2:03:59
lisp123
the context of why I'm going down this route (after doing some analysis), is that an array of 'lines' lends itself to subclassing lines to various media formats - plain text, rich text, pictures, videos, etc
2:28:15
mfiano
I seem to recall there was a way to tell CL to invoke the debugger on printer releated errors, instead of silence and seeing <<error printing object>> (on SBCL) in the printed repr. Is that something on the CL side or SBCL side? (it's been way too long for me to remember this stuff). cc: yitzi I think it was who wrote a portable printer implementation.
2:36:14
Fare
mfiano: in those cases, I had handlers or ignore-errors and validity checks in my own print-object methods