<_73>
I wrote this macro DEFCLOSURE that works as intended to give a function name to a lexical closure while allowing a docstring. I have heard that in CL you should never need to use EVAL but I have not been able to come up with a way to get rid of the EVAL in this macro. How could I get rid of this EVAL? (I added the code for PARSE-BODY from ALEXANDRIA because my macro uses it) http://dpaste.com/GKEXZBJPY
Cymew has quit [Ping timeout: 250 seconds]
<Bike>
_73: parse the body at macroexpansion time, not runtime
<_73>
ok Ill try that.
X-Scale` has joined #commonlisp
razetime has quit [Ping timeout: 256 seconds]
X-Scale has quit [Ping timeout: 256 seconds]
X-Scale` is now known as X-Scale
Devon has joined #commonlisp
mfiano has joined #commonlisp
MajorBiscuit has joined #commonlisp
<_73>
Got it thanks. It certainely makes more sense to parse the body at macroexpansion time. http://dpaste.com/62YYP7SPK
mfiano has quit [Client Quit]
Devon has quit [Ping timeout: 256 seconds]
<beach>
What does it do that you can't do with DEFUN?
<beach>
Also, why do you not accept names like (SETF <symbol>)?
<_73>
I am using dlambda from the let-over-lambda book and the author uses this pattern so I extracted it into a macro.
<beach>
Can you summarize that for me so i don't have to read the entire thing?
<beach>
I haven't read that book.
<beach>
But I also don't see what your macro can do that DEFUN can't.
<pjb>
_73: see flet and labels !
<pjb>
(flet ((foo (x) "Return the successor of the number X" (1+ x))) (foo 42)) #| --> 43 |#
<pjb>
(funcall (let ((increment 3)) (flet ((foo (x) "Return the INCREMENT'th successor of the number X" (+ x increment))) (function foo))) 42) #| --> 45 |#
<pjb>
_73: ^
<_73>
Dlambda stands for `destructuring lambda` and lets you write a lambda with dynamic dispatch. `(DLAMBDA (:foo (n1 n2) ...) (:bar (&optional bar) (...)) ...)`. SO I can dynamically dispatch different functions with different lambda lists based on a keyword specifier.
mfiano has joined #commonlisp
razetime has joined #commonlisp
mfiano has quit [Client Quit]
<_73>
If I used DEFUN I would have to funcall the DEFUN'd function to get the lambda out.
<_73>
pjb: I see now. I still think defclosure and dlambda are more convienent though. Also I want to be able to say (symbol-table :entry-p "foo") instead of (entry-p "foo") for example because I have many of these tables and they all have an :ENTRY-P function so I would need to do extra namespace management.
Devon has quit [Ping timeout: 240 seconds]
<_73>
You're solution requires more namespace management in general.
karlosz has joined #commonlisp
Devon has joined #commonlisp
Josh_2 has quit [Read error: Connection reset by peer]
mon_aaraj has quit [Ping timeout: 252 seconds]
karlosz has quit [Quit: karlosz]
mon_aaraj has joined #commonlisp
morganw has joined #commonlisp
Guest7423 has quit [Quit: Connection closed]
Guest7414 has joined #commonlisp
MajorBiscuit has quit [Ping timeout: 240 seconds]
mon_aaraj has quit [Ping timeout: 240 seconds]
mon_aaraj has joined #commonlisp
razetime has quit [Ping timeout: 252 seconds]
<jasom>
_73: CLOS lets you do that with eql specializers
mgl has quit [Ping timeout: 256 seconds]
Nilby has quit [Ping timeout: 240 seconds]
mixfix41 has quit [Ping timeout: 240 seconds]
ldb has joined #commonlisp
kpoeck has quit [Quit: Client closed]
mon_aaraj has quit [Ping timeout: 256 seconds]
mon_aaraj has joined #commonlisp
karlosz has joined #commonlisp
rogersm has joined #commonlisp
ns12 has quit [Quit: bye]
ns12 has joined #commonlisp
Guest7414 has quit [Quit: Connection closed]
mon_aaraj has quit [Ping timeout: 240 seconds]
tyson2 has joined #commonlisp
mon_aaraj has joined #commonlisp
mgl has joined #commonlisp
lisp123 has joined #commonlisp
lisp123 has quit [Ping timeout: 252 seconds]
Inline__ is now known as Inline
Inline has quit [Quit: Leaving]
karlosz has quit [Quit: karlosz]
ldb has quit [Quit: ERC (IRC client for Emacs 27.2)]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
Fade has quit [Quit: leaving]
Inline has joined #commonlisp
cosimone has quit [Ping timeout: 245 seconds]
Fade has joined #commonlisp
Fade is now known as Fade
Dynom has joined #commonlisp
mgl has quit [Quit: Client closed]
karlosz has joined #commonlisp
karlosz has quit [Client Quit]
cosimone has joined #commonlisp
mon_aaraj has quit [Ping timeout: 256 seconds]
kpoeck has joined #commonlisp
mon_aaraj has joined #commonlisp
cosimone has quit [Remote host closed the connection]
zacque has joined #commonlisp
cosimone has joined #commonlisp
aeth_ has joined #commonlisp
aeth has quit [Killed (NickServ (GHOST command used by aeth_))]
aeth_ is now known as aeth
<zacque>
Is this a bug in slime? I tried invoking (slime-eval '(+ 1 2)) from Elisp but got an error: symbol + not found.
<zacque>
To make it work, I have to invoke like (slime-eval '(cl:+ 1 2))
<zacque>
Also, I'm not sure how to pass the optional PACKAGE argument. Both of these fail to work: (slime-eval '(+ 1 2) "CL-USER") and (slime-eval '(+ 1 2) 'cl)
<_death>
it's not a bug.. slime-eval is not really intended for use outside slime's needs.. you can read the docstring for slime-rex to get more details on how it works
lisp123 has joined #commonlisp
lisp123 has quit [Ping timeout: 256 seconds]
<zacque>
Oic, I thought it's a "public" function with a single dash in its name
<_death>
it is.. you can use it within its limitations
aeth_ has joined #commonlisp
aeth has quit [Killed (NickServ (GHOST command used by aeth_))]
aeth_ is now known as aeth
Lord_of_Life_ has joined #commonlisp
<zacque>
Hmmm, ok...
Lord_of_Life has quit [Ping timeout: 252 seconds]
Everything has joined #commonlisp
Lord_of_Life_ is now known as Lord_of_Life
kpoeck has quit [Quit: Client closed]
mon_aaraj has quit [Ping timeout: 240 seconds]
<_death>
you give an elisp datum and it "magically" translates it to a CL form.. if you want to give an arbitrary (but readable) CL form, you can give it `(cl:eval (cl:read-from-string ,cl-form-as-string)) .. it has another limitation in the other direction, in the way of result.. so you can also add a cl:prin1-to-string.. but then you need some way to interpret it
<_death>
(also handle multiple values)
aartaka has quit [Ping timeout: 240 seconds]
<etimmons>
luis: I just discovered that some links on https://cffi.common-lisp.dev/ got broken by the move to common-lisp.dev. All the origin-relative URLs should be directory-relative instead.
<zacque>
_death: You meant like this: (slime-send '(cl:eval (cl:read-from-string "(+ 1 2)")))?
<zacque>
But it crashes my swank server right away
<Devon>
zacque: Try slime-eval instead of slime-send
<zacque>
So, invoking (slime-eval* '(+ 1 2)) works right out of the box
<zacque>
I'll keep in mind the limitations that _death pointed out just now
hashfunc569 has joined #commonlisp
lisp123 has joined #commonlisp
<hashfunc569>
is there a way to ask the SBCL compiler to warn you if you never use a :READER or :WRITER function of a class?
<Devon>
zacque: You might give a doc string, e.g., "Like `slime-eval' but user friendly."
<hashfunc569>
*:READER or :WRITER function designator of a slot
<Bike>
hashfunc569: doubtful. they're globally defined, so they could be used somewhere outside of any code you compile.
mon_aaraj has joined #commonlisp
<zacque>
Devon: Right, thanks for reminding
<hashfunc569>
Bike: that is very unfortunate
<hashfunc569>
now i'm really debating going back to just using DEFSTRUCT
<Devon>
hashfunc569: No doubt some general purpose tool like that is buried in some obscure paper or thesis.
<_death>
how come? if you want something to warn you, you can write define-hashfunc-class that does that
<Bike>
um, you'd have the same problem with defstruct accessors
<hashfunc569>
_death: that is a possible solution
<hashfunc569>
Bike: reason being is that now the code can't be self-documenting
<Bike>
huh?
<Bike>
what does documentation have to do with the warning?
<_death>
hmm, I misunderstood what you asked for.. do you mean if you have a :reader foo in a defclass, the compiler should at some point warn you about it not being used up to that point?
<hashfunc569>
_death: yes, exactly
lisp123 has quit [Remote host closed the connection]
<_death>
at what point would that be? any why?
<_death>
(and how does defstruct give better result there?)
<hashfunc569>
because if it's defined, but not used it code-bloat
<hashfunc569>
with defstruct there
<_death>
in Lisp you do incremental development.. if you haven't used something up to now, it doesn't mean you won't use it in the future
<Bike>
there's no way to institute a warning like this for defstruct either. for example, you could define a structure without :read-only t, but never use a writer, and there'd be no warning for that
<Bike>
define a structure slot*
<hashfunc569>
Bike: that's a good point
<_death>
maybe your question makes some sense when you package something up for delivery and want to drop some code that you know won't ever be used (some form of "tree shaking") but otherwise it doesn't make sense to me
<Bike>
yeah, more or less. it's more like a linting concern than anything that a compiler is doing
<hashfunc569>
ok fair enough. but i'm the type of person that when i see a :WRITER function defined for a class, i will cache that it my mind, thinking, "ok, this slot will at some point be written to" but since that may not be the cause, i can no longer hold that thought as an invariant
kpoeck has joined #commonlisp
<Bike>
yeah, i don't think it's unreasonable to want it.
<_death>
instead maybe think in terms of interfaces and protocols, not slots.. slots are often just an implementation detail, and :writer is just sugar to define a method to set the slot's value..
<hashfunc569>
i see what you're saying
<hashfunc569>
unfortunately :READER nor :WRITER can't be set to nil either
<_death>
what do you mean? you can just not have them
<hashfunc569>
right, but being as explicit about the data structures as possible is what i'm aiming for
<_death>
not sure what this has to do with data structures
<hashfunc569>
a slot is part of the structure of the data
<_death>
right.. and readers/writers are one way to access it, so?
<Bike>
not having a :writer seems pretty explicit to me
<_death>
maybe you want to be explicit about an _abstract data type_.. then you can define a class that has no slots at all, (defclass queue () ()) .. and a bunch of defgenerics like (defgeneric queue-insert (queue item)) (defgeneric queue-empty-p (queue)) etc.
<_death>
then, you can have a (defclass my-super-weird-queue (queue) ()) (defmethod queue-insert ...) etc.
<_death>
(well, with slots)
<_death>
a user then usually doesn't have to know anything about the implementation of my-super-weird-queue, just care about the protocol (that it's a subclass of queue, and implements the right semantics for the defgenerics)
nature has quit [Ping timeout: 256 seconds]
lisp123 has joined #commonlisp
cage has quit [Quit: rcirc on GNU Emacs 27.1]
lisp123 has quit [Ping timeout: 240 seconds]
Dynom has quit [Quit: WeeChat 3.4]
zacque has quit [Quit: Goodbye :D]
wyrd has quit [Ping timeout: 240 seconds]
wyrd has joined #commonlisp
shka has quit [Ping timeout: 252 seconds]
molson has quit [Remote host closed the connection]
molson has joined #commonlisp
pillton has joined #commonlisp
molson has quit [Remote host closed the connection]
molson has joined #commonlisp
<jasom>
when you have a moderate amount of data, never underestimate the power of a 4GB hash-table saved in a core image
anticomputer has quit [Remote host closed the connection]
anticomputer has joined #commonlisp
<_death>
what's the amount of information though?
<jasom>
_death: in this case a mapping from ISBN-10 and ISBN-13 to all of the books in OpenLibrary
karlosz has joined #commonlisp
<jasom>
I want to scan all of my books in by barcode; there's plenty of tools that will import a list of ISBNs and do the lookups for you. However many books have multiple barcodes, some of which collide with the ISBN number space but aren't ISBNs, so I need to know quickly if I scanned the right one or not. zbarscan -> my lisp database hash table -> text-to-speach and I can verify that the title is
<jasom>
correct.
hashfunc569 has quit [Ping timeout: 240 seconds]
karlosz has quit [Quit: karlosz]
<_death>
ok.. I guess you used an openlibrary dump then? is it not sorted?
robin has quit [Ping timeout: 240 seconds]
cosimone has quit [Read error: Connection reset by peer]
cosimone has joined #commonlisp
molson has quit [Remote host closed the connection]
molson has joined #commonlisp
robin has joined #commonlisp
ec has quit [Quit: ec]
kpoeck has quit [Quit: Client closed]
lisp123 has joined #commonlisp
<jasom>
_death: correct. It's sorted, but not by the keys I'm looking up
<jasom>
If it were bigger, I might just build a sorted index to the dump and binary search, but it fits in RAM, so *shrug*