freenode/#lisp - IRC Chatlog
Search
13:24:16
pierpal
anyway I recommend you this book https://www.amazon.it/dp/B004IASVJK it's highly educational, as are the other books by the same author.
14:52:47
HighMemoryDaemon
What's a good site for pasting my Lisp code to share a link? Hastebin, my go-to, seems to be down.
15:34:50
kilimanjaro
what's the idiomatic way to get just the first value from a call which returns multiple values
15:35:27
kilimanjaro
e.g. i have a function which ends with (gethash foo frob), but i don't want the user to see the second value
15:52:58
kenster
Streaming some lisp programming: https://youtu.be/ZYdsxGa78q4 or https://www.twitch.tv/kingherring
17:41:41
emaczen
How do you tell hunchentoot to serve an image with define-easy-handler? To serve HTML the body is just an HTML string, and so I am confused about how you would serve an image?
17:53:07
Demosthenex
ok, wait. in CL (cdr nil) is nil instead of throwing an error? maybe it's my time spent in scheme, but i thought that'd throw an error
17:55:17
Demosthenex
i always wrap assoc calls in (or (assoc :key alist) '(nil . nil)) so that i can safely cdr a default value when no key exists
17:58:57
Demosthenex
anyway, yeah, i'm enjoying common lisp. working with my son and trying to show him assoc lists.... but i guess we don't need that or for association lists ;]
18:00:31
Demosthenex
just amused that i was trying to show him a "TADAAAA" moment where it'd throw an error when we searched for a bad key, and.... instead it just returned nil. of course i was surprised l;]
18:02:24
pjb
Demosthenex: but since nil is both false, empty list, and no value, this is there reason why you can write (or (cdr (assoc key a-list)) "Hello")
18:03:12
pjb
Which doesn't prevent you to distinguish those cases (assoc key a-list) is true if it's present as `(,key . nil)
18:04:57
Demosthenex
just checking whether an exit is blocked in a room. he's chosen to keep his map data in a 2d array of alists
19:20:00
Bike
if you explain your problem in more detail, it's possible someone could come up with another solution.
19:21:13
kenster
the first argument is the class and the second the params you want to pass into make-instance
19:22:21
kenster
:content-file (make-instance 'hosted-content-file :id (b32c:b32c-decode content-id) :file-name filename))
19:22:53
Bike
Could you paste an example with-foreign-class form? If it's very long, on a pastebin site, please.
19:26:57
Bike
(defmacro with-foreign-class ((class-name &rest params) instance &body body) `(let ((,instance nil)) (unwind-protect-foreign-class ,instance (setf ,instance (make-instance ,class-name ,@params))) ,@body))) might be what you want?
19:27:30
Bike
You're the one doing quotation there, like in ',(second spec), but you don't actually want to, so...
19:27:50
Bike
oh, and then you'd use it like (with-foreign-class (hosting-session :id (gensym ..) :in-progress t ...) ...)
19:29:01
Bike
Anyway, the point is that you don't need to bind the params to a variable, or quote them, or anything.
19:29:18
Bike
If it gets confusing, try writing out a macro form you'd like to have, and then manually write what the expansion ought to be.
19:29:29
Bike
In this case, I think it's intuitive that we'd want a simple make-instance form like that.
19:30:03
kenster
I assembled the args like that because I didn't know about the args in the macro definition
19:31:07
Bike
you could have (defmacro with-foreign-class (spec instance &body body) `(bla bla bla (make-instance ,(first spec) ,@(second specd))))
22:12:23
AeroNotix
can the setf place be a variable? E.g. (setf (foo bar) value) where foo and bar are symbols which have the values of what I want setf to operate on?
22:13:21
Shinmera
foo must either be the name of a setf-expander, or constitute the function name (setf foo)
22:14:43
Shinmera
If all your possible foo places are implemented via functions rather than setf expanders you can simply instead do (funcall `(setf ,foo) value bar)
22:36:41
pjb
AeroNotix: the trick is to understand the basic feature of lisp which is taught in the 2nd part of the 5 minute introduction to lisp.
22:37:00
Shinmera
pjb: He means that foo should denote the place to pass bar and the value to, not foo being another variable to set.
22:37:03
pjb
That is: ALL lisp expressions are lists whose FIRST element is the name of the operator!
22:39:48
pjb
And finally if it's bound to the name of an implementation specific accessor, then you would have to use eval, which will be difficult.
22:44:14
pjb
random-nick: there's no difference between the terms form, sexp, data, lisp object, expression, etc.
22:46:12
no-defun-allowed
and atoms, yes those too. the only real difference between code/data is how they are used.
22:47:13
pjb
no-defun-allowed: I would even argue against that: (let ((x #(1 2 3))) (identity x) (eval x)) the same lisp object is being used as data AND as code!
22:48:02
pjb
no-defun-allowed: see it more like the dual nature of physics: particule & probability wave function.
23:39:11
White_Flame
even more literally: (defmacro defun-with-source (name params &body body) `(progn (register-source-code ',name ',params ',body) (defun ,name ,params ,@body)))
0:39:45
pjb
White_Flame: https://www.informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/ibcl/index.html
0:55:44
White_Flame
I know there were some very simple Lisps for the C64; with that thing having much more ram it could have been more viable
1:08:28
v0|d
White_Flame: designing a board w/ more ram is painful w/o 4-6lyrs. Not sure they have the tech back in then.