freenode/lisp - IRC Chatlog
Search
23:18:25
aeth
fiddlerwoaroof: Last time I wrote infix I didn't support mixing. So (infix (x + y - z)) was invalid. You'd have to do (infix ((x + y) - z))
23:18:50
pjb
In practice, you'd just write the code to compute your spaceship position and propulsion in pure lisp anyways.
23:19:18
pjb
For example, if you implemented a GPS system, you could take the formula from the specifications and use an infix model to avoid having to translate them yourself.
23:23:09
fiddlerwoaroof
precedence is just confusion, especially once you expand beyond standard mathematical notation
23:25:06
fiddlerwoaroof
And, I'd argue that order of operations is a misfeature in mathematical notation that's been around long enough that we don't care
23:26:08
aeth
In math, you can tell from context if the writer made a precedence mistake. Computers aren't that good (and have less context available)
23:36:08
makomo
not sure if anyone's familiar with it, but you basically have tricks like "A = |0><0| defines an operator" so that when you apply it to some state |phi> you get A |phi> = |0><0||phi> = |0><0|phi> which is really just |0> <0|phi> where <0|phi> is the scalar product"
23:41:20
jcowan
I like the Kotlin/Ada attitude: overload operators, fine; invent your own, not fine.
23:54:43
didi
Can I write a destructuring lambda list that takes only the N first elements? For example (that doesn't work), (destructuring-bind (a) '(1 2) a), and I'm only interested in the variable `a'.
0:02:09
fiddlerwoaroof
The biggest pain-point of my objective-c FFI is that everything crashes when I accidentally send the wrong selector to an objective-c object
0:40:59
elderK
makomo: I was dream-working on the backquote stuff. :) I have been walking through this, testing it in the REPL at different points: https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node367.html
0:41:58
makomo
although, this is just the appendix. the actual section of the book goes into more detail
0:42:20
elderK
I've basically been trying to figure out which parts of his code, applies which rules.
0:42:47
elderK
I've also been feeding his code some stuff, but also "doing the backquote thing" by hand, following the rules. Then comparing his output against my own.
0:45:25
makomo
are you referring to the fact that he just takes the CADR of the thing (ignoring any other values)?
0:46:10
elderK
In the do-loop, he verifies that the form is (unquote something) rather than (unquote something something something)
0:48:05
elderK
Off topic, my eyes are really starting to frustrate me. Most of the time, I don't really... the deficit so much. But right now, I am. I have a vertical split - one side, code. The other side, REPL.
0:48:42
elderK
And my monitor is wide enough that I can't really see each split at the same time. So, when I look at the REPL, I can't see the code.
0:48:51
elderK
And my right eye, the one that works, is shit enough that when I see the code, the REPL is blurry.
0:52:46
makomo
elderK: hah yeah, it really does ignore the CDDR in the above case, while checking it in the case below, interesting
0:53:36
makomo
however, you would only ever hit the error if you intentionally went and malformed the input to backquote. using the reader macros $, %, %@, etc. you're sure that the invariants will hold and no error will occur
0:55:23
makomo
tbh i never actually took a close look at his implementation of backquote, but i've been meaning to do it for some time
0:57:12
makomo
a thing that would be fun to make is a backquote expander but for humands -- it would produce a step-by-step expansion of the backquote, telling you which rule it applied at every step :-)
0:58:50
elderK
makomo: Yeah, that's what I'm thinking. Like, I want to make something, to continue "applying / practicing" CL. But I also want to nail these rules. So, maybe writing an "expander" isn't a bad exercise. :)
0:59:36
elderK
I mean, it would just end up being my own spin of what he made. I'd write it from scratch, doing it based on the rules. But in the end, it'll just be what he's done. Still, I think there's something to be said for doing it yourself, your way, to really... nail something.
0:59:49
makomo
elderK: yet another interesting thing is the "Meta Unquote Protocol (MUP)" which fare talks about in his fare-quasiquote. take a look if you're interested
1:00:36
elderK
I want to get to the point where I can at least /read/ and understand nested backquotery. Like, once-only.
1:01:46
elderK
Aye. But I also want to learn about tree walking and stuff, too. So, this seems like a two-for-one kinda deal :D
1:01:50
makomo
the problem with that particular implementation of once-only is that it's hard to follow the different tiers of evaluation, even when you know what the backquote conceptually does
1:02:58
elderK
Aye :) I'd like to verify my... "conceptual solution" to the once only problem. Just to make sure I'm on the right path. I couldn't implement it, because I couldn't figure out the BQ nesting. But, I'm pretty sure I know exactly what needs to be done.
1:03:39
makomo
in practice, you'll only ever see double backquotes. anything above that is overkill or is for pedagogical purposes only :-)
1:05:30
elderK
In a nutshell, we need to create some "names for the evaluated things." This is the first level. So, we "bind" the result of evaluating whatever forms we were passed. The next step, is creating names for those bindings. You can't just say (,symbol ,gensymed) because the "symbol" may not be a symbol - it may be a value or an expression - so you have to gensym to create placeholder names, so that you can have (gensymed-name-for-symbol
1:05:30
elderK
gensymed-storage-for-the-value). Then finally, you need to make it so that "symbol" means "gensymed-name-for-symbol" wherever ,symbol appears in the body of the thing we're wrapping. If that makes sense :P
1:06:38
elderK
I.e. Cache the results of evaluating the thing. Then create a binding of NAME -> CACHED. Then have some way of having ORIGINAL_NAME -> NAME
1:11:10
makomo
elderK: not quite. the first tier of gensyms is so that ONCE-ONLY is hygienic, i.e. so that the macro using ONCE-ONLY doesn't end up unintentionally capturing some symbols. the stuff that's bound (within the user macro) to these tier-1-gensyms are tier-2-gensyms (generated within the user macro, every time the macro is called)
1:12:55
makomo
the tier-2-gensyms are the ones used in the expansion of the user macro. finally, the provided variables are rebound to the value of the tier-1-gensym (i.e. the tier-2-gensym used for that particular variable) within the user macro (so that when you use it somewhere, you're actually using the tier-2-gensym instead of the original expression)
1:14:08
makomo
once the user macro is defined, the tier-1-gensyms are set in stone and done -- they're generated once (assuming compilation), when your macro is defined and when ONCE-ONLY is expanded
1:14:50
makomo
this is so that nested usage of the user macro doesn't accidentally end up doing variable capture/shadowing
1:18:11
makomo
#:ONCE-ONLY848 is a tier-1-gensym, and you can see how it's "set in stone" ("hardcoded") within the definition of HI
1:18:31
elderK
One thing I'd like to have, and I had trouble with, was gettin ga feel for what stuff was going on.
1:18:49
elderK
But, that didn't really give me a complete feel for what the macro was doing - just the "expansion"
1:19:11
makomo
the user macro HI generates the tier-2-gensym #:X852 and makes that the new value of the user macro argument X, so that you can transparently refer to it
1:19:25
makomo
you can see that the tier-1-gensyms never appear in the expansion, only the tier-2-gensyms do
1:20:38
makomo
the expansion of ONCE-ONLY might be a bit hard to read... until you learn the backquotes rules! :-)
1:20:55
elderK
makomo: When you were figuring out once-only, did you do it all yourself, or did you like, study other implementations and figure it out that way?
1:21:00
makomo
note that in this case, there are no nested backquotes within the expansion (it might look like it though)
1:21:19
makomo
elderK: it was mentioned in ONCE-ONLY which gave me a vague idea, and from that point i studied it myself
1:21:59
makomo
the thing that's mysterious is the 2nd argument that can appear for every symbol in ONCE-ONLY
1:22:08
elderK
I found PCLs explanation of once-only's intent clear. But it's explanation of backquote, etc, nonexistent.
1:22:44
elderK
Yeah :) I think I'll write a little "backquote expander." I'm not sure if that's the right name for it.
1:24:05
makomo
except that ONCE-ONLY can't know that "a-sym", etc. are safe names to use, so it has to use gensyms (tier-1-gensyms)
1:26:13
makomo
but once you understand the rules, you can see how the upper backquote and the lower backquote are "at the same level" and are conceptually "merged"
1:27:06
makomo
(provided that <form> doesn't start with @, in which case you have comma-at instead of comma (this is the caveat mentioned in the CLHS btw!))
1:28:18
elderK
The ,@ just says "Yeah, patch it into the output, directly." Which is what ,<form> would do in this case.
1:28:48
elderK
Where as ,@,@something would say "patch ,@something into the output", then ,@something would be expanded at the next .... level?
1:29:46
makomo
,@,@something would (after 1 evaluation) produce ,@<value-of-something-1> ... ,@<value-of-something-n>
1:30:04
makomo
these elements of the list given by something now have to be forms that will be evaluated as part of the 2nd evaluation!
1:30:59
elderK
THis is where I get a bit confused with terminology. The left-most , applies to the innermost backquote.
1:31:20
makomo
i won't spoil the fun of figuring out what the 2nd argument in a ONCE-ONLY spec does :-)
1:31:39
makomo
usually you do (once-only (a b c) ...), but that's just a shorthand for (once-only ((a a) (b b) (c c)) ...)
1:32:09
elderK
If I write ,@,@something as (unquote-splice (unquote-splice something)), it's clear that the right-most ,@ is evaluated first
1:33:08
makomo
yeah, it's important to be consistent. whenever you use (outer/inner)most, you're referring to the backquote/comma pair
1:33:27
makomo
so the outermost backquote is the leftmost one, but the outermost comma is the rightmost one
1:33:54
elderK
That's what gets me, you see. If I had ``,@,@s I'd expect the left-most ,@ to be done first, because "innermost BQ is expanded first."
1:34:43
elderK
So, ``,@,@s "expands innermost first" into `(backquote (unquote-splice (unquote-splice s))
1:34:46
makomo
yeah, that's exactly what expansion does -- reads it in into an actual form ("longhand")
1:35:38
elderK
So then, a macro, it "expands." And that makes sense, because it's generating a "longer form", which is later eavluated.
1:36:16
makomo
indeed, although the two expansions happen at different levels. the backquote expansion happens at read-time, while macroexpansion happens at compile-time (macroexpansion-time)
1:37:30
elderK
Ah, I see. For some reason, I thought macro-expansion happened at... I guess, read time. I didn't realize read was split from compile
1:38:29
makomo
yup. many other languages don't have the concept of a "reader" -- their compilers operate directly on the textual input (internally it is "read" into an AST, but the user doesn't see this difference)
1:38:59
NoNumber
Is there a way to see all the objects a symbol points to? For example, I have "x" as a global variable but I also have it inside a closure which has x as a different value, AND I have x as a function. This may be useless but I'm curious. Sorry if this is a dumb question
1:39:43
makomo
by the time EVAL/COMPILE are called, you're literally giving them lists (as the reader already read the text into actual in-memory objects)
1:42:52
makomo
NoNumber: if you're using SLIME, you can use slime-describe-symbol to see the various bindings (in the global environment) that have that symbol as their name
1:43:30
makomo
for example, after (defvar hi) and (defmacro hi ...), slime-describe-symbol gives me "HI names a special variable: ... HI names a macro: ..."
1:45:45
NoNumber
makomo: Thanks, this might be useful in aiding my understanding of closures and bindings, and whatnot
1:46:24
equwal
elderk: About your screen. If you are on emacs there is a package for rotating the windows with a hotkey, which you can use to make them vertical instead (assuming you are viewing the ctl1 from within emacs with w3m or something, which is how I would do it).
5:23:05
elderK
Abstract Algebra. I got a lot out of it. More philosophical than I thought it would be.
6:26:06
graftin
Is it better to get packages from Quicklisp or Guix? If I get a package from Guix, I can include it in my config.scm, but IDK how often they're updated compared to Quicklisp.
9:36:08
svillemot
I get an internal server error when trying to submit an issue on gitlab.common-lisp.net ; is there a maintenance going on?
9:36:40
mfiano
Is there any workaround to be able to use DESTRUCTURING-BIND to destructure the car/cdr of a possibly NIL value? (destructuring-bind (foo . bar) value) fails on nil
9:41:02
mfiano
It's been a while since I used CL. I almost forgot destructuring lambda lists were almost identical to macro lambda lists. Thanks!