freenode/lisp - IRC Chatlog
Search
15:29:24
pjb
d4ryus: for example, in general when definining reader macros, I use the function name, so I can easily redefine the reader macro (for some characters, if you botch your reader function it can be difficult to redefine (read) it).
15:32:54
d4ryus
jmercouris: Baggers has a video on destructuring-bind ('Little bits of lisp - destructuring bind' on youtube)
15:34:00
Bike
it means the lambda list can be structured like a macro call is. like, consider making your own macro that just duplicates let. you'd use it like (mlet (binding1 binding2...) body...). so you could (defmacro mlet ((&rest bindings) &body body) ...)
15:40:35
jmercouris
this: (defmacro serapeum.exporting:defclass (name supers &body (slots . options))
15:40:53
jmercouris
means it expects a list of at least 2 elements, with a varied amount of elements after of the form of a dotted pair
15:41:39
Bike
(slots . options) is exactly equivalent to (slots &rest options), like i said earlier.
15:42:06
Bike
"A destructuring lambda list (whether at top level or embedded) can be dotted, ending in a parameter name. This situation is treated exactly as if the parameter name that ends the list had appeared preceded by &rest. " in the page i linked.
15:44:07
pjb
jmercouris: (foo . bar) is a cons cell. A list such as (a b c d) is also a cons cell!!! It's (a . (b c d)). So you can match the two cons cells, and identify foo = a, and bar = (b c d). Therefore you can see that (foo . bar) is equivalent to (foo &rest bar).
15:52:05
sjl_
One thing that's mildly annoying that I run into: I often want to have a name-and-options parameter for a macro that's used like this: https://hg.stevelosh.com/chancery/file/tip/src/chancery.lisp#l224
15:53:06
sjl_
I could embed the destructuring (name &key foo bar baz) into the lambda list, but then callers wouldn't be able to give a bare symbol to mean a name with no options
15:54:04
sjl_
So either I embed the (name &key ...) into the lambda list, which is less code and more obvious for users when your editor shows you the lambda list as you type
15:54:41
sjl_
Or I do an opaque name-and-options in the lambda list, then (destructuring-bind (name ...) (alexandria:ensure-list name-and-options ...)) in the body
15:58:27
jackdaniel
sjl_: I've seen that some some lisps (by some I mean allegro and genera, possibly more) recognized a declaration for arglist
16:00:46
jmercouris
I'm sure there is a way by looking through all symbols, but I meant some idiomatic way
16:01:23
Bike
keep in mind this is direct specializations, so it won't get any methods specialized on a subclass
16:03:40
_death
sjl: there is a start of a mechanism for "enriched arglists" in slime (see contrib/swank-arglists)
18:21:45
puchacz
hi, I am trying to use cl-conspack with (tracking-refs (*refs*) (decode (encode x)))
18:24:10
puchacz
it can decode when I skip tracking refs, but of course I am left with forward reference inside an object
21:39:20
puchacz
okay, so I had decode and encode that was not specialised, so it was the first problem. I realised I should at least specialise on standard-object
21:39:58
puchacz
next, there are forward references, but they are only resolved if they are kept in alist or a hashmap, or an array, but not in the slot of the object
21:40:42
puchacz
so my workaround was to store alists as decoding is progressing, and only copy values from alists to slots after conspack is done