freenode/#lisp - IRC Chatlog
Search
17:32:10
__oliverSwift
hey, y'all. I had a thought about the syntax of common lisp. With scheme, function declarations look like (define (foo param)) which is consistent with how a function is called, but in CL it's (defun foo (param)) which made me wonder about how the defun function actually works. Is there some documentation somewhere that explains that? or can i look at it? I feel like that would help me understand macros
17:39:13
makomo
it sets the "function cell" of the symbol that was given as the name of the function
17:39:53
makomo
the function cell is set to a function object generated by that lambda expression (which wraps the body specified within the DEFUN)
17:42:46
__oliverSwift
Thank you guys, this is really helpful. I have to admit I'm a little confused with the terminology, but this is a good starting place.
17:42:47
Bike
scheme's (define (foo ...) body...) is actually just sugar for (define foo (lambda (...) body...))
17:44:28
koenig
I really learned something because I've read SICP and understand the Scheme syntactic sugar for define, so dlowe's expression makes sense too.
17:44:44
__oliverSwift
Well, I thought the scheme syntax was doing something to interpret the (foo …) as a list of symbols. I just wondered how they were breaking the syntax to make it work.
17:45:23
makomo
there's one thing i wonder myself. is it true that just because an operator is a standard function or macro, it doesn't mean that the operator is implementable by the user?
17:46:28
Bike
__oliverSwift: it is. in scheme, "define" is a special operator (i believe), not a function, and the implementation will pull the symbols apart.
17:47:32
Bike
seems trivial, but also works for the sequence and list functions, which you basically just need control structures and car/cdr/aref for
17:48:00
makomo
right. what bugs me a little is the fact that some operators which are not special "kinda are" special
17:50:13
dlowe
makomo: what makes them different is evaluation of their arguments. Functions always evaluate their arguments from left to right at runtime. Macros don't evaluate their arguments at all and run during compile time. Special forms don't do either of these.
17:50:22
makomo
hm, so if you were to start just with the special operators (and related primitives like function objects), you could implement the rest of the system (although inefficiently)?
17:51:05
makomo
so the fact that vector, list, etc. all have their special status within an implementation is just a side thing, needed for performance reasons
17:51:39
Bike
i mean they don't need to have a special status. in beach's SICL project, lists and vectors aren't special
17:52:33
makomo
right, because he's implement CL in CL itself, so his lists are just the host's lists
17:53:10
Bike
it doesn't just use the host for everything except when building the system from source.
17:54:01
makomo
so are lists, etc. represented just like other "general instances" or what the name was
17:55:44
anamorphic
How does one tell if a pathname is a directory or file? is it (null (pathname-name pathname))?
0:10:55
gaze___
I'd be more keen to adopt it for scientific stuff if I could get a gui and some plotting functionality... is that something you've worked on?
0:13:28
gaze___
I should probably bite the bullet and just try and get qtools/commonqt working but the fact that it only builds with older Qt bugs me a little.
0:14:50
stylewarning
gaze___: We use SBCL and have been experimenting with ECL for some things. Perhaps disappointingly, we haven’t tried building a GUI for anything with Lisp, let alone done any plotting. Most folks just grab for Python/matplotlib and don’t attempt any scientific visualization with Lisp.
0:17:04
gaze___
well... the way we run our experiments (I'm also with a QC group) is we have a script that has a DSL for generating microcode for our feedback controller, and right next to it a function that processes and visualizes the data coming off the feedback controller
0:17:44
gaze___
and this has been really useful. It's nice to jump from script to script to tune or to figure out how many averages you need or go "oops I set the frequency wrong let's change that and go again"
0:19:10
gaze___
so you might have one for calibrating your separatrix for state estimation which churns the data and plots a histogram, colored by prep state, and then another that just runs a t2 experiment and knows it should fit a decaying sine-modulated exponential
0:20:07
stylewarning
gaze___: which QC group? For something like that, if it can be simple, I might try McCLIM.
0:20:32
stylewarning
If it has to be “industrial strength”, maybe use LispWorks. (But improving the OSS ecosystem is definitely desirable.)
0:22:49
stylewarning
gaze___: yeah reasonable. You should see what you can manage with McCLIM. I’d love to hear that, esp. if it’s used in the world of QC.
0:23:34
gaze___
I'm nearly done with my PhD so I likely won't be starting something new... but I'm always interested in software in science
0:35:19
gaze___
https://github.com/heeres/objectsharer Oh there's also this which we use for instrument control
3:24:28
aeth
I know how to make Common Lisp more popular... https://gitlab.com/mbabich/lisp-hello-world/blob/c45deaab9918285d3de43c52340100fef6591d15/main.lisp
3:28:05
aeth
And yes I'm calling this the worst hello world for Common Lisp even though my previous one was (#4f(+++++++++[>++++++++<-]>.<+++[>++++++++<-]>+++++.+++++++..+++.>++++[>++++++++<-]>.<<<+++[>--------<-]>.<+++[>++++++++<-]>.+++.------.--------.>>+.<++++++++++.))
3:34:31
beach
Bike: In SICL, CONS cells are not represented the same way as other objects. They are a special case.
3:38:45
koenig
I am not deeply knowledgeable in Common Lisp, so it is always interesting to me to see code like that. I learn a lot.
3:40:42
koenig
My Common Lisp learning for today was finding out that defun is not in fact a special form.
3:42:10
beach
Typically expands to something like (setf (fdefinition <name>) (lambda (<parameters>) <body>))
3:43:11
koenig
Indeed, I was also educated about that. Connecting it to the syntactic sugar of how to implement Scheme's function define was helpful.
3:44:03
koenig
The peculiar thing to me is, I know a fairly good amount of computer science. But Lisp is something that I keep unraveling more and more and more.
3:45:15
White_Flame
but the handling of code & data interchangeably also has a lot of overlap with compiler technology and transforms
3:45:59
koenig
I've also written some simple CL macros. But I have to think mindfully about it when I do.
3:48:08
koenig
Well you all are very encouraging! Thanks for that. I'm headed to sleep now and will learn more Lisp magic tomorrow. :)
4:37:15
pjb
Yes, when you write macros, you have to mind two states at once: the state of the macro itself (macroexpansion time), and the state of the expansion (run-time). At least. Some macros have 3 or 4 levels!