jackdaniel changed the topic of #lisp to: Common Lisp, the #1=(programmable . #1#) programming language<http://cliki.net/> logs:<https://irclog.whitequark.org/lisp,http://ccl.clozure.com/irc-logs/lisp/> | SBCL 1.4.5, CMUCL 21b, ECL 16.1.3, CCL 1.11.5, ABCL 1.5.0
robotoad has quit [Quit: robotoad]
emaczen has quit [Ping timeout: 252 seconds]
Kundry_Wag has quit [Remote host closed the connection]
Kundry_Wag has joined #lisp
Kundry_Wag has quit [Ping timeout: 252 seconds]
LiamH has quit [Quit: Leaving.]
robotoad has joined #lisp
Essadon has quit [Quit: Qutting]
nirved has quit [Quit: Leaving]
rumbler31 has quit [Remote host closed the connection]
dale has quit [Quit: dale]
Kundry_Wag has joined #lisp
Kundry_Wag has quit [Read error: Connection reset by peer]
Kundry_Wag has joined #lisp
megalography has left #lisp [#lisp]
ryan_vw has quit [Ping timeout: 260 seconds]
<sjl> Is there a way to tell FORMAT to ignore an argument (inside ~{~})?
<sjl> cl-ppcre:all-matches returns a list of (start1 end1 start2 end2 start3 end3 ...) but I only want to print the starts
<Bike> clhs ~*
<Bike> should let you skip around
<sjl> aha
<sjl> thanks
igemnace has joined #lisp
arescorpio has joined #lisp
<sjl> Hmm, is there any way to get cl-ppcre to find overlapping matches?
mejja has quit [Quit: mejja]
<sjl> (ppcre:all-matches-as-strings "a.." "aabc") ; => ("aab")
pierpal has joined #lisp
<Bike> "A common trick is to use capturing technique inside an unanchored positive lookahead" oh god, what the hell
<no-defun-allowed> what the hell is this
<no-defun-allowed> oh, regexps
<sjl> http://paste.stevelosh.com/89de123b33b7efe1e927d9c9dfbdb30dd89d5819 will let me move on with my life I guess
emaczen has joined #lisp
dorothyw has quit [Remote host closed the connection]
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 252 seconds]
lavaflow has quit [Read error: Connection reset by peer]
lavaflow has joined #lisp
ryan_vw has joined #lisp
nanoz has joined #lisp
ryan_vw has quit [Client Quit]
anewuser has joined #lisp
elderK has quit [Quit: Connection closed for inactivity]
Oladon has joined #lisp
esrse has joined #lisp
permagreen has joined #lisp
anewuser has quit [Read error: Connection reset by peer]
shifty has joined #lisp
dddddd has quit [Remote host closed the connection]
dale has joined #lisp
marusich has joined #lisp
pierpa has quit [Quit: Page closed]
Kundry_Wag has quit [Ping timeout: 252 seconds]
robotoad has quit [Quit: robotoad]
Kundry_Wag has joined #lisp
Roy_Fokker has quit [Read error: Connection reset by peer]
wanz has joined #lisp
robotoad has joined #lisp
Kundry_Wag has quit [Remote host closed the connection]
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 272 seconds]
arescorpio has quit [Ping timeout: 246 seconds]
travv0_ has joined #lisp
impulse has quit [Quit: leaving]
rippa has quit [Read error: Connection reset by peer]
Oladon has quit [Quit: Leaving.]
travv0_ has quit [Ping timeout: 272 seconds]
space_otter has joined #lisp
Bike has quit [Quit: Lost terminal]
dale has quit [Quit: dale]
<beach> Good morning everyone!
terpri has quit [Remote host closed the connection]
terpri has joined #lisp
it3ration has joined #lisp
pfdietz has quit [Ping timeout: 250 seconds]
<pillton> G'day beach.
<no-defun-allowed> gday mate
arescorpio has joined #lisp
_whitelogger has joined #lisp
lavaflow has quit [Ping timeout: 246 seconds]
lavaflow has joined #lisp
xkapastel has quit [Quit: Connection closed for inactivity]
nanoz has quit [Ping timeout: 245 seconds]
elderK has joined #lisp
marusich has quit [Quit: Leaving]
Lycurgus has joined #lisp
vlatkoB has joined #lisp
travv0 has quit [Quit: Lost terminal]
<LdBeth> GG
themsay has quit [Ping timeout: 268 seconds]
jochens has joined #lisp
jochens has quit [Ping timeout: 264 seconds]
<makomo> morning
arescorpio has quit [Quit: Leaving.]
<beach> Hello makomo.
frgo has quit [Remote host closed the connection]
travv0 has joined #lisp
it3ration has quit [Ping timeout: 245 seconds]
anewuser has joined #lisp
aindilis has quit [Ping timeout: 246 seconds]
makomo has quit [Ping timeout: 246 seconds]
<splittist> g'day
<beach> Hey splittist.
<splittist> Sitting in my London hotel room waiting for the conference call with folks in three cities that are not London. The glamorous life of the road warrior. I keep thinking I should make time to see Xof, but, of course, I can't 'make' time (even though I live near CERN...).
<splittist> Any other London #lisp-ers?
astalla has joined #lisp
<beach> Wow, terrible.
<Xof> splittist: I have (some) time today!
razzy has quit [Read error: Connection reset by peer]
<Xof> I would be happy to spend it on meeting you
<splittist> Xof: that's very kind.
astalla has quit [Ping timeout: 268 seconds]
frgo has joined #lisp
frgo has quit [Read error: No route to host]
frgo has joined #lisp
frgo has quit [Remote host closed the connection]
frgo has joined #lisp
razzy has joined #lisp
angavrilov has joined #lisp
rozenglass has quit [Remote host closed the connection]
DGASAU has quit [Ping timeout: 244 seconds]
ryan_vw has joined #lisp
robotoad has quit [Quit: robotoad]
impulse has joined #lisp
ryan_vw has quit [Ping timeout: 252 seconds]
xkapastel has joined #lisp
varjag has joined #lisp
jack_rabbit_ has quit [Ping timeout: 252 seconds]
jack_rabbit_ has joined #lisp
azrazalea has quit [Ping timeout: 240 seconds]
shrdlu68 has joined #lisp
mingus has quit [Remote host closed the connection]
mingus has joined #lisp
shifty has quit [Ping timeout: 260 seconds]
heisig has joined #lisp
space_otter has quit [Remote host closed the connection]
slyrus2 has joined #lisp
drewes has joined #lisp
slyrus has quit [Ping timeout: 240 seconds]
slyrus1 is now known as slyrus
slyrus2 is now known as slyrus1
igemnace has quit [Read error: Connection reset by peer]
jochens has joined #lisp
<hjudt> is there a way to catch SIGTERM and SIGINT signals in sbcl? i've tried trivial-signal, but the examples provided do not work; e.g. sending INT only invokes the sbcl debugger but the signal handler does not run.
<no-defun-allowed> after some idea generation in #lispcafe, i present the magrathea anti-vulnerability scanner hunchentoot mixin
<jackdaniel> hjudt: some code illustrating what you try would be nice
<hjudt> basically the examples here: https://github.com/guicho271828/trivial-signal
<hjudt> Usage: toplevel handlers
<no-defun-allowed> it works just like the hunchentoot easy-acceptor but if you load too many "sketchy" URLs in too short time, it zipbombs you
<hjudt> what i want to do: i want to react to TERM so that i can invoke a proper shutdown routine on the server, doing some cleanup.
<jackdaniel> hjudt: if I had to guess I'd first disable interrupt for that signal in sb!unix package
<jackdaniel> (sb-unix::enable-interrupt sb-unix::sigterm :ignore) ; and see if trivial-signal starts working after that
<jackdaniel> that said it may not work, but here's your rod
<jackdaniel> fishing rod*
<jackdaniel> also regrading graceful exit I think there may be a nice interface for adding exit-hooks
<jackdaniel> without playing catch with signal handling
hhdave has joined #lisp
ym has joined #lisp
<hjudt> thanks. i have added a function to sb-ext:*exit-hooks*, which gets called. additionally setting sb-ext:*timeout* to a lower value than the default 60 also solves my problem that sbcl takes too long to shutdown.
rixard has quit [Ping timeout: 244 seconds]
<hjudt> probably my open slime/sly connection prevents an earlier shutdown?
nirved has joined #lisp
shka_ has joined #lisp
<hjudt> hm. disconnecting slime before sending TERM doesn't seem to make a difference.
<shka_> good morning
<hjudt> anyway, using exit hooks and setting the timeout does help in my case
<no-defun-allowed> morning shka_
marvin2 has quit [Remote host closed the connection]
kajo has quit [Remote host closed the connection]
kajo has joined #lisp
irdr has joined #lisp
irdr has quit [Max SendQ exceeded]
igemnace has joined #lisp
travv0 has quit [Ping timeout: 268 seconds]
meepdeew has quit [Read error: Connection reset by peer]
meepdeew has joined #lisp
beach has quit [Ping timeout: 252 seconds]
beach has joined #lisp
orivej has quit [Ping timeout: 268 seconds]
Kaisyu has quit [Quit: Connection closed for inactivity]
wanz has quit [Quit: wanz]
rumbler31 has joined #lisp
kooga has quit [Ping timeout: 260 seconds]
Necktwi has joined #lisp
<Necktwi> is there a cmacs?
rumbler31 has quit [Ping timeout: 244 seconds]
<jackdaniel> ?
<no-defun-allowed> What would that be?
<Necktwi> emacs in clisp
<no-defun-allowed> Climacs?
<jackdaniel> there is climacs
<jackdaniel> there is also hemlock
<Necktwi> ooo
<no-defun-allowed> Pretty sure we call it cl, unless you want an editor that only works with gnu clisp.
<jackdaniel> there is a new project called lem (I don't know how advanced it is right now)
kooga has joined #lisp
<jackdaniel> clisp is one of many common lisp implementations, abbrev for common lisp is CL not clisp
<no-defun-allowed> ^^
<Necktwi> ok i don need a lecture on cl and clisp
<Necktwi> huh
<Necktwi> got one already
<no-defun-allowed> That was..15 words.
<jackdaniel> well, given you misuse terms you clearly needed it
<no-defun-allowed> I might write an editor after Netfarm and Magrathea, but it won't be very emacsy, as it'll work on abstract syntax trees or actual lisp structures.
<jackdaniel> I believe that's what beach works on with Second Climacs (and that was discussed briefly a few days ago on this channel)
<no-defun-allowed> I thought cluffer did string buffers though.
<no-defun-allowed> That's what I remember his presentation on cluffer being at least.
<Necktwi> climacs news is from 2008
<shka_> Necktwi: Second Climacs
<Necktwi> anyone using it?
<no-defun-allowed> It's still a nice environment and I still works.
<no-defun-allowed> *it still works.
<no-defun-allowed> I remember I made an image of it which also loaded a climacsrc for the hell of it and wrote a hello world extension.
pierpal has quit [Quit: Poof]
pierpal has joined #lisp
<no-defun-allowed> Also, it has a better out of the box experience than slime+emacs IMO, I still can't get company mode out of dumb "I see a symbol, I suggest that symbol" mode.
<Necktwi> is the seed of cl written in c or assmebly?
<shka_> Necktwi: cl is a language, not a implementation
<shka_> for what is worth, you can implement cl in java
<no-defun-allowed> Depends on the implementation. Most compile to assembler though.
elderK has quit [Quit: Connection closed for inactivity]
<Necktwi> then what is its impkementation?
<jackdaniel> clisp is written in c, ecl's core is written in c as well, sbcl is written in common lisp, ccl is written in common lisp, abcl is written in java
<no-defun-allowed> SBCL and CMUCL are partly done in C for stuff like the garbage collector and the "everything went horribly wrong" debugger.
<no-defun-allowed> Others like SICL are purely done in Common Lisp though.
<jackdaniel> Necktwi: here you have a brief listing of CL implementations: https://common-lisp.net/project/ecl/static/quarterly/img/vol4/all-hierarchy.png
<jackdaniel> no-defun-allowed: how for instance ccl is "impurely" done in common lisp?
<jackdaniel> or sbcl?
<Necktwi> a lang compiler should start in assembly and then take off with the lang
pierpal has quit [Ping timeout: 252 seconds]
<jackdaniel> I believe you should educate yourself more
esrse has quit [Ping timeout: 252 seconds]
<jackdaniel> GCC doesn't start in assembly, it is written in C
<Necktwi> may be
<jackdaniel> and compiled with older GCC version
<jackdaniel> and gcc may be seen as a lingua franca of open source compilers
<no-defun-allowed> jackdaniel: CMUCL and SBCL do use C for the lowest level parts of their runtimes. I like scaring people with gencgc.c for example.
pierpal has joined #lisp
<no-defun-allowed> Necktwi: it'd be a terrible headache writing a compiler in assembler.
<Necktwi> then the lang is bad one
<shrdlu68> Or terrific fun, depending on your inclination.
<no-defun-allowed> Necktwi: then you have very strange standards.
<no-defun-allowed> Maybe. It's probably a thing for some people.
<no-defun-allowed> At least something like C or Forth is portable though.
<shka_> Necktwi: you are illogical
<jackdaniel> no-defun-allowed: they have some modules written in C, that is not the same. but now I udnerstand what you mean.
<shka_> Necktwi: find me a modern compiler written in assembly
<Necktwi> lisp logo impilies that
wanz has joined #lisp
<jdz> There's a lisp logo?
<jackdaniel> also saying SICL is a Common Lisp implementation may be considered a little bit of exaggeration given it is not complete, I think a more proper term would be: a set of modules written in CL
<Necktwi> what white n black circle
<Necktwi> that white n black circle
moei has joined #lisp
<no-defun-allowed> It's more likely to be finished in the next year than GCL.
<no-defun-allowed> Not the Barski alien? ):
<jdz> Necktwi: are you here to learn something or just reject every opinion that does not match your own?
<shka_> Necktwi: common lisp is language standard, implementations are free to be written any way they like to. There IS NO reference implementation.
<jackdaniel> no-defun-allowed: that doesn't make sense to me. GCL is working ClTl2 implementation with some ANSI parts (so in this sense it is a finished working project)
<no-defun-allowed> jackdaniel: I probably wouldn't want to run CL without a garbage collector, so it's a fairly crucial component of a Lisp system.
<jackdaniel> but I won't argue any further on that
<no-defun-allowed> Oh, I thought it was still noncompliant. Maybe that's another one
<shka_> so for instance, there is nothing like cpython in lisp land
<shka_> there is clisp, true, but it is not reference implementation
<shka_> if you would want to, you could write CL in perl
<shka_> or pascal
<no-defun-allowed> clisp is the shitslow one -- oh we're talking about standard by "I'm the leader implementation"
<shka_> or python
<shka_> or anything
<Necktwi> ytf garbage collector! u see the problems?
<shka_> just like you could write C compiler in java
<shka_> i bet there is C compiler written in Java
<jackdaniel> Necktwi: this kind of discussion belongs to #lispcafe - I suggest all interested should move it there. we've already left CL land with it to some opinions about compilers.
<shka_> good idea
<no-defun-allowed> Necktwi: if you don't want a garbage collector, you can take it to #rust or #c++ probably.
<no-defun-allowed> Meh, this conversation got boring very quickly.
<Necktwi> im just worried there is even a os in clisp mazzeno
<no-defun-allowed> Also I'm heading off to bed now.
<shka_> no-defun-allowed: good night
Bike has joined #lisp
<no-defun-allowed> For fucks sake, it's CL.
<no-defun-allowed> Night, shka_.
<shka_> Necktwi: you have no idea what you are talking about
<Necktwi> agreed
Bike has quit [Client Quit]
wanz has quit [Quit: wanz]
Bike has joined #lisp
astalla has joined #lisp
<dim> anyone here using GCL, even from times to times?
mooshmoosh has joined #lisp
<beach> Necktwi: Mezzano does not use clisp in any way as far as I know.
<dim> jackdaniel: idly trying ecl again, I see a lot of shifting a negative signed value is undefined [-Wshift-negative-value] in the output, hundreds of warnings when compiling lisp code
<dim> #define ecl_make_fixnum(n) ((cl_object)(((cl_fixnum)(n) << 2) | t_fixnum))
<dim> it seems to be just this macro
Essadon has joined #lisp
<dim> /usr/local/Cellar/ecl/16.1.3_3/include/ecl/object.h:131:62
<dim> hope this helps
<jackdaniel> shifting is for int integer <-> fixnum conversion (fixnum is an immediate), this is correct. we could possibly do something with a warning, but I'm not sure how to hid it
<jackdaniel> dim: ↑ thanks for the report though
jochens has quit [Ping timeout: 250 seconds]
<dim> (ql:quickload "pgloader") outputs thousands of those warnings
<dim> mostly because pgloader depends on a lot of other QL systems, of course
<jackdaniel> maybe you have somewhere -Wall flag set?
<dim> where should I look? I didn't hack anything at the ecl level, just brew installed it
<jackdaniel> cffi does some hacking with cflags afaik
<jackdaniel> and it accesses ecl's cmp cflags
<jackdaniel> sorry, I have two pans on fire (making dinner) can't help you more at this moment
<jackdaniel> on fire is a bad word, you know what I mean
<dim> yeah, feel free to ignore me, I know IRC isn't a sync channel
<zigpaw> few more minutes and they could be literally on fire I think ;)
okflo has joined #lisp
marvin2 has joined #lisp
frgo has quit [Remote host closed the connection]
frgo has joined #lisp
m00natic has joined #lisp
okflo has left #lisp ["ERC (IRC client for Emacs 27.0.50)"]
frgo has quit [Ping timeout: 268 seconds]
Lycurgus has quit [Quit: Exeunt]
Kundry_Wag has joined #lisp
Kundry_Wag has quit [Remote host closed the connection]
drewes has quit [Quit: Textual IRC Client: www.textualapp.com]
dddddd has joined #lisp
pierpal has quit [Quit: Poof]
pierpal has joined #lisp
pfdietz has joined #lisp
frgo has joined #lisp
pfdietz has quit [Ping timeout: 250 seconds]
xkapastel has quit [Quit: Connection closed for inactivity]
ebrasca has joined #lisp
astalla has quit [Ping timeout: 268 seconds]
kajo has quit [Ping timeout: 252 seconds]
irdr has joined #lisp
irdr has quit [Remote host closed the connection]
irdr has joined #lisp
pfdietz has joined #lisp
jochens has joined #lisp
shifty has joined #lisp
v0|d has joined #lisp
dmiles has joined #lisp
nicksmaddog has joined #lisp
anewuser has quit [Quit: anewuser]
razzy has quit [Ping timeout: 245 seconds]
Bike is now known as Bicyclidine
LiamH has joined #lisp
anewuser has joined #lisp
rippa has joined #lisp
ggole has joined #lisp
random-nick has joined #lisp
pfdietz has quit [Read error: Connection reset by peer]
pfdietz has joined #lisp
vaporatorius has joined #lisp
pfdietz has quit [Read error: Connection reset by peer]
pfdietz has joined #lisp
emdeesee has joined #lisp
sjl_ has joined #lisp
sjl_ has quit [Client Quit]
sjl_ has joined #lisp
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 246 seconds]
heisig has quit [Quit: Leaving]
Bike has joined #lisp
azrazalea has joined #lisp
scymtym has quit [Ping timeout: 260 seconds]
shka_ has quit [Quit: WeeChat 1.9.1]
irdr has quit [Remote host closed the connection]
cage_ has joined #lisp
steiner has joined #lisp
wanz has joined #lisp
Zaab1t has joined #lisp
Zaab1t has quit [Client Quit]
nly has joined #lisp
irdr has joined #lisp
jkordani_ has joined #lisp
Zaab1t has joined #lisp
steiner has left #lisp ["ERC (IRC client for Emacs 26.1)"]
jkordani has quit [Ping timeout: 240 seconds]
irdr has quit [Remote host closed the connection]
Inline has joined #lisp
irdr has joined #lisp
irdr has quit [Remote host closed the connection]
igemnace has quit [Read error: Connection reset by peer]
blackwolf has joined #lisp
irdr has joined #lisp
n3k0_t has quit [Ping timeout: 246 seconds]
ebrasca has quit [Remote host closed the connection]
igemnace has joined #lisp
shka_ has joined #lisp
dale_ has joined #lisp
dale_ is now known as dale
pfdietz has quit [Read error: Connection reset by peer]
pfdietz1 has joined #lisp
pfdietz1 is now known as pfdietz
warweasle has joined #lisp
jack_rabbit_ has quit [Ping timeout: 260 seconds]
Kundry_Wag has joined #lisp
froggey has quit [Read error: Connection reset by peer]
froggey has joined #lisp
matzy_ has joined #lisp
<shka_> good evening
<beach> Hello shka_.
meepdeew has quit [Remote host closed the connection]
shrdlu68 has quit [Quit: WeeChat 2.2]
robotoad has joined #lisp
Lycurgus has joined #lisp
orivej has joined #lisp
it3ration has joined #lisp
moei has quit [Read error: Connection reset by peer]
potatonomicon has joined #lisp
moei has joined #lisp
k-hos has quit [Ping timeout: 272 seconds]
random-nick has quit [Read error: Connection reset by peer]
pfdietz has quit [Read error: Connection reset by peer]
pfdietz has joined #lisp
Kundry_Wag has quit [Remote host closed the connection]
random-nick has joined #lisp
<matzy_> dunno who else has read it here (I'm assuming most people?), but I've been learning CL, and the second chapter on macros in Practical Common Lisp blew apart my brain last night
pfdietz has quit [Read error: Connection reset by peer]
<White_Flame> in a good way learning new things, or in a bad way of not understanding it?
<matzy_> i would like to say both, but most likely more of the latter
<shka_> there is not that much to understand
<matzy_> beforehand i actually thought i kind of had a grasp on them, but it made it very confusing somehow
<White_Flame> macros take source code, and return source code. This transformation happens before the involved functions are ever called.
<matzy_> i dont get the &rest
<matzy_> is it like, "and grab everything else they may have passed in"?
<White_Flame> so in (my-macro foo bar baz), even if foo/bar/baz are local variables, you get the source code symbols FOO BAR BAZ as parameters to the macro
<shka_> matzy_: pretty much
<White_Flame> yes, (defmacro my-macro (sym1 &rest others) ...) sym1 = FOO, others = (BAR BAZ)
<White_Flame> when called as above
<matzy_> ahhhh
<shka_> matzy_: it is like cl:+
<shka_> you can write (+ 1 2 3 4 5 6)
<White_Flame> &body is pretty much exactly like &rest, but tells the editor to indent it like a code body instead of as a data list
<matzy_> so you could do (defmacro sum (op &rest nums) '(op ,@nums))?
<matzy_> shka_: would that be a macro for your addition?
<White_Flame> (sum + 1 2 3) => (+ 1 2 3) ?
<shka_> matzy_: i mean, that #'+ is a function, and it accepts variable number of arguments
<White_Flame> which woudl evaluate to 6
<shka_> macros are essentially the same
<matzy_> shka_: oh right, i get that. it's more the actual construction that confuses me
<matzy_> White_Flame: ahhh i never knew about that distinction before
rozenglass has joined #lisp
pfdietz has joined #lisp
<matzy_> would my macro work for any math function, or was it wrong?
<White_Flame> it in effect eliminates SUM from the beginning of a sexpr
<matzy_> so you would call (sum + 1 2 3 4 5 6)
<shka_> matzy_: you used ' instead of `
<White_Flame> it's equivalent to (defmacro sum (&rest rest) rest)
<shka_> and macro is pointless, really
<matzy_> White_Flame: oh wow. ok let me look at it for a sec
<White_Flame> (sum format t "foo") would work as well
<matzy_> oh crap lol
<matzy_> so it would work for addition, it just isn't safe (does other things too)?
<White_Flame> it's literally makes SUM a thrown-away prefix on a sexpr
<White_Flame> it's perfectly safe, because it's perfectly redundant ;)
<matzy_> lol
<matzy_> but aren't all macro names throw away prefixes? like you dont use the name for anything besides calling it, right?
<matzy_> or am i confused on what you mean
<White_Flame> macros perform some transformation, usually because you want to generate more complex code given a simpler form
<matzy_> naming my macro sum may be causing the confusion
<White_Flame> (defmacro sum (&rest nums) `(+ ,@nums)) would semantically perform a sum operation, though it's equivalent to #'+
<White_Flame> (sum 1 2 3) => (+ 1 2 3) => 6
<matzy_> ok, now could you pass in the + operator with a substitution like i tried to do?
<White_Flame> and it's writable as a function, (defun sum (&rest nums) (apply #'+ nums))
<White_Flame> a substitution to what?
<pfdietz> matzy_: macros can perform arbitrary computations. They can be used for things that require preprocessors in other languages. Something like yacc, for example, can be done via a macro in Lisp.
<matzy_> could you do: (defmacro sum (operator &rest nums) `(operator ,@nums))
<pfdietz> A general rule though is that if it can be done naturally by a function, don't use a macro.
<Bike> `(,operator ,@nums)
<Bike> in which case, yes
<matzy_> ah right
<Bike> though it's pretty pointless
<matzy_> ok, that makes sense. i just wanted a simple example using rest
<White_Flame> basically, as PCL mentions, write the short macro form and the expanded form that you desire. Then write code to generate one from the other
<White_Flame> create this macro: (defvars *a* *b* *c*), which would expand to (progn (defvar *a*) (defvar *b*) (defvar *c*)) for any given list of variable names
<White_Flame> that's something not easily done with a function
<matzy_> ok, this looks fun
<pfdietz> You might also look at the things in lisp itself that are macros. Call macroexpand or macroexpand-1 on the (quoted) forms to see what they turn into.
<matzy_> so like (macroexpand-1 'when)?
<pfdietz> No, like (macroexpand-1 '(when x (foo)))
Fade has quit [Quit: Lost terminal]
confusedwanderer has joined #lisp
<matzy_> so macroexpand shows what the macro results in, but not the macro itself, right?
<matzy_> the code i'm getting seems to be the evaluated macro form
<White_Flame> pressing Alt-. in emacs when on the macro name will take you to the macro's source code
<pfdietz> Right. They show what happens when macro expansion is performed at the (top level of the) form.
<matzy_> White_Flame: awesome!!!!
Fade has joined #lisp
<matzy_> that's what i wanted to see, their source. but then it'll be super helpful to see how they transform too
<matzy_> White_Flame: ah crap my evil bindings overwrote that shortcut. do you know what the function is that i could call with M-x?
<matzy_> (i can google around didnt know if you had emacs up currently or not)
<matzy_> ah simple go to def, nvm
Kundry_Wag has joined #lisp
<pfdietz> macroexpand-1 does one expansion. macroexpand keeps doing expansion (at the root of the form) until it's not a macro there.
<pfdietz> Also, if you want to see gory details, look at the clhs.
Kundry_Wag has quit [Remote host closed the connection]
DGASAU has joined #lisp
another-user has joined #lisp
it3ration has quit [Ping timeout: 240 seconds]
scymtym has joined #lisp
<another-user> hi, is there real world examples of advantage of clos over structs/plain functions?
<White_Flame> yeah, (collide ball wall). Do you put the collision "method" on class ball or class wall?
<White_Flame> CLOS says methods aren't contained inside classes
<White_Flame> regarding pklain functions, they can't dispatch on their parameter type (at least in the C view of things)
<White_Flame> and CL multimethods can have before/after/around hooks, as well as the meta-object protocol which lets you define what an object, method, etc fundamentally is & does
wanz has quit [Quit: wanz]
rozenglass has quit [Remote host closed the connection]
<White_Flame> during development, CLOS lets you hot-upgrade the class definition
<another-user> White_Flame: yeah, but all those hooks can be implemented trivially with plain functions as well and to define my data i could use structs/maps
<White_Flame> not really
<White_Flame> at leas,t not transparently
<White_Flame> certainly you can turing tarpit any feature, by dumping in lots of programmer discipline burden and mandating specific framework call styles
<jackdaniel> another-user: you could have heard the same argument about introducing functions from assembler programmers
Kundry_Wag has joined #lisp
<another-user> ha-ha-ha, indeed
<jackdaniel> and about introducing objects from C programmers
Kundry_Wag has quit [Remote host closed the connection]
<shka_> another-user: multiple dispatch is a major point imho
<jackdaniel> and aobut introducing closures from forth programmers
<jackdaniel> etc :)
<matzy_> White_Flame: i feel like this should be easier than i'm making it out to be. i dont get how to repeat (defvar ) statements like that for each arg
<White_Flame> matzy_: mapcar
<shka_> matzy_: progn!
<matzy_> (defmacro make-vars (&rest vars) `(progn (defvar ,@vars))) -- is what i have so far
<shka_> oh, ok
<matzy_> but slime wont even let me run that lol
<White_Flame> (mapcar (lambda (x) `(foo x)) '(1 2 3)) => ((foo 1) (foo 2) (foo 3))
<White_Flame> ,x
<matzy_> is there a way with progn?
<Bike> matzy_: then (make-vars x y z) would expand into (progn (defvar x y z)), no?
<matzy_> Bike: ah i see!
<another-user> White_Flame: regarding collide example, it's good point against oop actually, usually it comes up in game dev and there people use ECS instead of OOP
<Bike> you're going to need more defvars
<matzy_> ok let me try again, i'll be back :)
<LdBeth> GG
<beach> another-user: I think you are going to have to trust us that there are tons of advantages of using generic functions and standard objects. You will understand the advantages once you start using these features.
<ski> ("ECS" ?)
<shka_> another-user: CLOS is awesome, allows to write programs with unparalleled extensibility while still being understandable
<beach> another-user: It is good argument against traditional object orientation where the class provides encapsulation and where there is only single dispatch.
<shka_> sadly, there is no really good book that would demonstrate this
<matzy_> Bike: i actually tried that in slime, and it said y was unbound. but shouldn't ,@vars at least work right?
<another-user> ski: entity component system
<matzy_> why isnt that expanding like i want?
<beach> another-user: It is not a good argument against CLOS-style object orientation, where the encapsulation is provided by the package system and we have multiple dispatch.
<shka_> i tried to write example in a blogpost, but sadly i think that i failed to show advantage decently
<ski> never heard. is it related to abstract data types and modules ?
<Bike> matzy_: it's expanding into (defvar x y z), which is what you told it to expand into, but probably not what you want it to expand into.
<Bike> matzy_: you want it to expand into three different defvars. right?
<matzy_> Bike: no, slime throws an error instead of expanding, and while i get it is not what i was trying to do, shouldn't it still work?
<jackdaniel> clos brings a lot to the table. I have ambivalent feelings about this, because it abstracts many things away (so you don't have to think about these things), but also requires a lot of cognitive effort for programmer to understand the code - I'm not sure if using it for anything non-trivial simplifies or complicates programming
<Bike> it should still expand, yes. you're doing (macroexpand-1 '(make-vars x y z)), matzy_?
<matzy_> oh sorry i was actually running it like you did - (make-vars x y z)
<matzy_> and when i do, i get a slime error that "y is unbound"
<matzy_> isnt that the point of &rest and @ though?
<Bike> When you actually RUN it you'll be running (defvar x y z)
<Bike> which tries to read the value of y
<Bike> but there is no variable y, obviously
<matzy_> ahhhhh
<matzy_> i see now, thanks
<Bike> so slime does not throw an error instead of expanding
<Bike> it expands it, and then runs it, and THAT signals an error
<matzy_> wow, that's incredibly helpful to know
<matzy_> somehow i missed that so far
<another-user> beach: White_Flame yeah, i totally agree on usefulness of generic functions, let me clarify why i'am asking this weird questions
* ski . o O ( `(define-syntax make-vars (syntax-rules () ((make-vars ?var ...) (begin (define-variable ?var) ...))))' )
<beach> ski: That does not look like Common Lisp.
<pfdietz> another-user: one example I like is using slots of standard objects as caches. The slot is initially unbound, and when accessed a method for the SLOT-UNBOUND method fills it in. After that the stored value is returned without being recomputed.'
<ski> beach : `syntax-rules' in Scheme. the interesting part here is the use of `...' in syntax patterns and templates, "automagically" expanding to what matzy_ wanted (without an explicit call to `mapcar'/`map')
<pfdietz> Another interesting use case: you want to add some slots to objects, temporarily. Change their class to a subclass that has the extra slots, do your work, then change them back when done.
<beach> ski: Yes, but Scheme is not Common Lisp.
<cgay> jackdaniel: requires a lot of cognitive effort compared to what, though? I personally find today's Java totally impenetrable for example, and a well-written (waving hands wildly) clos program pretty straight-forward.
<ski> indeed. i suppose i was wondering whether someone had implemented such a syntax matching system (with `...'), for CL
<shka_> actually now when i think about it, i may have a decent example!
<shka_> https://github.com/michaelw/cl-dot look how simple the API is
<Bike> i think costanza wrote a paper on implementing hygenic macros in lisp or vice versa
<Bike> the paper i'm thinking of cited something, i'm pretty sure
<ski> well, the issue here isn't hygiene or not
<jackdaniel> cgay: wow, how did you get java to this?
it3ration has joined #lisp
<jackdaniel> cgay: compared to CL which doesn't use advanced clos machinery
<Bike> i mean i assume "implemented hygenic macros" means "implemented something like syntax-rules"
<jackdaniel> i.e a dump function is easier to follow than a generic function with couple of around methods, custom method combination and arguments being non-standard classes
<ski> Bike : not really
<jackdaniel> otoh dumb function doing the same will be longer (given both pieces are written by a good programmer)
<cgay> jackdaniel: i was simply talking about the congitive effort to understand a program, whether clos or something else.
<beach> another-user: You had better clarify fast if you want me to read it. Dinner is imminent. :)
<another-user> i'm coming from clojure world and there people just usually use hash maps for state and plain/generic functions to operate on said state and i'm totally fine with that but i wonder if clos will give me some super advantage
<ski> (at least, in general, those are quite distinct things. `syntax-rules' is a DSL, not an EDSL. there are hygienic macro systems which allow you to run arbitrary code)
hhdave has quit [Ping timeout: 245 seconds]
<beach> another-user: Again, you will have to believe us and try it. It is not going to be easy to give you examples that will be convincing.
<another-user> and i wonder why clos wasn't included in clojure if it's so cool(no sarcasm or irony of whatever)
<another-user> or whatever*
<another-user> beach: got it
<shka_> another-user: clos is a rather big thing
<pfdietz> Well, clojure tried to be more functional, except at the very highest level. Different design approach.
<beach> another-user: When I taught Common Lisp in New Zealand, I gave an example where having no auxiliary methods meant that an optimization required a change in the interface, which is not what you want to tell your customers before installing version 2.
<shka_> clojure took multiple dispatch and called it a day
<beach> another-user: Those very skeptical students were very impressed.
<cgay> Dylan simplified CLOS a lot, and I suppose that's what I'm actually thinking about when I say CLOS is easy to understand, not all the :before, :after, :around, MOP stuff.
<another-user> do you know what books/blogposts i should read about clos for newbies(with clojure background)
<beach> cgay: Oh, but auxiliary methods are essential (as I just mentioned).
<pfdietz> THose are CLOS, not MOP.
<jackdaniel> having auxiliarry methods is a big chunk of clos
<Fade> reading Art of the Metaobject Protocol makes CLOS quite transparent, in my experience.
<cgay> beach: that's a valid viewpoint
<it3ration> is CLOS anything more than OOP / protocol-driven-development?
<it3ration> apologies, i haven't had a chance to look at it yet
<jackdaniel> without these mixins are basically useles dispatch-wise
<beach> it3ration: Yes.
<beach> it3ration: Go read about it.
jkordani has joined #lisp
* LdBeth when I say Haskell is easy to understand, I mean Haskell 98 but not other extensions made by GHC
<it3ration> yeah yeah, working on it - spent the last year in clojure, finally making it through practical common lisp
pjb has joined #lisp
<matzy_> ok, dumb question time. when i'm writing a macro, and i have a CL standard function that i was to run while expanding the macro, how do i denote that vs one that i DONT want run during the macro (i.e. i want passed through the macro to the resulting form, to be evaluated there)
<beach> another-user: As I recall, PCL has several examples of using CLOS.
<matzy_> *that i want to run while expanding the macro
<another-user> beach: got it, thank you!
<beach> matzy_: Er, QUOTE?
anamorphic has joined #lisp
<pjb> matzy_: macros are functions.
<pfdietz> matzy_: the stuff that gets passed through will be in quoted constants (or equivalently not comma-escaped in backquote forms).
<pjb> matzy_: how do you write a function that returns an expression calling a function, without calling that function?
<matzy_> pfdietz: perfect, i was actually using a backquote too
<pjb> Well, assuming that function is not something like LIST, APPEND, CONS, etc.
<matzy_> pjb: with a quote, right?
<pfdietz> (let ((x 1)) `(list ,x)) ==> (list 1)
<matzy_> i'm just used to seeing macros with backquotes
<pjb> matzy_: more precisely, as DATA.
<matzy_> that's perfect, thanks
<pjb> matzy_: you can build this data with list operators, with backquote or by quoting a list literal.
<pfdietz> Strong suggestion: do NOT use nested backquote. They are of the devil.
<matzy_> oh yeah i could see that getting ugly
jkordani_ has quit [Ping timeout: 272 seconds]
<matzy_> do you guys normally just use quotes?
<pjb> matzy_: remember: macros are normal functions.
<anamorphic> Hmm what's wrong with nested backquotes?
<another-user> shka_: can you share a link your blogpost?
<pfdietz> I find them difficult to understand.
* ski . o O ( ",',barf" )
<pjb> matzy_: more often backquote or LIST, since othen the resulting expression must contain variable parts, coming from the parameters of the macro.
<jackdaniel> another-user: the problem is the same as with many stars in C (check out three star programmer)
orivej_ has joined #lisp
<matzy_> ah ok
<jackdaniel> (***x)(); /* -> 42 */
<pjb> matzy_: for example, let's write a function that transform an expression such as (while <condition> do <something>…) into (loop :while <condition> :do <something>…)
<jackdaniel> anamorphic: ↑↑
<jackdaniel> another-user: ignore above, sorry
<matzy_> pjb: ok, one sec
<shka_> it falls somewhat short
<another-user> shka_: thanks!
<shka_> i am not a good writer either
<anamorphic> 3 star programmer... was just reading about it :-)
travv0 has joined #lisp
orivej has quit [Read error: Connection reset by peer]
* ski . o O ( "Quasiquotation in Lisp" by Alan Bawden in 1999 at <http://people.csail.mit.edu/alan/ftp/quasiquote-v59.ps.gz> )
<matzy_> pjb: ok actually i have no idea
<pfdietz> Ah, like a 10x programmer? (defined to be a programmer who creates enough technical debt to keep 10 others busy)
<matzy_> :while and :do are named params there, right?
<pjb> (defun expand-while (form) (destructuring-bind (while <condition> do &body <something>) form (assert (eql while 'while)) (assert (eql do 'do)) (list* 'loop :while <condition> :do <something>))) (expand-while '(while (< a b) do (print a) (incf a))) #| --> (loop :while (< a b) :do (print a) (incf a)) |#
<pfdietz> LOOP is weird. Those do not have to be keywords.
<it3ration> is there some way to use reader syntax to get clojure-style [] / {} / #{} syntax for vectors, maps, and sets in CL?
<it3ration> just curious if someone has done it already
<anamorphic> I think LOOP is the lispiest thing in Lisp
<jackdaniel> pfdietz: I haven't heard that one!
<jackdaniel> (10x programmer)
<pfdietz> :)
<shka_> i know one
<shka_> he was my boss
<Bike> it3ration: Yeah. Though there's no dedicated set structure built in.
<LdBeth> it3ration: check out fset
<pjb> Now you can write the while macro as: (defmacro while (&whole form <condition> &body <body>) (expand-while form)) (macroexpand-1 '(while (< a b) do (print a) (incf a))) #| --> (loop :while (< a b) :do (print a) (incf a)) ; t |#
<another-user> beach: could you please elaborate on that optimization example?
<LdBeth> it3ration: you can get that from quicklisp
DGASAU has quit [Ping timeout: 264 seconds]
<White_Flame> matzy_: (defmacro foo (..) (macro-time `(run-time ,(macro-time))))
<pjb> matzy_: of course, you can substitute the expand-while function and "inline" it directly in the macro: (defmacro while (&whole form <condition> do &body <body>) (assert (eql do 'do)) (list* 'loop :while <condition> :do <body>)) (macroexpand-1 '(while (< a b) do (print a) (incf a))) #| --> (loop :while (< a b) :do (print a) (incf a)) ; t |#
anewuser has quit [Quit: anewuser]
<matzy_> pjb: is all of that valid? are < > used in cl or is that just shorthand?
<pjb> matzy_: if you want to use backquote, it's orthogonal to macros. You can study it independently.
<pjb> Any character can be used in symbol names.
<beach> another-user: I shall have to get back to you. Dinner time now.
<pjb> Some characters need to be escaped, but you can use any of them.
<pjb> <> don't need to be escaped, since they don't have any particular signification by default for the lisp reader.
<another-user> beach: sure, bon appetit
<LdBeth> pjb (IRC): does invisible characters included?
<pjb> LdBeth: indeed :-P
<Bike> matzy_: < is just the usual less-than predicate.
<pjb> matzy_: you could set < to a terminating reader macro and then you'd have to escape it to keep it in a symbol name.
<pjb> But unless you do that, no problem.
<pjb> (you could do that for any character, including letters and digits).
<matzy_> i see now. i'm still trying to grok all that
<pjb> matzy_: read the chapter 2. < and a are both constituent characters.
<matzy_> pjb: yeah i forgot about that. i was thinking they had some syntactical meaning in your code, which was weird because i went through chapter 2 and never saw it mentioned as valid syntax
<pjb> matzy_: people who write grammars often use <> to distinguish non-terminal symbols from terminal symbols.
<matzy_> what is a "terminal symbol"?
anamorphic has quit [Quit: anamorphic]
jkordani_ has joined #lisp
<pjb> Since the destructuring form does something similar to parsing an expression, I used that same convention to make it clearn what was to be terminal symbols, pure syntactic elements, from what was non-terminal symbols, the parameters of the expression.
warweasle has quit [Quit: later]
<pjb> matzy_: a terminal symbol is a symbol that appears itself in the sentences (the expressions) of the language.
<pjb> A non-terminal symbol doesn't appear in the sentences of the language, only in the grammar, to denote gramatical trees.
<another-user> i have to go now, thank you all for great answers! i'll try to wrap my head around clos
<pjb> So if you want, in the context of grammars, non-terminals are variables or parameters, while terminals are the literals.
<shka_> another-user: take care
<another-user> beach: i'm really interested in your example, i hope i'll find you here at some time in future and i'll ask again
<matzy_> ok, so is something like defun a terminal symbol?
jkordani has quit [Ping timeout: 276 seconds]
<pjb> matzy_: you would have to talk in the context of a grammar rule.
<matzy_> so it could be either?
vaporatorius has quit [Quit: Leaving]
vibs29 has quit [Ping timeout: 264 seconds]
<pjb> For example: function-definition ::= ( defun <name> ( <arguments> … ) <expression> … ) .
<matzy_> i was taking that to mean that built-in cl things, like defun and when and whatnot, are terminal symbols
<pjb> here, defun would be a terminal, just like ( or ).
<matzy_> ok
<pjb> <name> would be a non-terminal.
another-user has quit [Quit: WeeChat 2.3]
<matzy_> so in ::= (progn (<expression>) (<another exp>))
vibs29 has joined #lisp
<matzy_> progn is terminal and the others non, right?
<pjb> Now, since we can use destructuring-bind to decompose a sexp of that form into those elements, we could write: (destructuring-bind (defun <name> (&rest <arguments>) &body <expressions>) '(defun fact (x) (if (< x 0) 1 (* x (fact (- x 1))))) (list :name <name> :arguments <arguments> :body <expressions>)) #| --> (:name fact :arguments (x) :body ((if (< x 0) 1 (* x (fact (- x 1)))))) |#
<pjb> in the grammar rule: progn-form ::= (progn (<expression>) (<another exp>)) . Yes.
<matzy_> pjb: holy cow it just all clicked
<matzy_> i saw your example before and had no idea what it meant
<matzy_> now it all makes sense
<pjb> Good :-)
<pjb> So, defmacro does a destructuring-bind on the whole form automatically.
<matzy_> wait, i'm confused on how <name> evaluates to 'fact'
<pjb> Because destructuring-bind does it.
<matzy_> ah ok
<pjb> It matches the corresponding parameters to the corresponding subexpressions of its second argument.
<matzy_> BAM
DGASAU has joined #lisp
<matzy_> totally get it now :)
<pjb> (destructuring-bind (a b c) '(1 2 3) (list c b a)) #| --> (3 2 1) |#
<copec> I'm writing something in CL to manage ZFS Datasets across multiple platforms, so I am just invoking the ZFS CLI. Does there exist something where you provide a command and some form of a grammar to parse the return text and organize it into a type of object?
<matzy_> White_Flame: grrr i'm still trying to figure out that problem you gave me
<pjb> copec: there are parser generators.
<White_Flame> matzy_: you want the answer?
<matzy_> White_Flame: every time i try to do ,mapcar it tells me it's an unbound variable
<matzy_> White_Flame: no, i'm in too deep now!
<White_Flame> ,(mapcar ...) or ,@(mapcar ...)
jochens has quit [Remote host closed the connection]
<pjb> (mapcar (lambda (var) (+ 1 var)) '(1 2 3)) #| --> (2 3 4) |#
<matzy_> ohhh you need to put a comma before the whole expression?
jochens has joined #lisp
<pjb> matzy_: you can build your program bottom-up, by evaluating expressions in the repl.
<White_Flame> the comma "escapes" the expression after it, relative to the backquotes
<pjb> (let ((var 1)) (+ 1 var)) #| --> 2 |#
<matzy_> I was doing this: (defmacro make-vars (&rest vars) `(progn (,mapcar (lambda (x) '(defvar x)) ,@vars)))
<pjb> ((lambda (var) (+ 1 var)) 1) #| --> 2 |#
<pjb> (mapcar (lambda (var) (+ 1 var)) '(1 2 3)) #| --> (2 3 4) |#
<matzy_> i know it's not right yet but the mapcar was screwing me up. so it should be ,(mapcar ...)
<copec> Does an atypical lisper use parser generators, or does "bespoke parsing"
<White_Flame> inside a ,( ... ) body, "vars" is directly visible
<pjb> (let ((list '(1 2 3))) (mapcar (lambda (var) (+ 1 var)) list)) #| --> (2 3 4) |#
<pjb> (let ((list '(1 2 3))) `(mapcar (lambda (var) (+ 1 var)) ',list)) #| --> (mapcar (lambda (var) (+ 1 var)) '(1 2 3)) |#
<pjb> etc.
<matzy_> pjb: thank you so much
<White_Flame> copec: a lisper tends to try to use the built-in reader as much as possible
DGASAU has quit [Read error: Connection reset by peer]
<White_Flame> that woudl at least build up s-expression nesting. From there, it's a toin coss whether applying it as a function/macro or destructuring it as data is more applicable
DGASAU has joined #lisp
<matzy_> pjb: what if you wanted to evaluate mapcar in your last example
<matzy_> cause that's what i'm trying to do
<pjb> (eval (let ((list '(1 2 3))) `(mapcar (lambda (var) (+ 1 var)) ',list))) #| --> (2 3 4) |#
loli has quit [Quit: WeeChat 2.3]
<matzy_> but not evaluate the other things
eagleflo has quit [Ping timeout: 246 seconds]
<matzy_> eh nvm i just need to play around, that makes no sense im sure
<pjb> (let ((list '(1 2 3))) `(list 'the 'result 'is ,(mapcar (lambda (var) (+ 1 var)) list))) #| --> (list 'the 'result 'is (2 3 4)) |#
<matzy_> oh White_Flame already told me
<pjb> (let ((list '(1 2 3))) `(list 'the 'result 'is ',(mapcar (lambda (var) (+ 1 var)) list))) #| --> (list 'the 'result 'is '(2 3 4)) |#
<pjb> (eval (let ((list '(1 2 3))) `(list 'the 'result 'is ',(mapcar (lambda (var) (+ 1 var)) list)))) #| --> (the result is (2 3 4)) |#
jochens has quit [Ping timeout: 252 seconds]
<copec> White_Flame: How would you parse https://unaen.org/pb/35l
<matzy_> what if you wanted four copies of (lambda (var) (+ 1 var)) with the list filled into each one
<White_Flame> backquotes are basically shorthand for (list ...). So `(progn ,(mapcar ...)) is pretty much (list 'progn (mapcar ...)), so you can see that PROGN is a returned list form, and the mapcar runs in the parent (macro) context
<copec> I can take this into #clschool as that seems more appropriate
<matzy_> White_Flame: aha! i see it now
<pjb> copec: reading the manual for zfs, if it gives the format of its output.
<pjb> copec: or better, reading the specifications of zfs.
<pjb> copec: but this is assuming they define their output format as a fixed format/API.
<copec> They do
<copec> It is in the man page, even
<pjb> Then you can write down the grammar of the language describing this format.
<pjb> And use this grammar to generate automatically the parser.
<copec> You wouldn't try and do a bespoke parsing with the reader or something?
<matzy_> White_Flame: so i'm trying to use mapcar and a lambda to generate the lists of defvars
<matzy_> (defmacro make-vars (&rest vars) `(progn ,(mapcar (lambda (x) '(defvar x)) ,@vars)))
<pjb> Of course, you could also do that. It could even be more resistant to changes. But it could also break as easily as anything else upon changes in the format.
<matzy_> but slime gives me some weird input error when i try that
<matzy_> White_Flame: am i on the right path?
m00natic has quit [Remote host closed the connection]
<pjb> One advantage of writing down the grammar, is that it can easily be checked against the specification (a good specification would already have the grammar of its inputs and outputs written down, so it'd only be copy-and-paste).
<pjb> and it can easily be updated when the specifications changes.
<pjb> And since we can generate the parser automatically, it gives the minimum of work to maintain your program in sync with the tool.
<matzy_> White_Flame: i basically want everything in mapcar to be evaluated except that defvar
<White_Flame> the split-sequence library could break the individual lines into string fields
<pjb> Also, the grammar will usually be complete, including the little details for data items that occur rarely, of which you may never see examples, and thus not implement otherwise.
<White_Flame> matzy_: you want the mapcar to return lists holding sexpr forms
<White_Flame> as you're building up source code
<matzy_> right, so i thought using a lambda could build those
<pjb> (mapcar (lambda (line) (split-sequence #\space line :remove-empty-subseqs t)) (split-sequence #\newline zfs-output))
<pjb> of course.
<it3ration> hey folks, i was looking at cffi recently for CL and I was wondering how insane it'd be to write vulcan bindings
<White_Flame> matzy_: (lambda (x) `(foo ,x))
<pjb> And then you still need to parse the different fields.
<matzy_> i could map over my input list and assign it to a list containing the string "defvar" to be evaluated later
jinkies has joined #lisp
<pjb> it3ration: I don't know what vulcan is, but it would probably not be insane at all.
<matzy_> White_Flame: i think i'm in a weird scenario with the backquotes
<pjb> matzy_: if you want the string "defvar" you will get the string "defvar". But is it really what you want?
<matzy_> yes, then later it will be evaluated, right?
nitrowheels has joined #lisp
<pjb> (mapcar (lambda (x) `(list "defvar" ',x)) '((+ 2 3) 4 5)) #| --> ((list #1="defvar" '(+ 2 3)) (list #1# '4) (list #1# '5)) |#
<matzy_> i thought the results was (progn (defvar *a*) (defvar *b*) (defvar *c*))?
<pjb> There's no string "defvar" in there.
<pjb> (not directly. Indirectly, there's "DEFVAR" as name of the symbol defvar).
<matzy_> well no, but i dont want the macro to evaluate it
<matzy_> so i want the macro to just pass it through, like a string, is what i meant
<pjb> Macros are functions. They don't evaluate anything.
<White_Flame> the macro will return the list (progn (defvar ...
<matzy_> huh? isnt that the entire point of ` and , though?
<White_Flame> just as (list 'progn (list 'defvar '*a*) ...) would
n3k0_t has joined #lisp
<pjb> And anyways, you should never write defvar in the body of a macro or a function, since it won't do anything useful. defvar works at compilation time.
<shka_> vulkan bindings https://github.com/3b/cl-vulkan
<pjb> matzy_: ` and , are just shortcuts for LIST LIST* CONS APPEND.
<White_Flame> pjb: the challenge is a macro (defvars *a* *b* *c* ...)
<pjb> `(a b ,c ,@d ,e f) == (append '(a b) (list c) d (list e 'f))
<pjb> White_Flame: ok.
* White_Flame is afk
<pjb> matzy_: (macroexpand-1 '(defvars *a* *b* *c*)) #| --> (progn (defvar *a*) (defvar *b*) (defvar *c*)) ; t |#
<pjb> matzy_: so the macro defvars will take a variable number name of variables, as argument. How do you write that?
<matzy_> yes that's exactly what i'm trying to make, that progn statement
<matzy_> &rest
<pjb> Yes. (defmacro defvars (&rest variables) …)
<matzy_> here's where I'm at:
<matzy_> (defmacro make-vars (&rest vars) `(progn ,(mapcar (lambda (x) `(defvar ,x)) ,@vars)))
<pjb> So now, we have a variable named variables containing a list of variable names: (let ((variables '(*a* *b* *c*))) …)
<pjb> with that, we can have fun.
<matzy_> ok :)
<pjb> Not mad.
<pjb> Not bad.
<matzy_> but slime wont even run that :(
<pjb> matzy_: the only thick is that , will substitute the value, which is a list in this case.
<pjb> But you want to substitite each element of the list instead. We say, to splice the list.
<pjb> (let ((x '(1 2 3))) `(a ,x)) #| --> (a (1 2 3)) |#
<matzy_> oh damn, i thought mapcar would help me with that
<pjb> (let ((x '(1 2 3))) `(a ,@x)) #| --> (a 1 2 3) |#
<pjb> We use ,@ fort his.
<pjb> for this.
<pjb> mapcar is very good.
<pjb> it's the comma that's wrong.
<matzy_> ohhhh
<matzy_> why would it put in the whole list of &rest?
<matzy_> or does it just put one item in, but it's wrapped in a list
<pjb> it3ration: ah, right. Well, perhaps you'd need more than just ffi, but yes, if you have a good C library defining the vulcan API, you can start by making a low level CFFI interface to it, and then write higher level tools in lisp.
<pjb> matzy_: look careful those two lets.
<pjb> And try ,@(mapcar …) instead of ,(mapcar …)
<pjb> matzy_: , doesn't care what the expression returns; an atom or a list it's the same for it.
<pjb> matzy_: on the other hand, ,@ expects a list.
<matzy_> your examples are blowing my mind. i guess i didnt expect it to work that way
<pjb> matzy_: you may read a tutorial, or PCL, for more such examples.
<matzy_> i'm on chapter 8 of pcl
<pjb> Good.
<matzy_> was reading the "write your own maco" section last night, and was confused so I came and found you awesome people :)
xkapastel has joined #lisp
<matzy_> so @ destructures a list? can that only be used in macros?
<matzy_> oh wait no duh, you used it above
jochens has joined #lisp
<pjb> matzy_: no, @ doesn't do anything. It's ,@
<jackdaniel> fun fact is, that ,@ can't be safely used in reader macros
<pjb> And as I said above, it has nothing to do with macros. See my examples, they don't involve a macro.
<pjb> jackdaniel: why not?
<pjb> Not alone of course, , and ,@ can only be used in the context of `.
<matzy_> so now i have: (defmacro make-vars (&rest vars) `(progn ,(mapcar (lambda (x) `(defvar ,@x)) ,@vars)))
<pjb> name it defvar.
<matzy_> but slime is giving me an error: "comma not inside a backquote"
<matzy_> but all my commas are in backquotes...?
<jackdaniel> pjb: I remember only the conclusion, sorry :( I've discussed this problem here a year ago or something
<matzy_> pjb: instead of defmacro?
<pjb> matzy_: We would expect make-vars to be a function, not a macro. So to work only at run-time. While defvars would be expected to work at compilation-time.
<pjb> (defmacro defvars (&rest vars) `(progn ,(mapcar (lambda (x) `(defvar ,@x)) ,@vars)))
<matzy_> whoa why is that?
<pjb> Also, if you use abbreviations, don't use -. If you use -, use in-extenso names: define-variables or defvars.
<pjb> Simply conventions.
<matzy_> so - can't be in macro names?
<jackdaniel> and since I don't remember the actual problem let's treat it as a hearesay
<pjb> matzy_: yes, it can be, but on long names.
<pjb> like define-variables
<matzy_> oh ok
<matzy_> why the slime error though?
<matzy_> i cant see anything else wrong
<pjb> something starting with def or define-, or with- or do or do- we would expect that to be macros.
jochens has quit [Ping timeout: 240 seconds]
<matzy_> ah ok
<pjb> matzy_: it's the ,@vars
<pjb> it's meaningless.
<pjb> matzy_: you need to count the backquotes and increment when you see one, and count the comma or comma-at and decrement when you see one. The variable references should be at the same level as their definition.
<matzy_> but i want them to be evaluated before being passed to lambda
<matzy_> ohhh
<jackdaniel> or maybe it was that #1=(foo . #1#) can't be used in a macro, because compiler may try to expand it? anyway, nvm that
<matzy_> i have ,(mapcar ... ,@vars)
<pjb> So in: (defmacro defvars (&rest vars 0 ) `( 1 progn , 0 (mapcar 0 (lambda (x) 0 `( 1 defvar ,@ 0 x) 0) ,@ -1!!! vars)))
<pjb> I wrote ,@(mapcar …) not ,(mapcar … ,@…)
anamorphic has joined #lisp
<pjb> This makes you look very tired ;-)
rozenglass has joined #lisp
<matzy_> yeah i was so close and now i'm lost again. wouldn't doing @,(mapcar ...) do the expansion and substitution on everything inside that statement?
<matzy_> or rather ,@(mapcar ...)
<pjb> matzy_: (let ((vars '(*a* *b* *c*))) (mapcar (lambda (x) `(defvar ,x)) vars)) #| --> ((defvar *a*) (defvar *b*) (defvar *c*)) |#
<pjb> right?
<pjb> So the mapcar returns a list of defvar forms.
<matzy_> ok wait one sec, need to grok
<pjb> We want to splice them in the progn: (let ((vars '(*a* *b* *c*))) `(progn ,@(mapcar (lambda (x) `(defvar ,x)) vars))) #| --> (progn (defvar *a*) (defvar *b*) (defvar *c*)) |#
<pjb> matzy_: notice how I just write those expressions at the REPL to try them out immediately.
<matzy_> i see, forget about the macro and just try and build the sexps
<pjb> Then I can replace the let and bindings by defmacro and lamba-list: (defmacro defvars (&rest vars) `(progn ,@(mapcar (lambda (x) `(defvar ,x)) vars)))
<pjb> the defmacro or defun comes at the end, when all the rest works.
<pjb> And you can copy-and paste the literals and results to write the tests: (assert (equal (macroexpand-1 '(defvars *a* *b* *c*)) '(progn (defvar *a*) (defvar *b*) (defvar *c*)))) #| --> nil |#
<pjb> This is TDD! :-)
<matzy_> pjb: your macro doesnt work for me in slime
<pjb> And why not?
<matzy_> i get an error when i try to load it
<pjb> What error?
<matzy_> or sorry, expand it
<matzy_> i'm trying: (macroexpand-1 '(make-vars x y z))
<matzy_> is that right to test it?
<pjb> defvars, not make-vars.
<matzy_> shit
<pjb> make-vars would be a function.
<matzy_> i just forgot to change it when i changed the name as you suggested
<matzy_> wow
<matzy_> that was....awesome
<pjb> (defun make-vars (vars) (dolist (var vars) (proclaim `(special ,var))))
<pjb> It would be rather useless.
<matzy_> so the only thing i dont get is the ,@ before the WHOLE mapcar statement
<matzy_> I get I need ,@vars
<pjb> Again, it's a function. So you can refactorize it.
<matzy_> and ,@x in the defvar
<jackdaniel> matzy_: mapcar returns a list and ,@ unsplices this list
<matzy_> oh i see
<jackdaniel> so try (mapcar #'1+ '(1 2 3)) ; that will return (2 3 4)
<pjb> (defmacro defvars (&rest vars) (let ((defvars (mapcar (lambda (x) `(defvar ,x)) vars))) `(progn ,@defvars)))
<jackdaniel> so ,@(mapcar …) is the same as ,@(2 3 4)
<jackdaniel> wrong, the same as ,@'(2 3 4)
<jackdaniel> to prevent evaluation
<pjb> only ,@' doesn't work :-)
<jackdaniel> ,@(quote 2 3 4) ?
<pjb> Oh, it works in the REPL, but not with C-x C-e.
<matzy_> so will it evaluate and splice the result and any thing inside of it that is not escaped?
<matzy_> because ,(....) affects everything in the list
pierpal has quit [Read error: Connection reset by peer]
<matzy_> let me make an example real quick to show where i'm confused
vibs29 has quit [Ping timeout: 245 seconds]
<pjb> matzy_: actually, I would argue that to understand, you would have to use the functions before using backquote.
<pjb> (defmacro defvars (&rest vars) (let ((defvars (mapcar (lambda (x) `(defvar ,x)) vars))) (cons 'progn defvars)))
vibs29 has joined #lisp
<pjb> (macroexpand-1 '(defvars *a* *b* *c*)) #| --> (progn (defvar *a*) (defvar *b*) (defvar *c*)) ; t |#
<pjb> compare with (defmacro defvars (&rest vars) (let ((defvars (mapcar (lambda (x) `(defvar ,x)) vars))) (list 'progn defvars)))
<pjb> (macroexpand-1 '(defvars *a* *b* *c*)) #| --> (progn ((defvar *a*) (defvar *b*) (defvar *c*))) ; t |#
<matzy_> basically if i have (let ((x 2) (y 3)) (+ x y)) in a macro, i would get (+ X Y) as my result, right?
<pjb> Nope.
<pjb> You would get 5.
<matzy_> but if i do (let ((x 2) (y 3)) ,(+ x y)) - it evaluates everything inside the parens
<pjb> matzy_: you cannot write , outside of `.
<matzy_> yeah nvm i messed that up
<pjb> matzy_: write a complete example, with `.
<pjb> And it's unrelated to macros.
<matzy_> ah ok
<matzy_> one sec
loli has joined #lisp
<matzy_> ok, if i do: (let ((x 2) (y 3)) `(+ x y))
<matzy_> the backquote effects each item in the parens
<matzy_> right? it individually applies to each one and prevents evaluation
<matzy_> `(+ x y) === ('+ 'x 'y) right?
<matzy_> i'm confused on why @,(thing1 thing2 thing3) does try to splice each item
<pjb> (list '+ 'x 'y)
<pjb> or '(+ x y)
<matzy_> shouldn't it try and splice things like lambda in our macro example pjb ?
<pjb> matzy_: the exact rules are listed on http://www.lispworks.com/documentation/HyperSpec/Body/02_df.htm
<pjb> There's no comma, so nothing occurs.
<pjb> Read this section 2.4.6, it's the clearest.
<matzy_> huh?
<pjb> matzy_: the exact rules are listed on http://www.lispworks.com/documentation/HyperSpec/Body/02_df.htm
<matzy_> ok, i think i get it. ,@ works on the next form, which for me, is the entire mapcar form
<matzy_> so does mapcar finish before ,@ is applied? or whats the order in a macro like this?
nitrowheels has quit [Quit: Leaving]
<matzy_> i kept thinking it acts on each item in that form individually
<pjb> matzy_: indeed, the evaluation of mapcar finishes before its result is used by ,@
<pjb> read again this example: (defmacro defvars (&rest vars) (let ((defvars (mapcar (lambda (x) `(defvar ,x)) vars))) (cons 'progn defvars)))
<pjb> or this example: (defmacro defvars (&rest vars) (let ((defvars (mapcar (lambda (x) `(defvar ,x)) vars))) `(progn ,@defvars)))
<pjb> as I said above, it's just a function, you can refactorize it.
<matzy_> ok, one sec, i'm gonna paste that in emacs and put in line breaks so i can read it
<pjb> Indeed.
<matzy_> ok wow that is much easier to understand than the way i tried
<matzy_> i'm a bit surprised (cons 'progn defvars) works like that but i kinda get it
<pjb> By the way, is there any blind (or vision impaired) lisper? There's this hackernews question: https://news.ycombinator.com/item?id=18414562 ; I've commented suggesting lisp, but I'm not blind, so what do I know?
<pjb> matzy_: a useful function for this kind of expressions is LIST* It's like CONS, but with several elements before the rest: (list* 1 2 3 '(4 5 6)) #| --> (1 2 3 4 5 6) |#
<pjb> Of course, it can also be used with a single element: (list* 1 '(2 3)) #| --> (1 2 3) |# (cons 1 '(2 3)) #| --> (1 2 3) |#
<matzy_> oh ok so it merges the lists together
<pjb> Nope.
<pjb> It prefixes several elements in front of a list.
<pjb> cons prefixes one.
<matzy_> puts non-list items in a list, sorry
<matzy_> but wouldn't that statement only run once in your code?
<pjb> To merge lists, use MERGE: (merge 'list '(1 3 5) '(2 4 6) (function <)) #| --> (1 2 3 4 5 6) |#
<matzy_> how is it putting progn in as many lists as &rest params?
<pjb> matzy_: you're overspecifying. I didn't say non-list!
<matzy_> whoops! :)
<pjb> (list* '(a b c) '(d e f) 3 4 '(5 6 7)) #| --> ((a b c) (d e f) 3 4 5 6 7) |#
<pjb> There are no statements in lisp. This is 30% of its power.
<pjb> There are no lists, it's 10% of its power.
<matzy_> wait, why doesnt (5 6 7) stay in its list? (a b c) and (d e f) do
<pjb> There are no parenthesis, it's another 10% of its power.
<pjb> Because (5 6 7) is the last argument to LIST*.
loli has quit [Quit: WeeChat 2.3]
<pjb> LIST* processes differently its last argument.
<pjb> APPEND too.
<pjb> APPLY too.
<matzy_> oh ok, i can read up on that myself
<pjb> append doesn't copy the last argument. apply does like list*: (apply 'list 1 2 3 '(4 5 6)) #| --> (1 2 3 4 5 6) |#
<pjb> matzy_: type /msg specbot clhs apply
jkordani has joined #lisp
<pjb> clhs apply
<pjb> and follow the links.
<matzy_> so your cons gets (cons progn (*a*) (*b*) (*c*)) at the end of macro execution, right?
<matzy_> assuming we used those args?
<pjb> Nope.
<matzy_> dammit lol
<matzy_> (cons 'progn (*a* *b* *c*))?
<matzy_> *progn
<pjb> With '(*a* …)
<pjb> *a* is not a function.
<jackdaniel> if anyone wonders what's going on with McCLIM, here are pixel-perfect bounding rectangles for a multiline text: http://i.imgur.com/1Ki3Uid.png :-)
<matzy_> oh right
<pjb> you can use PRINT to see: (defmacro defvars (&rest vars) (let ((defvars (mapcar (lambda (x) `(defvar ,x)) vars))) (cons 'progn (print defvars))))
<pjb> (macroexpand-1 '(defvars *a* *b* *c*)) #| ((defvar *a*) (defvar *b*) (defvar *c*)) --> (progn (defvar *a*) (defvar *b*) (defvar *c*)) ; t |#
<matzy_> oh wow cool
<pjb> print returns it's argument, so you can use to see the value of subexpressions.
<pjb> But not if the subexpression returns multiple-values that are used!
<pjb> (multiple-value-call #'+ (truncate 10 3)) #| --> 4 |# (multiple-value-call #'+ (print (truncate 10 3))) #| 3 --> 3 |#
anamorphic has quit [Quit: anamorphic]
<matzy_> is #' the same as ' but for functions?
jkordani_ has quit [Ping timeout: 260 seconds]
anamorphic has joined #lisp
<jackdaniel> 'foo is (quote foo), #'foo is (function foo)
<jackdaniel> quote prevents evaluation, function checks function associated with a symbol
<jackdaniel> so these are different things
<jackdaniel> s/checks/return/
<matzy_> jackdaniel: ok thanks. i was always wondering about that in elisp..
warweasle has joined #lisp
<pjb> Well, the function operator is the operator that creates closure, so it's the most important operator of lisp, I'd say :-) lambda is a macro that expands to (function (lambda …)).
<LdBeth> in Emacs Lisp #' is works the same as '
it3ration is now known as wusticality
<LdBeth> which introduces confusion
<pjb> LdBeth: not exact, since 25. emacs lisp now has closures too.
dddddd has quit [Ping timeout: 246 seconds]
<LdBeth> pjb (IRC): even in (setq lexical-binding t), what (function foo) is still return 'foo
<pjb> #+emacs (setf lexical-binding t) #+emacs (let ((x 42)) #'(lambda () x)) -> (closure ((x . 42) t) nil x)
<pjb>
wusticality is now known as it3ration
it3ration is now known as wusticality
<matzy_> LdBeth: godammit
<matzy_> lol
<pjb> #+emacs (let ((x 42)) (cl-flet ((foo (y) (+ x y))) #'foo)) --> (closure ((x . 42) t) (y) (+ x y))
<pjb> of course, you are right for old emacsen and the legacy mode, so it makes emacs lisp rather complicated…
<LdBeth> and you can even do (funcall '(closure ((x . 42) t) nil x))
<pjb> Yes :-)
meepdeew has joined #lisp
<wusticality> it3ration -> wusticality just fyi
<wusticality> pjb: i spose the tricky thing in general is memory management, I need to look into how that works with cffi
<pjb> wusticality: it's indeed a big problem to solve with any foreign library.
loli has joined #lisp
<matzy_> pjb: ok i've been playing around with the solution you helped me come to in slime. so does @, mean in english"evaluate everything in the body AND splice the resulting list"?
<matzy_> because it acts like ,(...) which i take to mean "evaluate everything in parens"
<matzy_> i took out the @ and saw the only difference is our result is wrapped in one extra list
<anamorphic> LIST* has been quite handy when adding a new property to a plist: (list* :foo 123 '(:bar 456)) => (:FOO 123 :BAR 456)
ggole has quit [Quit: ggole]
<White_Flame> matzy_: `(literal-term ,outer-term ,@outer-term) a term can be a symbol or a sexpr
<White_Flame> (let ((a 1) (b '(2 3))) `(,a ,@b c)) => (1 2 3 c)
<White_Flame> erm, ...(,a ,@(cons 1.5 b) c) => (1 1.5 2 3 c)
<White_Flame> , or ,@ versus symbol or (sexpr) are orthogonal
dddddd has joined #lisp
shifty has quit [Ping timeout: 272 seconds]
wusticality has quit [Remote host closed the connection]
<matzy_> White_Flame: thank you! i see now
<pjb> matzy_: in lisp, orthogonality is very high.
<pjb> matzy_: it means that you can combine almost everything with everything in any order.
<matzy_> so if you have `(one two ,@(three four) five) -- three and four are the only things that are evaluated in that statement, right?
<matzy_> basically the ,@ cancels eval for everything in its sexp?
<matzy_> sorry, evaluates
<pjb> matzy_: this comes from the fact that there's no statement, only expressions and that expressions are lists, with a uniform format: the operator in the first position, the arguments in the rest).
<pjb> No, the only thing that is evaluated, is the expression: (three four)
wusticality has joined #lisp
<pjb> three should be the name of an operator, and four is an argument.
<matzy_> oh shit, ok
<matzy_> this is where i'm confused, you just hit it
<matzy_> so the expression itself is evaluated, but that doesn't mean things in that expression will also be evaluated?
wusticality has quit [Remote host closed the connection]
<whartung> ???
<pjb> matzy_: how the subexpressions are evaluated depends on the operator.
<pjb> If it's a special operator, it depends on the special rule of the special operator.
<matzy_> (assuming a is in scope and equals 1): `(+ ,@(+ 3 a)) -- will a be 1 or a?
<pjb> If it's a macro, it depends on the macro and its expansion.
wusticality has joined #lisp
<pjb> If it's a function, then yes, the arguments are evaluated, and the results are bound to the parameters of the function that is called.
Jesin has joined #lisp
<pjb> ask your repl!
<matzy_> so for a function, the ,@ will force evaluation on everything in the sexp
<matzy_> oh yeah!
<pjb> (let ((a 1)) `(+ ,@(+ 3 a))) #| --> (+ . 4) |#
<matzy_> sorry shoulda done that first
<pjb> Note: this is not a form. program-error
<pjb> (if you try to evaluate it)
<pjb> (eval (let ((a 1)) `(+ ,@(+ 3 a)))) #| ERROR: The value 4 is not of the expected type list. |#
<matzy_> i am shocked by that result
<pjb> You cannot have dotted lists or circular lists in forms (programs). Only in data, as quoted literals.
<pjb> (eval (let ((a 1)) `(+ ,(+ 3 a)))) #| --> 4 |#
<pjb> (let ((a 1)) `(+ ,(+ 3 a))) #| --> (+ 4) |#
<matzy_> why did i get a cons cell with (+ . 4)?
<pjb> Because of ,@
<matzy_> ohhhh!
<pjb> and because (+ 3 a) returned 4, not a list, but an atom.
<matzy_> ok, so @, worked as i thought
<pjb> Since it was the last item in the `(+ ,@(+ 3 a)) list, it worked.
<matzy_> it evaluates the a before evaluating the whole form
<pjb> but (let ((a 1)) `(+ ,@(+ 3 a) 4 5)) #| ERROR: The value 4 is not of the expected type list. |#
rpg has joined #lisp
<pjb> matzy_: it doesn't matter. You can just use variables: (let ((x 4)) `(+ ,@x)) #| --> (+ . 4) |#
<pjb> (let ((x '(4))) `(+ ,@x)) #| --> (+ 4) |#
<matzy_> ok, but when i'm writing a macro, and it's backquoted, and i use a ,@ before my sexp, do i still need to force things in that sexp to eval or will ,@ take care of it? That's my entire question
<matzy_> I just dont know if I'm even phrasing it, or explaining my thought, correctly
<pjb> You don't need to force anything.
<pjb> Just remember that normally, you should give a LIST to ,@.
<matzy_> ok
<pjb> orthogonality means independence.
<pjb> it means it doesn't matter that you're writing a macro.
<pjb> With (let ((x '(4))) `(+ ,@x)) there's no difference if it's in a macro or not.
<pjb> it doesn't matter.
<pjb> forget about macros!
<pjb> The question is that you want to build a list. What kind of list do you want? What form should it have?
<pjb> If you want a list of the form (+ <x> <y>) with <x> and <y> replaced by some expressions that you will compute and produce, then you can do it with LIST:
<pjb> (let ((<x> '(* 3 x)) (<y> '(+ 2 y))) (list '+ <x> <y>)) #| --> (+ (* 3 x) (+ 2 y)) |#
<pjb> or you can do it with backquote:
<pjb> (let ((<x> '(* 3 x)) (<y> '(+ 2 y))) `(+ ,<x> ,<y>)) #| --> (+ (* 3 x) (+ 2 y)) |#
<pjb> backquote which is a reader macro reads as an expression equivalent to my (list '+ <x> <y>):
<pjb> (quote `(+ ,<x> ,<y>)) #| --> (list* '+ (list* <x> (list <y>))) |#
<pjb> the exact expression depends on the implementation.
<pjb> But it doesn't matter, it will do just the same.
<LdBeth> well, i'm kinda envy scheme's syntax system
<pjb> Now, if you say the list you want must be of the form (+ <args>…)
<pjb> then you can write (let ((<args> '(1 2 3))) (list* '+ <args>)) #| --> (+ 1 2 3) |#
<pjb> or you can write (let ((<args> '(1 2 3))) `(+ ,@<args>)) #| --> (+ 1 2 3) |#
<pjb> So you can say that ,@ replaces the …
<pjb> while , is a mere substitution.
<matzy_> ok
<pjb> matzy_: finally, you would use ` if you can write a model of the form of the list you want. And you would use list, list*, cons, append, etc if you are building a more abstract data structure.
<pjb> But even considering that, often it will be clearer to use the list operators, possibly wrapping them in functional abstractions.
<matzy_> so back to our solution real quick: (defmacro defvars1 (&rest vars) `(progn ,@(mapcar (lambda (x) `(defvar ,x)) vars))) -- why is lambda not just treated as a symbol, like we do for progn?
<matzy_> because the , in ,@ affects the whole sexp?
<matzy_> why is lambda evaluated without a ,
<pjb> For example, you could write: (defun toplevel-expressions (expressions) (list* 'progn expressions)) (defun make-defvar (var) (list 'defvar var)) (toplevel-expressions (mapcar #'make-defvar '(*a* *b* *c*))) #| --> (progn (defvar *a*) (defvar *b*) (defvar *c*)) |#
<pjb> instead of using ` ,@(mapcar …).
<pjb> (defmacro defvars (&rest vars) (toplevel-expressions (mapcar #'make-defvar vars))) ; is way clearer!
<matzy_> yeah it really is!
<matzy_> but that was my question i've been wondering about - why is lambda evaluated in that backquoted sexp?
<matzy_> because of the ,@ before (mapcar)?
<pjb> The only detail is that you need to have the functions toplevel-expressions and make-defvar defined in the compilation environment, since they're used at macroexpansion time. So if you define them in the same file as a the macro, you need to put them in an (eval-when (:compile-toplevel :load-toplevel :execute) (defun …) …) form.
<pjb> matzy_: yes. , and ,@ will evaluate the expressions and use their result.
<matzy_> got it! i didnt know if ,@ was one symbol that acted on the whole sexp or if , applied to each thing in the sexp and @ affects the resulting list?
<matzy_> (sorry no need for the ?)
<pjb> Well, technically it's not a symbol, it's pure syntax, parsed and interpreted by the ` reader macro, but yes. , and ,@ are two different things.
cage_ has quit [Remote host closed the connection]
warweasle has quit [Quit: rcirc on GNU Emacs 24.4.1]
<matzy_> right, but ,@ still performs the role of , just also acts on the resulting list
<pjb> `(let ((x '(1 2 3))) `(a ,@ x b)) #| --> (a 1 2 3 b) |# `(let ((@ '(1 2 3))) `(a , @ b)) #| --> (a (1 2 3) b) |# ;-)
<matzy_> am i correct? does what i'm asking make sense?
<pjb> , also acts on the result of the expression: it inserts it in the resulting list.
<matzy_> if i need to escape backquotes will @, do that and splice or does it just splice? seems to be the former
<matzy_> ohh ok
<pjb> Escape backquotes? what do you mean?
<matzy_> it's like in my macro, if i didnt have @, there at all the lambda wouldn't be evaluated, right?
<matzy_> sorry ,@
<pjb> Well, yes, the expression wouldn't be evaluated.
<matzy_> if i just use , it evaluates everything in the sexp. if i use ,@ it evaluates everything in the sexp, splices the resulting list, and inserts it back into the resulting list
<pjb> `(progn (mapcar (lambda (x) `(defvar ,x)) vars)) #| --> (progn (mapcar (lambda (x) (list* 'defvar (list x))) vars)) |#
<matzy_> is that correct?
<pjb> matzy_: yes, just like ,@
<pjb> both , and ,@ read an expression and evaluate it.
<matzy_> yes!!!!!! ok i get it now
<pjb> Well, more precisely, ` builds an expression where those expressions will be evaluated.
<matzy_> i was confused on whether ,@ just did the splicing
<matzy_> and not evaluating
<pjb> The evaluation is performed not at read-time, but at run-time.
<pjb> matzy_: for reader macros, you can quote them to see what is read.
<matzy_> the same as just using , right?
<pjb> matzy_: (quote `(foo ,x ,@xs bar)) #| --> (list* 'foo (list* x (append xs '(bar)))) |#
<matzy_> that happens at run-time as well?
<matzy_> oh god
<pjb> So you can see that x and xs are not evaluated. But they're inserted in the resulting expressions in such a way that if you evaluate this resulting expression, they will be evaluated.
<matzy_> ahhh i see
<pjb> (let ((x 42) (xs '( 4 2))) (list* 'foo (list* x (append xs '(bar)))) ) #| --> (foo 42 4 2 bar) |#
<pjb> matzy_: indeed, we have to be careful and distinguish read-time, compiltion-time, macroexpansion-time, and run-time and sometimes several instances of them embedded.
anamorphic has quit [Quit: anamorphic]
<pjb> So if you don't evaluate the backquoted expression, then the subexpressions are not evaluated.
<pjb> Note that you can force the read-time evaluation of an expression using #.
<pjb> (quote (1 (+ 1 2) #.(+ 1 2) 2)) #| --> (1 (+ 1 2) 3 2) |#
<matzy_> whoa i didnt know about that
<pjb> `(1 (+ 1 2) ,(+ 1 2) #.(+ 1 2) 2) #| --> (1 (+ 1 2) 3 3 2) |#
<pjb> But: (quote `(1 (+ 1 2) ,(+ 1 2) #.(+ 1 2) 2)) #| --> (list* 1 (list* '(+ 1 2) (list* (+ 1 2) '(3 2)))) |#
wusticality has quit [Remote host closed the connection]
wusticality has joined #lisp
<pjb> ,(+ 1 2) implies that (+ 1 2) will be evaluated at run-time, while #.(+ 1 2) evaluates (+ 1 2) at read time; it's like if we read 3.
<pjb> matzy_: notice you can prevent the expressions read by #. to be evaluated by setting *read-eval* to nil.
<matzy_> in slime you mean?
<pjb> (setf *read-eval* nil) (quote (#.(+ 1 2) 3)) --> Reader error on #<string-input-stream #x30200236649D>, near position 33, within "(quote (#.(+ 1 2) 3)": #. reader macro invoked when *read-eval* is false .
<pjb> matzy_: in the REPL or elsewhere.
<pjb> But be careful with C-x C-e, since this evaluates the expressions in a separate REPL, those variables must be set globally in the slime-repl, before they can be taken into account in the threads used by C-x C-e.
<matzy_> ah ok. i didnt even know C-x C-e worked for cl, i just use C-c C-l
<pjb> alternatively, you can set swank::*swank-bindings* and also swank:*default-worker-thread-bindings* SWANK:*MACROEXPAND-PRINTER-BINDINGS* SWANK::*INSPECTOR-VERBOSE-PRINTER-BINDINGS* SWANK::*INSPECTOR-PRINTER-BINDINGS* swank::*backtrace-printer-bindings*
<pjb> matzy_: if you type C-u C-x C-e, it inserts the result in the buffer.
<pjb> (+ 1 2) C-u C-x C-e inserts: 3
emaczen has quit [Ping timeout: 260 seconds]
Lycurgus has quit [Quit: Exeunt]
wusticality has quit [Remote host closed the connection]
<pjb> So you can use it to generate some code or some data when you program. In effect, this adds an edit-time to the various lisp times :-)
<matzy_> so it doesnt display in the minibuff like elisp? huh
<matzy_> cool! just tried it
travv0 has quit [Ping timeout: 252 seconds]
wusticality has joined #lisp
<no-defun-allowed> Good morning everyone!
confusedwanderer has quit [Remote host closed the connection]
<pjb> matzy_: yes, C-x C-e displays the result in the minibuffer. C-u C-x C-e inserts it in the buffer.
esper0s has joined #lisp
<pjb> matzy_: C-u is a prefix modifier to emacs commands. A lot of commands can perform variants with it.
<pjb> matzy_: sometimes, you can use numerical prefixes, eg. C-u 3 x inserts xxx
<matzy_> oh wow i never knew about that.
<matzy_> but i use evil, so i feel like there are a lot of keybindings i'm missing out on that dont get ported
<pjb> matzy_: of course, you can shorten C-u 3 it as C-3 in GUI: C-3 y inserts yyy
<pjb> Perhaps, I don't use evil at all.
<pjb> Last time I used vi was in 1991.
groovy2shoes has quit [Quit: moritura te salutat]
<matzy_> i dunno how you gave up modal editing for jamming ctrl all the time
asarch has joined #lisp
<matzy_> i've tried, i can't do it. i know i miss out on a lot though
nly has quit [Ping timeout: 240 seconds]
wusticality has quit [Remote host closed the connection]
wusticality has joined #lisp
vlatkoB has quit [Remote host closed the connection]
<no-defun-allowed> Emacs requires you to fit less state in your head.
<matzy_> but do you ever really think about which vim state you're in? do you think you're in "highlighting mode" when you drag your mouse across text while holding down left click?
<matzy_> it's just natural, when you want to type you go in insert and leave immediately after. i've never had to really think about it, since my first week probably (been awhile now)
<matzy_> plus i dont see how people live without text objects - ci(, da', vi{......i use those more than any other command
<matzy_> emacs doesnt have an equivalent, right?
<Xach> with practice you can get used to anything
<Xach> and you can also get to enjoy anything after a while.
<esper0s> true
<Xach> i don't think many things are really natural.
<matzy_> i agree, but something that's semantic (like vim's text-objs and motions) comes pretty damn close (if you speak english)
<matzy_> ct{ - change to {
<matzy_> that's hard to top
<esper0s> i do agree that vi had it pretty well down when it comes to semantically differentiating between text
<esper0s> however emacs gives you the ability to do just the same
Bike has quit []
wusticality has quit [Ping timeout: 268 seconds]
<matzy_> esper0s: does it? i'm curious, i never got beyond the motion keys in the tutorial because i found them so ridiculous
<matzy_> i know that's semantic, but for moving, just feels dumb :D
<matzy_> they're so far apart
<esper0s> you just create your own elisp functinos :D
<matzy_> heh, i already have a mess of functions to make things work how i want in evil
<matzy_> one step ahead!
esper0s has quit [Ping timeout: 245 seconds]
esper0s has joined #lisp
<fiddlerwoaroof> matzy_: I use a weird mix of vim and emacs keybindings now, things like C-M-k for (delete a sexp) are particularly useful.
<esper0s> yes i use sexp movement quite often
<fiddlerwoaroof> C-M-u is particularly useful too
<esper0s> have you guys heard of the book "Structure and interpretation of Computer programs" written by MIT and using lisp
<esper0s> ?
<fiddlerwoaroof> Yeah
<esper0s> i havent strated it yet, is it any good?
<on_ion> i've started it. heard very great things about it -- close to one of the best books on such topic
<on_ion> it even has a meme
<aeth> Humans were essentially the same as humans today in behavior and anatomy 40k to 30k years ago. Human civilization started roughly 10k years ago and slowly developed since then. The difference between us and the humans before us is better tools. Tools matter. That's why the editor war absolutely matters. I suspect both vim and GNU Emacs are way better than the competition as far as productivity goes, though.
<jcowan> on_ion: Probably have better luck discussing SICP in #scheme
mooshmoosh has quit [Quit: Quit]
<esper0s> hahah the memes
<on_ion> jcowan: is that intended for esper0s ? i was responding to his approach to the channel. he doesn't know this place is *only* Common Lisp - which i already do, too
<jcowan> sorry, yes, brain fart
<on_ion> aeth: you may have better luck discussing editor wars in #emacs of #vim. =P
<on_ion> or*
<aeth> on_ion: Except this is about editing Lisp, not editing.
<on_ion> i made a temporary stack-allocated meme there thats all i really meant =)
jochens has joined #lisp
<matzy_> yeah got a bit off topic, i was originally just curious about the cool CL keybindings i'm missing out on in emacs
<pjb> matzy_: use C-h m and don't miss any cool keybinding!
<pjb> (Try C-h m in different modes!)
aindilis has joined #lisp
<matzy_> pjb: that actually doesnt help with evil - that shows the replaced bindings (i.e. evil)
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<matzy_> like C-u is company-previous-page (c-u and c-d in vim scroll pages up and down)
<pjb> I'd guess you can type :q! to exit evil
<matzy_> lol
<matzy_> i can turn it off and check though, so valid point
jochens has quit [Ping timeout: 240 seconds]
jef` has joined #lisp
<flip214> esper0s: on_ion: SICP is really great. It talks about Scheme, but if you manage to rewrite the example on-the-go to Common Lisp, you've got quite an experience before you!
<flip214> As a starting point I'd recommend PCL, too.
<flip214> minion: tell esper0s about PCL
<minion> esper0s: please see PCL: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
<flip214> matzy_: as a vim user, perhaps you feel more at home with the slimv or vlime plugins for vim8 resp. neovim.
<flip214> just saying.
angavrilov has quit [Remote host closed the connection]
<matzy_> I really like PCL cause it's the first book i've read that assumes you actually know how to program
<matzy_> versus taking pages upon pages to explain basic things every programmer already knows
<matzy_> flip214: there's no going back to me sadly :) just this mixed-up world i now live in
<matzy_> *for me
<matzy_> as much as i miss vim keybindings (which i do get), i would miss all the crazy crap i've done with emacs even more
<on_ion> the first part of SICP is programming intro. the rest is profound mind trip
<flip214> matzy_: ack. np (for me ;)
<on_ion> theres a reason that programmers from all languages value that book very highly
jef` has quit [Quit: Lost terminal]
<matzy_> on_ion: yeah i probably just didnt go far enough, the beginning was too basic and slow for me. then i found PCL, and i'm letting it slowly rape my brain
<no-defun-allowed> Per number of anime edits, SICP is more popular than many, many programming languages.
void_pointer has joined #lisp
<aeth> That just means it appeals to a certain crowd, though.
<no-defun-allowed> That's the figure I usually use just to show that SICP is a very popular book regardless of who is reading it.
<no-defun-allowed> (Don't port it to JavaScript pls, I saw someone did that and it was sad.)
Bicyclidine is now known as bike
<flip214> on_ion: regarding "mind trip" I can also recommend "Gödel, Escher, Bach". And for non-technical literature (but still a mind-trip ;) I value "The Illuminatus! Trilogy" (Robert Shea, Robert Anton Wilson)
<on_ion> i see quora etc questions "why is the book so good" and recently read an article (from HN i believe) praising its otherworldly affect or effect
<no-defun-allowed> (if you read it long enough, it was trying to tell you to put it down. No one should put a programming text through that kind of torture.)
<on_ion> no-defun-allowed: sicpdistilled.org ? =)
<no-defun-allowed> I don't remember which one
<on_ion> flip214: oh yeah!! thats actually the one singular book i really really want to read. some day i will find it
<on_ion> flip214: also ty=) will check out illuminatus as well
<no-defun-allowed> Clojure! Kill it!
<on_ion> aeth: read 'The Craft of Text Editing' ? =)
<on_ion> no-defun-allowed =P
<on_ion> i think its pronounced like foyer
<no-defun-allowed> I think I should add a callback thing to cl-decentralise, so I don't fry anyone's minds with the normal event loop.
rumbler31 has joined #lisp
<on_ion> call/cc
rumbler31 has quit [Remote host closed the connection]
<aeth> on_ion: A callback is not really call/cc, just a higher order function afaik. (Not even technically that since you can do it with non-first-class functions, too.)
<aeth> What call/cc gets you afaik is easy timeouts. But I haven't looked into that.
<no-defun-allowed> So I have a list or structure with all the new callbacks after they get registered in some kind of setup macro, then I just pop em off while I get new data.
jinkies has quit [Ping timeout: 246 seconds]
<no-defun-allowed> Maybe I'll make it capable of lparallel if I want to get fancy and use multiple threads. Node people would lose it though.
shka_ has quit [Ping timeout: 252 seconds]
<aeth> no-defun-allowed: Instead of going through fresh functions, I have my functions that are passed in take a certain data structure that represents its state and keep the function constant.
<aeth> no-defun-allowed: i.e. I pass in an init function, that init function returns a state and a function that's called every iteration with that state (and some other things if needed)
<no-defun-allowed> Right.
<aeth> And I have no clue what that state is, or that function is, the init function handles it
anamorphic has joined #lisp
<aeth> (I even have an optional (could be NIL) call-at-the-end function to close connections)
<no-defun-allowed> It's not awfully efficient (or safe, I haven't drop tested it), but so far my only method of programming cl-d programs is using an event "loop" handler which is a little awkward when state gets involved. https://gitlab.com/netfarm.gq/cl-decentralise/blob/master/eventloop.lisp
<aeth> As far as style goes I'd use with-gensyms and once-only from alexandria, so (with-gensyms (line block-data) (once-only (connection) `(loop ...)))
<aeth> in event-loop
<no-defun-allowed> I'd rather have an `on` macro which takes similar arguments to one of the cases in the event-loop and a lambda.
<no-defun-allowed> Yes, I've loosened up and used Alexandria in Netfarm so I might as well use it in cl-d now :)
<aeth> event-loop should probably either be called define-event-loop and create a function or it should be called with-event-loop imo
<anamorphic> I'm using CHECK-TYPE and DECLARE TYPE at the top of my function and it's seems kind of redundant. Thoughts?
<aeth> A name like event-loop sounds functiony and you can't really tell macros and functions apart without naming conventions
<aeth> anamorphic: check-type and declare are redundant. Some implementations ignore declare, and SBCL ignores check-type if a declare is present since it already does the check
<no-defun-allowed> I'll probably remove the "loop" part so with-event-handlers is likely to be the new name.
<aeth> anamorphic: Use declare if you want performance alone, use check-type if you want to be able to correct the type at runtime (but it will be slower in at least SBCL), and mix the two depending on the implementation (with a macro, obviously) if you want the optimal solution for a given implementation even if the type error isn't always correctable at runtime like check-type gives you.
<anamorphic> Oh interesting. Thanks for replying so detailedly
<aeth> anamorphic: I wrote a macro DEFINE-FUNCTION to be a syntactic unification of CHECK-TYPE and DECLARE without using both at the same time. https://gitlab.com/zombie-raptor/zombie-raptor/blob/ab11fe386c84f4d9ac963370275eea2e3f872902/util/util.lisp#L140-240
<anamorphic> Cool! I am checking it out
<aeth> In particular, I intend to make the default option eventually depend on the implementation so e.g. SBCL will default to DECLARE and CLISP will default to CHECK-TYPE
wusticality has joined #lisp
<anamorphic> aeth: that sounds like something univerally useful like for alexandria
<aeth> It's probably too controversial for something like alexandria.
<aeth> I do intend to spin it off into a util library eventually, though.
makomo has joined #lisp
<aeth> The main competition is defstar afaik, but I *think* my approach is better.
<aeth> I don't have anything for bindings yet because I intend to have a unified binding eventually (i.e. handling all of LET, LET*, MULTIPLE-VALUE-BIND, FLET, LABELS, MACROLET, etc. and maybe even WITH-ACCESSORS and SYMBOL-MACROLET)
<anamorphic> Awesome. Maybe serapeum then perhaps. Don't leave home without (:use #:cl #:alexandria #:separeum)
<anamorphic> What's a few more symbols when you start with >900
<anamorphic> I had not considered let and bindings...
<anamorphic> Even with just at a defun level it's hugely helpful I think
wusticality has quit [Ping timeout: 246 seconds]
<anamorphic> aeth: where did you see defun*? Turns out, it's not very googleable
<aeth> My motivation for the LET rework is I want to be able to do (let (((values x y) (floor 42.5d0))) ...) like you can use VALUES in SETF
<aeth> And once I add values might as well add type, function, macro...
<anamorphic> Oh n/m found it
warweasle has joined #lisp
<aeth> anamorphic: It's GPLv3 though
<aeth> So you (probably) can't use it.
<aeth> That's also why I'm not entirely sure how my macros compare to it. I'm intentionally not reading how it works since my work is MIT licensed.
esper0s has quit [Remote host closed the connection]
<no-defun-allowed> I'll read it for you if you do want to do that.
<anamorphic> Yeah might be a big hangup for some. I'm just an enthusiastic amature/noob though so it doesn't matter to me personally
<no-defun-allowed> I believe if I'm vague enough, it's legally cleanroom reverse engineering at worst.
<aeth> anamorphic: GPL library means you can only use it in GPL libraries and GPL programs.
<anamorphic> Oh I see
<aeth> no-defun-allowed: Thanks but define-function is already feature-complete
* no-defun-allowed uses CSL just to troll GNU weenies.
<aeth> no-defun-allowed: I just added return value support
<aeth> s/return value/typed return value/
<aeth> It's quite amusing in check-type mode. It will still work, it just m-v-b's your entire program and then check-types those values and then returns those values
<no-defun-allowed> No but actually I use it since I don't want people selling my programs. That'd be rude.
scymtym has quit [Ping timeout: 252 seconds]
<anamorphic> I'm using Lisp for realestate analysis and GIS stuff
<aeth> s/your entire program/your entire function body/
<anamorphic> What's CSL, no-defun-allowed ?
Roy_Fokker has joined #lisp
permagreen has quit [Remote host closed the connection]
<no-defun-allowed> The Cooperative Software License. It's pretty much the AGPLv3, but it has restrictions on who can sell the software, and its grandparent is the CC BY-NC-SA license.
<aeth> so sort of like what MongoDB did, then
permagreen has joined #lisp
<no-defun-allowed> Maybe. I don't know.
<aeth> modified AGPLv3, except it's anti-cloud in particular, not all businesses
<no-defun-allowed> I see.
<no-defun-allowed> (if you're a workers coop you're let off though.)
<anamorphic> aeth: Wish you the best with define-function. Seems incredibly useful - an easy way to get both safety and type hints to the compiler
asarch_ has joined #lisp
Zaab1t has quit [Quit: bye bye friends]
asarch has quit [Ping timeout: 240 seconds]
<aeth> I wonder if it's possible to modify CLOS so you can provide classes for optional and keyword arguments in a method. Then I could have (almost) unified syntax (define-method would use classes, define-function uses types, and there's a difference because types allow things like (integer 0 *)).
asarch_ is now known as asarch
<aeth> Technically, types in &rest could be handled by default-type (which would have to be renamed for unified define-function/define-method syntax)
varjag has quit [Quit: ERC (IRC client for Emacs 26.1)]
<cgay> Is there room for the provided-p option in those lambda lists?
<aeth> What would that do?
<bike> as in, if you write (&optional (x integer)), does that mean integer is a variable with whether x was provided, or a type
<aeth> bike: I require a default value in optional and keyword arguments, even if the default value is NIL and thus will always error in (x nil integer)
jkordani has quit [Read error: Connection reset by peer]
<aeth> sorry, I require a default value if the type is provided
<aeth> It's the destructuring-bind (binding &optional default type)
<aeth> cgay: I guess I could optionally make default interpreted as type if type is NIL as an option
<aeth> that just requires modifying the name-and-options destructuring-bind of (name &key inline optimize debug default-type check-type return) to add a new flag
warweasle has quit [Quit: back later, maybe]
scymtym has joined #lisp
<cgay> I was just curious. I'm a fan with or without that option.
mutenewt has joined #lisp
makomo has quit [Read error: Connection reset by peer]
<aeth> It's not as easy as I thought because I would really want to combine the parsing of the typed lambda list (which means LOOP instead of MAPCAR) if I want to configure the parsing like that
nicksmaddog has quit [Quit: Leaving]
LiamH has quit [Quit: Leaving.]
<aeth> failed AVER: (not (sb-c::ctran-next sb-c::ctran))
<aeth> This is probably a bug in SBCL itself. (Alternatively, SBCL might have been corrupted by bad user code, e.g. by an undefined Lisp operation like (fmakunbound 'compile), or by stray pointers from alien code or from unsafe Lisp code; or there might be a bug in the OS or hardware that SBCL is running on.) If it seems to be a bug in SBCL itself, the maintainers would like to know about it. Bug reports are welcome on the SBCL mailing lists, whic
<aeth> Well, then. I guess when I mess up redefining define-function things go very wrong.
debsan has joined #lisp
<aeth> cgay: I think the most intuitive way of handling the problem is having a type-first? option that provides the alternate syntax (binding &optional type default)
asarch has quit [Ping timeout: 240 seconds]
asarch has joined #lisp
Roy_Fokker has quit [Read error: Connection reset by peer]
anamorphic has quit [Quit: anamorphic]
<no-defun-allowed> could you get in trouble for intentionally sending someone a zip bomb automatically?
<aeth> Is there a way to get an arbitrary-length typed cons? e.g. (typep (list 1 2 3) '(cons fixnum (cons fixnum (cons fixnum)))) => T
<aeth> but it's only that particular length
anamorphic has joined #lisp
<aeth> What I'd really want is something like the (obviously invalid) type: `(list ,default-type) for the &rest
rumbler31 has joined #lisp
<cgay> aeth, not sure if we're talking about the same thing, but for the supplied-p issue couldn't you just allow &optional (a 1 integer a-supplied-p)?
random-nick has quit [Read error: Connection reset by peer]
<aeth> cgay: oh I see what you're saying
<aeth> cgay: That's already in there, I just use an invalid type as the default value
<aeth> (a nil integer)
<aeth> s/invalid type/member of an invalid type/
<aeth> NIL will work unless it's T, SYMBOL, BOOLEAN, or LIST. For the last 3 you can just use some other type or another default value.
<cgay> oh i see. i didn't make the connection that that can be used to do the same thing.
mutenewt has quit [Quit: Leaving]
<cgay> wait, it doesn't completely, right? you might want a valid default and a way to figure out if the arg was supplied.
<cgay> meh, it's an edge case
<aeth> I'm not sure how that could be done. I think that's too high-level for define-function
<aeth> There are some edge cases I know I don't handle, like trying to use :inline when you're not in a top-level-form (e.g. within a LET or DEFUN instead of PROGN or actually top-level). I inline and ftype with declaim.
sjl_ has quit [Quit: WeeChat 2.3-dev]
blackwolf has quit [Quit: ERC (IRC client for Emacs 25.3.1)]
<aeth> cgay: It seems doable in check-type mode, but with declare mode there's no way (afaik) to tell the difference between the user using the reasonable default as default or the user providing that same reasonable default manually because a fake default value (easiest way to implement this) can't be used without changing the actual type in the declaration. It would also make the default value unviewable in SLIME's API minibuffer thing.
anamorphic has quit [Quit: anamorphic]
<aeth> At least the way I think it could be done is turning any type into (or null type) and then if (null foo) provide the actual default and make a note that that is done
<aeth> (Not quite that easy because the type would also have to be parsed to make sure that it is not including SYMBOL, BOOLEAN, LIST, or NULL already)
<no-defun-allowed> should test wpscan against magrathea first before doing any fun stuff today
<no-defun-allowed> still damn CLOS is really easy to work with how haven't all the c++ plebs heard of it
<no-defun-allowed> >[i] Updating the database...
<no-defun-allowed> you piece of shit wpscan
<no-defun-allowed> and it expects wordpress to actually be ther which makes sense
Mr-Potter has joined #lisp
<no-defun-allowed> doesn't kill nikito at all, the hell?
fsmunoz has joined #lisp
<no-defun-allowed> great so nikito doesn't use compression at all
anewuser has joined #lisp
wusticality has joined #lisp
fikka has joined #lisp
wusticality has quit [Ping timeout: 244 seconds]