Search
Saturday, 16th of September 2017, 0:13:18 UTC
0:13:32
Bike
(apply #'+ (compute-a-list-of-numbers))
0:13:33
pjb
of course. Or you can write a macro that has to call a function, but it doesn't know the number of arguments.
0:14:01
iqubic
What would such a macro look like?
0:14:03
pjb
(defmacro do-something (fun) `(apply ,fun (read)))
0:14:23
iqubic
What does read repersent in that macro?
0:14:29
specbot
http://www.lispworks.com/reference/HyperSpec/Body/f_rd_rd.htm
0:14:31
aeth
(defun avg (numbers) (/ (apply #'+ numbers) (length numbers))
0:14:59
iqubic
Let's talk about macros.
0:15:18
pjb
That said, in both cases, you should check for call-arguments-limit, and use reduce in the later case (signal an error in the former).
0:15:57
iqubic
Can I use a case statement in a macro to have the expansion change based on the value of a variable?
0:16:19
Bike
The value of a variable when?
0:16:28
Bike
Is the value known at compile time?
0:16:41
pjb
macros are mere functions.
0:16:54
Bike
macro functions are just functions. the only thing magical about them is when they run, which isn't very magical at all
0:17:10
iqubic
Can macros have multiple s-exps in them?
0:17:29
Bike
Do you mean, can a macro expand into multiple forms?
0:17:44
pjb
The only difference is that macro function always take two arguments: the whole expression, and the environment.
0:18:03
pjb
iqubic: macros are normal functions, they can have any number of s-exps in them!
0:18:17
pjb
But they always return one single sexp.
0:18:24
Bike
Not directly. You can expand into something like (progn ...), which executes a number of forms in sequence.
0:18:44
pjb
macro-function: whole-sexp × environment --> sexp
0:19:02
ebrasca
jasom: I work with cl-who in hunchentoot.
0:19:05
aeth
Iirc, a top level progn is the exception to some of the top-level-only rules because that's the intended output for certain kinds of macros
0:19:19
iqubic
why do you have to use (progn ...)
0:19:20
pjb
defmacro wraps that with a destructuring-bind so that you don't have to do it yourself on the whole-sexp.
0:19:38
pjb
iqubic: because the macro has to return only ONE fucking sexp.
0:20:03
aeth
rule #3 here: http://www.lispworks.com/documentation/HyperSpec/Body/03_bca.htm
0:20:08
aeth
Useful for e.g. declaim
0:20:21
iqubic
pjb, why are you swearing?
0:20:28
aeth
so 3.2.3.1.3 is why progn is used
0:20:37
pjb
So that you record better: I already wrote above one sexp.
0:20:47
aeth
sorry, 3.2.3.1, rule 3
0:21:02
pjb
<02:18:17><pjb> But they always return one single sexp.
0:21:02
pjb
<02:19:19><iqubic> why do you have to use (progn ...)
0:21:29
pjb
Clearly, your brains are not ON. Suck the "fucking" is designed so that you switch from OFF to ON.
0:21:47
Bike
dude, chill out a bit.
0:22:22
aeth
It doesn't have to be designed that way. They could have supported values or something (similar to multiple return values in functions). They just don't. But progn works because the spec was designed for progn to work in that way.
0:22:48
Bike
there wouldn't be much point to having multiple return values
0:22:51
aeth
Probably because it's easier to work with `(progn ...) than (values a b c d ...)
0:22:52
Bike
since you can just return a progn form
0:23:16
pjb
And often not even a progn, but something else, like locally, let, do, etc.
0:24:00
pjb
handler-case, unwind-protect..
4:12:59
shrdlu68
ACTION hasn't slept all night and has made the mistake of taking coffee in the morning.
4:24:22
iqubic
And now you have the jitters I assume?
4:25:50
shrdlu68
I am both fatugued and extremely alert...a distressingly unnatural state.
4:40:06
jasom
my dad used to say that he didn't use coffee to stay awake for work because he'd have to rewrite all the code after he got some sleep
4:41:07
jasom
instead he added a line to his makefile that would echo a bunch of ^G characters to the terminal after it was done building and nap until the beeps woke him up
6:26:46
beach
Good morning everyone!
7:11:22
Marcy
How can I get slime to load something as soon as it starts? I tried editing my .emacs file and it's not working.
7:29:50
jackdaniel
Marcy: you mean someting Common Lisp?
7:30:15
jackdaniel
then you can put anything in ~/.sbclrc (in case of sbcl), or ~/.eclrc (in case of ecl) etc
Saturday, 16th of September 2017, 12:13:18 UTC