ebrasca has quit [Remote host closed the connection]
<jcowan>
beach: There is no reason not to use the S-genitive with non-proper nouns, as long as the whole phrase is not too complicated. "My daughter's clothes" is just as good as "Alice's clothes", and likewise "my company's advanced AI software" and "the present King of Denmark's hat." In short, english is not German.
euandreh has quit [Ping timeout: 252 seconds]
<jcowan>
(Shinmera's case *is* too complex to be idiomatic, though)
euandreh has joined #commonlisp
taiju has quit [Ping timeout: 252 seconds]
random-nick has quit [Ping timeout: 245 seconds]
dec0d3r has quit [Remote host closed the connection]
char has quit [Remote host closed the connection]
char has joined #commonlisp
Spawns_Carpeting has quit [Quit: WeeChat 3.1]
Spawns_Carpeting has joined #commonlisp
akoana has joined #commonlisp
hendursaga has quit [Ping timeout: 276 seconds]
<drmeister>
Let's say I have an accessor where I can evaluate: (imgui%:|DeltaTime| io) and the setf form: (setf (imgui%:|DeltaTime| io) 1.0)
<drmeister>
I want to define an accessor imgui:delta-time where I can go:
<drmeister>
(imgui:delta-time io) and the setf form: (setf (imgui:delta-time io) 1.0)
<drmeister>
I'd like these accessors to be macros so that they get converted at compile time to the |DeltaTime| accessor.
<mfiano>
So, what is the question / where are you stuck?
<drmeister>
Should I be using define-setf-expander? I've always struggled with that macro.
<mfiano>
What is wrong with #'(setf fdefinition) ?
hendursaga has joined #commonlisp
<hayley>
IIRC (defmacro imgui:delta-time (io) `(imgui%:|DeltaTime| ,io)) would work as a SETF place too.
<drmeister>
Yeah - sure - that works.
<drmeister>
You mean: (setf (fdefinition 'delta-time) #'imgui%:|DeltaTime|)
<jeosol>
Guest6112: what are you trying to achieve. Your entry function appears to be empty, just a call to (loop ...) and does nothing else
<Guest6112>
I intentionally removed a bunch of code there. I thought this was a problem with SBCL or my .asd definition. I've done some more digging and it turns out this segfault is actually happening because of sqlite, I'm trying to figure that out now
<beach>
Guest6112: Why are you trying to build an executable this early in the development process.
<beach>
?
<beach>
It is much easier to debug things if you work interactively.
<Guest6112>
Oh I've done a ton of development on the REPL. I omitted a _ton_ of code from that example because I thought this was an SBCL or ASDF problem. Its actually something else.
<beach>
But that something else must have manifested itself during the interactive development work, no?
<beach>
Or are you saying that it happens only in the executable that you build, but not when you work at the REPL?
lottaquestions has quit [Ping timeout: 252 seconds]
<Guest6112>
It only happens in the executable. I just figured it out -- I was using a defparameter at the top of the file (evidently a really bad idea) to connect to my sqlite database. I believe the defparameter happened, then went out of memory, then a query tried to refer to it.
semz has joined #commonlisp
hendursaga has quit [Ping timeout: 276 seconds]
hendursaga has joined #commonlisp
Qwnavery has quit [Quit: WeeChat 3.3]
hendursaga has quit [Ping timeout: 276 seconds]
hendursaga has joined #commonlisp
jealousmonk has quit [Remote host closed the connection]
donovanquixote has joined #commonlisp
ulfvonbe` has joined #commonlisp
notzmv has quit [Ping timeout: 252 seconds]
Spawns_Carpeting has quit [Ping timeout: 265 seconds]
igemnace has quit [Remote host closed the connection]
akoana has quit [Ping timeout: 260 seconds]
akoana has joined #commonlisp
pranavats has left #commonlisp [Disconnected: Replaced by new connection]
pranavats has joined #commonlisp
Nilby has joined #commonlisp
zacque has joined #commonlisp
taiju has quit [Ping timeout: 265 seconds]
taiju has joined #commonlisp
gaqwas has joined #commonlisp
shka has joined #commonlisp
GreaseMonkey has quit [Remote host closed the connection]
gaqwas has quit [Ping timeout: 252 seconds]
lad has joined #commonlisp
rgherdt__ has joined #commonlisp
notzmv has joined #commonlisp
rain3 has joined #commonlisp
taiju has quit [Ping timeout: 260 seconds]
akoana has left #commonlisp [#commonlisp]
<lucerne>
Can someone give me an example of using symbol-macrolet and then setf on these symbols? BTW, did I understand correctly that symbol-macrolet fails if it tries to bind a symbol that is already a special variable? Wouldn’t that mean that any function that uses symbol-macrolet can potentially fail, depending on the global environment of where it is
<lucerne>
used?
Lycurgus has joined #commonlisp
<beach>
Special variables should have *earmuffs* and symbols bound by SYMBOL-MACROLET should not.
<Shinmera>
symbol macros are macros and thus only exist at compile time, too.
<Shinmera>
or rather, their usage only exists at compile time
<beach>
Right, so the error is caught at compile time.
<beach>
lucerne: (let ((a (make-array 2))) (symbol-macrolet ((b (aref a 0))) (list b (setf b 10) b)))
taiju has joined #commonlisp
Skyfire has quit [Quit: brb]
Skyfire has joined #commonlisp
iamFIREc1 has quit [Ping timeout: 260 seconds]
hendursa1 has joined #commonlisp
<beach>
lucerne: Did you faint?
hendursaga has quit [Ping timeout: 276 seconds]
<hayley>
I think you are supposed to ask the most common cases first, but I haven't taught Common Lisp to many people. Maybe fainting is more common than I expect.
<lucerne>
beach: Are all code in a package guaranteed to be compiled? No JIT compiling for example? I guess the only exception would be using eval? So if I use symbol-macro-let with eval, it would depend on the global env of the caller?
<beach>
lucerne: No, code is not guaranteed to be compiled, but if you use COMPILE-FILE or COMPILE, at least minimal compilation has been performed.
<Lycurgus>
the JIT concept doesn't really make sense in lisp
amb007 has quit [Ping timeout: 260 seconds]
<Lycurgus>
since normally the compiler is always available
amb007 has joined #commonlisp
<beach>
lucerne: I take it you are looking for a case where you define a function that uses SYMBOL-MACROLET and then later you define a special variable with that name?
<Lycurgus>
compiled on the fly vs loading fasls
<lucerne>
Hmm. Won’t the conflict not happen anyway as symbols of different packages have differing namespaces?
<beach>
I suppose the function could fail then if it were interpreted.
<hayley>
You still need a compiler to JIT. Though having tiered compilation can be handy if you want to compile a lot of code quickly.
<Lycurgus>
but they don't that's what pkgs are
<beach>
lucerne: Sure, if the two symbols are not the same, then there is obviously no conflict.
<lucerne>
Btw, is a lisp image executable portable between OSes?
Lycurgus has left #commonlisp [Deus Ex]
<beach>
lucerne: Two symbols are the same if they have the same name and the same package.
<hayley>
Usually no.
<beach>
lucerne: By the way, there is not really any "code in a package" in Common Lisp.
<amk>
Howdy, does anyone know of a reasonably complete CL graphql library?
<lucerne>
Lycurgus: Isn’t an always available compiler what people call JITs?
<lucerne>
What I’m wondering is if CL compiles specialized versions of each functions for each tuple of input argument types. (This trick is used to great effect in Julia.)
<beach>
lucerne: No, for it to be JIT, it must recompile at run time.
<beach>
lucerne: The language has no opinion about that. Can you give an example of what you mean?
<hayley>
It's possible to write a macro to do "type splitting", which achieves nearly the same effect (though the type is dispatched wholly at runtime with current implementations, whereas dispatch can be done at compile-time in Julia).
<hayley>
e.g. (defmacro split-on ((variable type) &body body) `(if (typep ,variable ',type) (progn ,@body) (progn ,@body))) and then (split-on (x fixnum) (+ x 2))
<beach>
lucerne: It would be uncommon for any Common Lisp implementation to compile a new version of a function when a new call to it is defined. But this technique: http://metamodular.com/SICL/call-site-optimization.pdf is meant to make similar optimizations possible.
<beach>
lucerne: I don't know Julia, but what is their type system like? I mean, if it has to compile a new function for each call site, inlining will work quite well.
<beach>
lucerne: Furthermore, it seems silly to make different versions of a function that does not depend on the "type" of its argument(s).
<hayley>
Doing type splitting (as I described) can be used to effectively hoist the dispatch on how to AREF and operate on the elements on an array. It can be useful for performance.
pve has joined #commonlisp
<beach>
hayley: That's what the SICL sequence functions do.
<beach>
The current version does not use quite the same technique, but the idea is the same.
<hayley>
I am aware, thanks. Is that code silly to you? I think it's a pretty reasonable optimization, though I vaguely recall you mentioning that the SICL compiler should do some sort of hoisting automatically.
<hayley>
(I think the term is "hoisting" some test out of a function, but I could be mistaken.)
<beach>
I meant code like (defun f (x) (g x)).
<hayley>
s/function/loop
<hayley>
Oh, okay.
<beach>
I see no point in compiling two different versions of f according to the type of the argument.
makomo has joined #commonlisp
<hayley>
Yes, that sort of code would be pointless, but that is not what the SICL sequence functions do, nor is it what the Julia compiler does. I would say that the Julia compiler nearly does the same trick that you do with the sequence functions.
hhdave has quit [Ping timeout: 265 seconds]
<beach>
I see.
<hayley>
However, from memory, Julia only compiles specialised variants of a function when the compiler would find it useful to call a specialised variant.
<beach>
That's not quite what lucerne said, which is why I was wondering.
<beach>
Like in (f 2) and (f 3), 2 and 3 can be the sae
<beach>
oops
<beach>
the same type or different types in Common Lisp.
<hayley>
You are referring to "What I’m wondering is if CL compiles specialized versions of each functions for each tuple of input argument types"?
<beach>
Yes, and the statement that Julia does.
<hayley>
I see.
iamFIREc1 has joined #commonlisp
<beach>
The key here being "argument TYPES".
<hayley>
Unless there is some very profitable constant folding to be done, I think a compiler would only bother to generate specialized code for what I called "layout times" in my regular expression compiler.
<beach>
And if Julia considers 2 and 3 to be the same "type" so that the same specialized function would be reused, then it would miss an opportunity for (defun f (x) (if (< x 3) <code-a> <code-b>))
<beach>
So I was waiting for lucerne to explain a bit more.
<pjb>
Furthermore, it's also silly to compile different versions of a function when the different types have actually the same size. C++ does this (because "type-safety"), thus duplicating a lot of code uselessly. You may need a function working on 8-bit types, one on 16-bit types, one on 32-bit types, and nowadays one on 64-bit types, but not care if it's an int or a char*…
<pjb>
Of course, in the case of lisp, all the values are references, so they're all the same width, and a single function is needed.
<hayley>
I have a list of useful types like (simple-array character 1) and (simple-array base-char 1), which I know the Lisp compiler can handle specially.
<pjb>
But references to them are the same!
<hayley>
pjb: Hence why I call them "layout types", as opposed to more abstract (and useful) types like STRING.
<hayley>
There is probably a better name for such types, but I intend to draw attention to how the type is used for optimization rather than, say, proving properties of a program.
cosimone has joined #commonlisp
dec0d3r has joined #commonlisp
<beach>
lucerne: Another question: If Julia compiles a different version of some callee for each combination of argument "types" on call sites, what happens when the callee is then redefined? Does it find all call sites to determine how many versions of the new callee to compile?
<lucerne>
beach: I am not at all an expert on this subject. I basically know the highlevel concepts: dynamic languages are slow as they need to have runtime checks and can use less assumptions to hardcode optimizations, so Julia uses some heuristics to compile type-specialized versions of functions to overcome this limitation. Regarding constant folding (2
<lucerne>
vs 3), I know Julia sometimes does that, but I don’t the specifics. I think it would only do this if is inlining the function anyway. (Julia has some concept of recompiling functions when their dependencies change, so it can inline functions and still support live coding. I a, again not at all an expert. Use their docs, they are one of the best.
<lucerne>
They also have a zulip chat where you’ll find more knowledgeable people.)
<lucerne>
The recompiling, btw, happens when the function is to be used, I think. They use the term “invalidated method.”
<beach>
lucerne: I am not interested enough to go read up on Julia. I thought since you had opinions about how Common Lisp should do things, you might know.
<lucerne>
I was just wondering if CL did such optimizations.
<beach>
lucerne: Recompiling as dependencies change is very iffy. If you have mutual recursion for instance. Also, you can't fully recompile in Common Lisp. You would need to keep a minimally compiled version around. Even so, the amount of recompilation could be massive.
<lucerne>
Btw, can you elaborate on what you mean by a layout type? The layout of the data in the memory?
<beach>
lucerne: Common Lisp is a language. Julia is a programming system. You can't compare the two.
<beach>
lucerne: So Common Lisp does not "do any optimizations". Some implementations do of course.
iamFIREc1 has quit [Ping timeout: 252 seconds]
<beach>
lucerne: A language specification or standard should just define what conforming code looks like and the semantics of such code.
<gin>
is there a substitute function that can replace multiple characters with multiple characters? like (multi-substitute "abc" "ABC" "carbon") => "CArBon"
dec0d3r has quit [Remote host closed the connection]
splittist has quit [Ping timeout: 252 seconds]
hubvu has quit [Ping timeout: 252 seconds]
jcowan has quit [Ping timeout: 245 seconds]
splittist has joined #commonlisp
hubvu has joined #commonlisp
Elis21F has joined #commonlisp
jcowan has joined #commonlisp
hendursa1 has quit [Remote host closed the connection]
hendursa1 has joined #commonlisp
<pve>
gin: you can try cl-ppcre:regex-replace-all
hubvu has quit [Ping timeout: 245 seconds]
victor has quit [Read error: Connection reset by peer]
splittist has quit [Read error: Connection reset by peer]
victor has joined #commonlisp
hubvu has joined #commonlisp
splittist has joined #commonlisp
<gin>
pve: thanks
amb007 has quit [Ping timeout: 252 seconds]
Guest-liao has joined #commonlisp
amb007 has joined #commonlisp
igemnace has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
<Guest-liao>
Hello
lad has quit [Ping timeout: 260 seconds]
<beach>
Hello Guest-liao.
<beach>
Guest-liao: Are you new here? I don't recognize your nick.
<Guest-liao>
Yes
<beach>
Great! Welcome!
<beach>
What brings you to #commonlisp?
<Guest-liao>
One question.
amb007 has quit [Read error: Connection reset by peer]
<Guest-liao>
We have a plan for meta information for the document of Common Lisp. Like we have srfi-data.scm file for the signature of proc and macro
amb007 has joined #commonlisp
<Guest-liao>
of different lisp implemation
<Guest-liao>
Then we can proposal a s-expression of common signature of proc and macro for lisp different implementation community and different scheme community .
<Guest-liao>
Then have RFC- process to review and approve that.
<Guest-liao>
That is just one area. it can be extended in other domain as well.
amb007 has quit [Ping timeout: 245 seconds]
amb007 has joined #commonlisp
<beach>
Guest-liao: There is just too much stuff in what you are saying for me to deal with right now. Maybe others can answer. I need a lunch break myself.
<Guest-liao>
beach take your time. Just an initial idea.
<Guest-liao>
Basic idea is that centralize the meta information in Common Lisp, and rich s-expression for both of Common lisp and scheme.
random-nick has joined #commonlisp
<Guest-liao>
Basic idea is that centralize the meta information of Common Lisp, and rich s-expression for both of Common lisp and scheme.
cosimone has quit [Ping timeout: 252 seconds]
<hayley>
What information?
<Guest-liao>
Like (def (sig (procedure "(toplevel-command SYMBOL PROC [HELPSTRING])" (id toplevel-command)))
<Guest-liao>
(p "Defines or redefines a toplevel interpreter command which can be invoked by entering " (tt ",SYMBOL") ". " (tt "PROC") " will be invoked when the command is entered and may read any required argument via " (tt "read") " (or " (tt "read-line") "). If the optional argument " (tt "HELPSTRING") " is given, it will be listed by the " (tt ",?") "
<Guest-liao>
command.")
<Guest-liao>
)
hubvu has quit [Ping timeout: 260 seconds]
splittist has quit [Ping timeout: 252 seconds]
hubvu has joined #commonlisp
<hayley>
So, just implementation documentation but with \texttt{} replaced with (tt ...)?
amb007 has quit [Read error: Connection reset by peer]
<Guest-liao>
Really? what is it that look like? Could you give one example.
amb007 has joined #commonlisp
<hayley>
From memory, the SBCL manual is typeset using Texinfo.
<Guest-liao>
the symbols in implementation documentation.
<trevlif>
Seems like one can implement CLOS using types? Is that a fair comment? For example, instead of using generic functions, have a typecase within a defun
dec0d3r has joined #commonlisp
<trevlif>
Ok gotta go, chat later folks. Happy lispign!
trevlif has left #commonlisp [ERC (IRC client for Emacs 26.3)]
char has quit [Ping timeout: 252 seconds]
<tfb>
... and by the time I came back they'd gone. Oh well.
<frgo>
<frgo>
hi all: Is Quicklisp (www.quicklisp.org) down? Did I miss something?
azimut has quit [Remote host closed the connection]
azimut has joined #commonlisp
<edgar-rft>
frgo: down here, too (germany)
<JeromeLon>
the whois entry expired yesterday
<edgar-rft>
Quicklisp is the new Facebook :-)
<frgo>
Hm - well... Thanks for confirmation edgar-rft. (I am in Germany, too)
dec0d3r has quit [Read error: Connection reset by peer]
<frgo>
Oha.
dec0d3r has joined #commonlisp
<frgo>
JeromeLon: That is not good...
<frgo>
JeromeLon: I just checked myself. Expiry date shows as 2022-10-09T15:20:41Z. So it will expire next year.
amb007 has quit [Ping timeout: 252 seconds]
amb007 has joined #commonlisp
<edgar-rft>
Xach is logged in but might be still asleep (in the USA it's early in the morning).
<JeromeLon>
frgo: you are right, it was updated a few hours ago. It looks like some whois mirrors are not up to date yet
perrierjouet has quit [Ping timeout: 252 seconds]
<frgo>
But I am unable to resolve www.quicklisp.org. DNS resolver comes up dry.
<frgo>
(even Google's DNS server doesn't resolve it anymore)
<tfb>
it was updated about 4 this morning UTC
<frgo>
Yep, so we have to wait a bit...
Guest-liao has quit [Ping timeout: 256 seconds]
<JeromeLon>
NX TTL for .org if 86400
<JeromeLon>
*is
ebrasca has joined #commonlisp
Guest-liao has joined #commonlisp
perrierjouet has joined #commonlisp
molson_ has joined #commonlisp
molson has quit [Ping timeout: 260 seconds]
sm2n_ has joined #commonlisp
sm2n has quit [Ping timeout: 245 seconds]
sm2n_ has quit [Ping timeout: 252 seconds]
tfb has quit [Quit: died]
Krystof has joined #commonlisp
dec0d3r has quit [Remote host closed the connection]
attila_lendvai has joined #commonlisp
Guest-liao has quit [Quit: Client closed]
Guest-liao has joined #commonlisp
perrierjouet has quit [Quit: WeeChat 3.3]
Nilby has quit [Ping timeout: 245 seconds]
loskutak has quit [Ping timeout: 252 seconds]
<madnificent_>
Does anyone have the IP address on hand so I can override locally?
<madnificent_>
* of quicklisp.org, that is
selwyn has joined #commonlisp
cosimone has joined #commonlisp
azimut_ has joined #commonlisp
azimut has quit [Ping timeout: 276 seconds]
tyson2 has quit [Quit: ERC (IRC client for Emacs 27.2)]
perrierjouet has joined #commonlisp
lisp123 has joined #commonlisp
Guest-liao has quit [Quit: Client closed]
Guest-liao has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
zacque has left #commonlisp [Killed buffer]
lisp123 has joined #commonlisp
lisp123 has quit [Ping timeout: 265 seconds]
Lycurgus has joined #commonlisp
joast has joined #commonlisp
selwyn has quit [Read error: Connection reset by peer]
amb007 has quit [Ping timeout: 252 seconds]
amb007 has joined #commonlisp
waleee has joined #commonlisp
amb007 has quit [Ping timeout: 265 seconds]
amb007 has joined #commonlisp
lisp123 has joined #commonlisp
waleee has quit [Ping timeout: 268 seconds]
lisp123 has quit [Ping timeout: 260 seconds]
Lycurgus has quit [Quit: Exeunt]
sandbox has joined #commonlisp
sandbox is now known as Spawns_Carpeting
Guest-liao has quit [Quit: Client closed]
<Devon>
QuickLisp.org DNS still down. Note WHOIS says Updated Date: 2021-10-10T04:14:33Z
<Devon>
I.e., eleven hours ago.
loskutak has joined #commonlisp
<gin>
what does that mean? my projects relying on quicklisp would fail if I were to redo its setup?
selwyn has joined #commonlisp
tyson2 has joined #commonlisp
selwyn has quit [Remote host closed the connection]
gendl has quit [Ping timeout: 245 seconds]
selwyn has joined #commonlisp
gendl has joined #commonlisp
<frgo>
gin: Well, yes. As quicklisp.org can't be resolved to an IP address the quickload of any package that's not already downloaded would fail - that's what I experience here.
cage has joined #commonlisp
lisp123 has joined #commonlisp
<gin>
that's too bad. I will make sure I don't re-create my project setups until quicklisp.org comes back up
lisp123 has quit [Ping timeout: 245 seconds]
notzmv has quit [Ping timeout: 245 seconds]
iamFIREc1 has joined #commonlisp
mister_m` is now known as mister_m
<jackdani1l>
bundles to your rescue!
cosimone has quit [Quit: ERC (IRC client for Emacs 27.1)]
jealousmonk has joined #commonlisp
semz has quit [Quit: Leaving]
cosimone has joined #commonlisp
waleee has joined #commonlisp
waleee has quit [Client Quit]
waleee has joined #commonlisp
tyson2 has quit [Quit: ERC (IRC client for Emacs 27.2)]
attila_lendvai has quit [Ping timeout: 268 seconds]
semz has joined #commonlisp
semz has quit [Client Quit]
semz has joined #commonlisp
gaqwas has joined #commonlisp
Devon has quit [Ping timeout: 252 seconds]
attila_lendvai has joined #commonlisp
waleee has quit [Ping timeout: 245 seconds]
waleee has joined #commonlisp
donovanquixote has quit [Remote host closed the connection]
luna-is-here has quit [Quit: luna-is-here]
sm2n has joined #commonlisp
luna-is-here has joined #commonlisp
luna-is-here has quit [Quit: luna-is-here]
cage has quit [Quit: rcirc on GNU Emacs 27.1]
notzmv has joined #commonlisp
luna-is-here has joined #commonlisp
johnjay has quit [Read error: Connection reset by peer]
johnjay has joined #commonlisp
hendursa1 has quit [Quit: hendursa1]
hendursaga has joined #commonlisp
selwyn has quit [Read error: Connection reset by peer]
<madnificent_>
it's back up :D
kevingal has joined #commonlisp
ad-absurdum has quit [Quit: Leaving]
sm2n has quit [Read error: Connection reset by peer]
<Arcsech>
The order goes very roughly from slow to fast: clisp, ecl, abcl, ccl, sbcl, with ccl and sbcl being much faster than any of the others (for this super limited benchmark). Might do a bit more exploration along these lines.
gpiero has quit [Quit: Quitting...]
gpiero has joined #commonlisp
Krystof has joined #commonlisp
shka has quit [Ping timeout: 245 seconds]
greaser|q has joined #commonlisp
greaser|q has joined #commonlisp
greaser|q has quit [Changing host]
greaser|q is now known as GreaseMonkey
Psybur has joined #commonlisp
<lisp123>
How do implementations compare on profiling?
Guest6112 has quit [Quit: Client closed]
Lord_of_Life has quit [Ping timeout: 252 seconds]
Lord_of_Life has joined #commonlisp
tyson2 has joined #commonlisp
mzan has joined #commonlisp
pve has quit [Quit: leaving]
pjb has quit [Quit: restart for macOS upgrade]
Psybur has quit [Ping timeout: 265 seconds]
dec0d3r has joined #commonlisp
cjb has joined #commonlisp
taiju has quit [Ping timeout: 252 seconds]
<Spawns_Carpeting>
can the first element of a lisp expr be anything other than an atom in a valid program?
random-nick has quit [Ping timeout: 265 seconds]
<Spawns_Carpeting>
like ((something) 1 2)
<hayley>
((lambda (x) x) 1)
<Spawns_Carpeting>
what would an AST for that look like hayley ?
<Spawns_Carpeting>
or an expr tree
<Spawns_Carpeting>
there is no parent node?
taiju has joined #commonlisp
<dre>
the parent node is the list
<hayley>
There wouldn't be a parent node, because there isn't a parent of this program fragment.
<Spawns_Carpeting>
an AST would not include the list itself would it?
<dre>
(+ 1 2) => 3 leaves, '+' is one, '1' and '2' -- all on the same level.
<hayley>
This code designates a call to the function (lambda (x) x) with the single argument 1.
* hayley
doesn't know what an AST looks like in most people's heads.
<Spawns_Carpeting>
that's what I thought too dre, but I don't know how you could walk that tree to generate bytecode instructions
<Spawns_Carpeting>
a more convention style AST where each operator is a node, and its children are the parameters makes it easier to do that
<Spawns_Carpeting>
i think the other version would be more like a parse tree or something
<hayley>
Can't say more without knowing your bytecode, but in e.g. the Netfarm VM we would write (BYTE 1) (BYTE 2) (GET-PROC <code for LAMBDA function>) (CALL 2)
<Spawns_Carpeting>
I wonder if a non-lisp language would make a better first programming language to try to implement from scratch. Any thoughts about that?
<hayley>
Nah.
<Spawns_Carpeting>
I figured the syntax would be trivial to parse but i find it maybe more confusing
<Spawns_Carpeting>
it doesn't help that I don't have any formal education in parsers or anything like that, and all of the resources I can find are creating ASTs for non-lispy langs
<hayley>
I don't think you really need an AST if you aren't doing much analysis on it. Just pattern match on the list structure you were given.
<lisp123>
Spawns_Carpeting: 1000s of people have tried to find a better approach than lisp. There isn't :)
<Spawns_Carpeting>
what order do you walk the tree to generate ops in the right order hayley? It might seem like a stupid question but I couldn't figure out a way to do that easily
ahlk has quit [Remote host closed the connection]
<Spawns_Carpeting>
i think you just have to walk it backwards, from the bottom rightmost part to the first node? does that sound correct?
<hayley>
Arguments then the function, handling the most nested forms first. So (f x (g y)) compiles to (read Y) (call G) (read X) (call F)
<hayley>
Don't think of it as a global tree traversal though, with depth or breath-first search or whatever. Just think of each type of expression, and how you would generate code for it. e.g. for a form like (F X) I need to generate code to load X, then call F. For (F (G X)) I need to generate code to load (G X), which consists of loading X and calling G...
<Alfr>
hayley, you can't do that. You need to read and stash x before calling g on y; e.g. when x is special and g sets it.
akoana has joined #commonlisp
<hayley>
Right, it depends on evaluation order of arguments, and CL is defined to use left-to-right evaluation.
<Alfr>
At least for the usual left to right evaluation order.
* hayley
thinks some more
<hayley>
That code probably should be (read X) (read Y) (call G) (call F)
gaqwas has quit [Ping timeout: 265 seconds]
<Spawns_Carpeting>
why would we read x first?
<Spawns_Carpeting>
incase it has side effects or something?
<hayley>
It depends on the language you are implementing, and how the bytecode stores arguments. The Netfarm VM uses a stack machine, and the first argument is pushed first.
<Spawns_Carpeting>
i wanted to do a stack machine as well
<hayley>
If I swapped around (read X) and (read Y) (call G), the arguments would be in the wrong order (which is what Alfr pointed out).
<Spawns_Carpeting>
i thought it would push y, call g, push x, call f
<hayley>
Again, it depends on which order you take arguments off the stack.