libera/#commonlisp - IRC Chatlog
Search
3:44:04
beach
Spawns_Carpeting: What is your objective with this work of yours? I can tell you how the Cleavir AST would look for an expression like the one that hayley showed, but that may be pointless depending on your objective.
3:49:33
beach
The AST would have a parent node "function application", and it would have two children. The first child would be "function", and the second a list of arguments.
3:50:56
beach
The "function" node would then either be a "named function" AST if the operator is a symbol, or it would be an "anonymous function" AST if the operator is (lambda (x) x) as in the example hayley gavce.
4:01:46
Spawns_Carpeting
that makes sense, I think I keep getting the parse tree and the AST mixed up
4:02:18
Spawns_Carpeting
AST doesn't really care that much about lists or atoms and whatnot, just about expressions
4:03:17
Spawns_Carpeting
my first AST was a flat list for each sexpr rather than an actual tree for example
4:03:24
beach
Right. The Lisp "parse tree" for something like ((lambda (x) x) 1) is trivial, and completely specified.
4:04:51
beach
... It is a proper list of two elements. The first element is a list of three elements, and the second element is 1.
4:10:22
Spawns_Carpeting
i guess I should just ignore lambdas and more advanced stuff for a while anyways
4:17:49
Spawns_Carpeting
its just a bytecode thing for now, technically it's nothing because nothing does anything or works at all
4:18:12
Spawns_Carpeting
this is my first time doing anything related to programming langs and parsers and stuff
4:21:23
beach
Well, that's why I asked about the objectives. You can omit whatever you like if you just want to learn by tinkering a bit. But if you want to compile Lisp, you need to handle all possible constructs.
4:23:42
minion
Spawns_Carpeting: Cleavir: A project to create an implementation-independent compilation framework for Common Lisp. Currently Cleavir is part of SICL, but that might change in the future
4:23:55
minion
Spawns_Carpeting: SICL: SICL is a (perhaps futile) attempt to re-implement Common Lisp from scratch, hopefully using improved programming and bootstrapping techniques. See https://github.com/robert-strandh/SICL
5:53:36
hayley
Spawns_Carpeting: I sort of ignored functions with my first "Lisp" interpreter, and trying to write less trivial programs drove me up a wall.
6:07:34
hayley
I could also provide my own bytecode compiler, but it would be tricky to follow, as you'd need to keep the bytecode specification and intermediate languages in mind. But my (lazy) approach is to replace variable references in the input language with De Brujin indices, and then generate linear bytecode.
6:08:54
hayley
Spawns_Carpeting: See https://gitlab.com/Theemacsshibe/slacker-compiler#input-language and then the "Intermediate language" grammar.
6:09:33
gin
I too want to write my own tiny Lisp interpreter (or something like it) but don't know where to start. is it necessary to read the dragon book first?
6:10:49
hayley
Yes, in <https://gitlab.com/cal-coop/netfarm/netfarm/-/tree/master/Code/Scripts/Script-machine>. But it is a bit over-optimized, so I would prefer to refer people to <https://cal-coop.gitlab.io/netfarm/documentation/Netfarm_script_machine.html#%28part._.Script_execution%29>
6:10:59
gin
spiaggia: yes, a hobby project. yes, to learn how it is done and also to use it myself at least to write trivial programs
6:11:15
hayley
But, if you haven't written any interpreter before, I would also recommend you start with a "tree walking" interpreter which doesn't bother with bytecode.
6:11:47
gin
hayley: by tree walking, do you mean do a recursive descent in the abstract syntax tree and evaluate each node on the fly?
6:12:28
hayley
Yes, but you don't even have to bother with producing an AST. Just dispatch on the nested list structure.
6:12:42
spiaggia
gin: Lisp in Small Pieces is more modern, but I like them both for different reasons.
6:13:18
Spawns_Carpeting
I will check that out tomorrow hayley thanks. I am heading to bed right now and will be back tomorrow!
6:13:51
Spawns_Carpeting
also gin maybe we could chat sometime since we are both working on very similar things!
6:14:18
gin
lisp in small pieces - 500 pages. sounds like going to take hard work. have to plan time for it.
6:14:57
hayley
The book covers a few interpreters (tree walking and bytecode) and then compilation to C, so it makes good use of 500 pages to me.
6:15:41
gin
anatomy of lisp - 464 pages. so two hefty books. will start with only one. out of anatomy of lisp and lisp in small pieces which one do you recommend me, a beginner who has never implemented an interpreter?
6:16:42
Spawns_Carpeting
the VM is just a standard VM with asm like opcodes, the source language is what I want to be lisp like
6:17:54
Spawns_Carpeting
so you write lispy programs, it gets compiled to your standard PUSH/POP/JUMP style opcodes
6:18:17
gin
anyone has learnt programming with Logo here? always wanted to ask, is Logo really a dialect of Lisp? i see it mentioned often.
6:19:02
hayley
I dunno, but based on (fortunately) infrequent discussions, I sometimes wonder if Common Lisp is a dialect of Lisp.
6:19:10
spiaggia
gin: Good. And the translation was made by an excellent translator, making the English version better than the original.
6:20:00
gin
Spawns_Carpeting: goal is to create a small Lisp or Lisp-like language for fun, learning, and also using it to solve small problems like tiny calculations for which I usually use python these days.
6:20:01
spiaggia
gin: In fact, the translator was the only person who got promoted to "distinguished writer" at the French ILOG company that used to sell Lisp systems and tools.
6:20:34
hayley
(Of course, the answer is no, CL is very clearly Smalltalk. They both have late binding of most things, useful type systems, and no datum that isn't an object :)
6:21:24
spiaggia
gin: And if you bring your copy of Lisp in Small Pieces to ELS, she will sign it for you.
6:21:29
gin
spiaggia: woah! talk about combining two skills to create a very niche set of skills. i have often heard this advice is that the best way to make a mark in the world is to take two good skills you have and combine them because the combination would become a niche set of skills that very few other people may have
6:24:42
hayley
There's a physical location for ELS 2022 (the ELS this year happened last May), but no mention of an online part on the ELS website.
6:25:13
hayley
Oh, helps if I check my emails. Didier Verna said "We will also arrange to remain hybrid so that people can physically attend, or follow online!"
6:26:29
susam
I am new to this community, by the way. I began joining this channel only since last year although I have been on IRC for 15 years. Attended the last ELS virtually. The talk on Extempore blew my mind. I would like to attend this year's too. Perhaps virtually because I don't live in Europe.
6:29:18
hayley
I had hoped to visit last year (from Australia), and also catch the last tour of The Stranglers if possible, but both were stopped by the pandemic. I'll see what I can do for ELS 2022.
6:31:16
spiaggia
hayley: It is worth going. Just putting a face to many of the people we interact with is worth it.
6:32:33
susam
Very nice. I will probably only be a visitor (a lurker). Hoping to participate some day. Although I learnt CL long time ago, it is only recently that I have begun using it seriously for some of my hobby projects.
6:35:04
susam
gin: Yes, Logo has had a lot of Lisp influence. I talked to an LCSI Logo developer sometime back and the LCSI logo (which is the same as Atari Logo and IBM PC Logo) were developer by experienced Lispers. Emacs + an assember written in Lisp + a debugger written in Lisp were their development tools.
6:35:05
spiaggia
susam: I don't know if you habitually go to computing conferences, but you can be a participant without presenting anything, and in fact, most people are. There might be 15 presentations or so, for around 90 participants. The thing about going is not so much about the presentations, but about the discussions with the participants during the breaks, or over meals and coffee breaks.
8:06:14
pve
Hi, is it stylistically ok to use strings in a defpackage form, e.g. (:export "CAT" "MEOW" "PURR" ...)?
8:12:06
beach
pve: I personally think it looks ugly if you then use lower-case letters in the code, which is why I use uninterned symbols instead.
8:14:23
beach
The other problem with strings is that it may not work when the readtable changes. If you use uninterned symbols, there is a better chance that the name of the symbol you use in code is going to be the same as that of the uninterned symbol. I am thinking particularly of Franz "modern mode".
8:18:06
pve
beach: Ok thanks. Now that I think about it, this might even be just a matter of syntax highlighting. I like how the strings stand out a bit among the keywords.
8:20:27
beach
pve: I have said this several times, but let me say it again: Emacs syntax highlighting is mediocre at best. It doesn't take different roles of symbols into account. It seems wrong to highlight all uninterned symbols the same no matter the role, and it seems wrong to highlight all strings the same too.
8:21:00
beach
pve: I use Emacs for Common Lisp programming only because we don't have anything better yet. But we are working on it.
8:23:28
JeromeLon
(let ((*message* *messages*)) (do something that indirectly (and temporarily) changes and uses *messages*))
8:23:56
JeromeLon
I remember getting an sbcl warning about this (using lexical variable for a name that looks like a dynamic one)
8:24:26
JeromeLon
But I am not getting it anymore. Does anyone have any idea what circumstances are triggering it?
8:24:46
beach
JeromeLon: It would be highly unusual to initialize a variable with a name in singular form with a variable in plural form.
8:25:18
pve
beach: Oh, are you saying that, for example, exported symbols in a defpackage form (written as uninterned symbols) could be highlighted differently than uninterned symbols elsewhere in the code?
8:26:03
beach
pve: And the strings used in the :EXPORT clause should be highlighted the same as the uninterned symbols in that clause.
8:26:50
cosimone
there are some emacs theems, such as dracula, that do highlight documentation strings differently with respect to other strings
8:27:08
cosimone
however, using a declare expression beforehand fools it into thinking it's a regular string
8:27:40
JeromeLon
beach: or maybe that was my mistake? yes, it was probably a typo, I can reproduce. Thanks!
8:28:20
beach
Nilby: Because, as I said, if the role is the same, the highlighting should be the same.
8:28:22
mfiano
I do not consider _that_ aspect of Emacs highlighting wrong. I wouldn't want it any other way
8:28:23
cosimone
i think a lot of the logic used to highlight common lisp is the same as the one used for emacs lisp, but i could be wrong
8:28:37
loke[m]
I'll have to check the spec, but I'm pretty sure that the declarations have to come after the docstring.
8:28:51
cosimone
i modified color-identifiers.el a bit to account for common lisp, it does provide a nicer and much richer highlighting
8:30:32
cosimone
loke[m]: according to http://www.lispworks.com/documentation/HyperSpec/Body/m_defun.htm#defun, declarations come before documentation
8:31:18
beach
mfiano: Do you think it is fine that 1. The first DEFMETHOD is highlighted as if it were an operator, and 2. that the second DEFMETHOD is not highlighted the same as the first?
8:31:43
mfiano
beach: I wasn't talking about semantic highlighting. I was talking about the atom type differentiations.
8:32:32
beach
mfiano: So in (defpackage ... (:export "FOO" 'bar) you want FOO and bar highlighted differently?
8:32:44
mfiano
I would make lots of mistakes if my uninterned symbol was the same color as a keyword symbol as an argument to a function for example.
8:34:02
beach
On the other hand, if you do (f :foo :foo) and F is (defun f (&key foo)...) I would definitely want the second :foo to be highlighted differently.
8:35:45
beach
I maintain that the role of a token is more important than its exact syntax. And I maintain that Emacs is unable to take the role into account.
8:35:53
mfiano
Why will you "refuse to make suggestions" and "be quiet" over different opinions? Lisp's main strengths include the flexibility it gives programmers and listening to other opinions is always welcome. That sounds sort of a childish response..
8:36:31
cosimone
_death: yes, i noticed that too, if i run (documentation ...), i can still see the string
8:36:33
beach
mfiano: I just meant that I won't argue with you since you were not referring to any of my suggestions.
8:36:47
ecraven
beach: well, emacs *could* do this by just sending the form to swank for fontification
8:37:06
cosimone
it's up to personal preference, but i think the "canonical" form seems to be declarations first
8:40:16
ecraven
I've been thinking about that on and off, actually *parsing* s-expressions for fontification in emacs, not just regex-matching them
8:40:39
ecraven
and even better than parsing, using a running system to know *what* anything is actually
8:42:31
beach
ecraven: Second Climacs uses READ (in the form of Eclector) to parse the buffer contents, so that it can take custom reader macros and such into account. And scymtym has been doing work on syntax analysis of the result.
8:43:13
beach
ecraven: The main thing stopping me (or us) from making progress is that I still need to figure out how to compute indentation.
8:44:16
ecraven
for example, emacs "incorrectly" indents '(foo bar\nbaz quux), where I *want* foo and baz to start at the same column (because it's all "data").
8:44:56
beach
ecraven: But, again, to do it right, you need to parse the contents using Common Lisp READ.
8:46:00
mfiano
in an asdf:defsystem :depends-on form, if the first dependency is a symbol that begins with DEF, it indents the rest of the list very strangely. It also doesn't matter if its a symbol, keyword, or uninterned symbol prefix.
8:46:28
mfiano
I like to sort my dependencies lexicographically, and in one project #:defpackage-plus was first. Big mistake :)
8:47:04
_death
there is a discussion about precisely these indentation issues current on emacs-devel
8:47:58
jackdaniel
automatic indentation was supposed to save the programmer from certain cosmetic dillemas but given how much headache comes from invalid indentation (or of implementing the right thing), that claim seems to be shaky ,)
8:48:46
beach
jackdaniel: I maintain that the problems are due to a fundamentally flawed technique for computing indentation.
8:50:52
jackdaniel
beach: I know; I wonder what would be the correct approach for editors that aim to target multiple languages with indentation rules that depend on the role of a symbol
8:51:25
jackdaniel
probably such editor would need to implement at least a part of a compiler for each supported language
8:51:57
jackdaniel
(and this is more common in ides lately I think, not necessarily for indentation but for completion and such)
8:53:32
pjb
gin: you may start by reading AIM-8 http://informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/aim-8/aim-8.html ; and have a look at those examples: http://informatimago.com/articles/usenet.html#Compilation
8:53:59
pjb
gin: but then, if you want to go beyond the toy tiny lisp interpreter, reading LiSP is indeed a very good idea.
8:54:05
beach
jackdaniel: I seriously doubt that there is a uniform approach that can take different languages into account. Each language would need a parser that recognizes that language, in our case READ. And it needs to be incremental to handle large buffers, which I suspect is not even possible in most languages.
8:55:04
pjb
gin: and the latest edition of the Dragon Book, Compiler Principles Techniques and Tools, Aho et al. http://dragonbook.stanford.edu/ if you want to go beyond (other languages with parsers, code generation, the latest edition even covers some garbage collection).
8:57:16
pjb
gin: LiSP is 500 pages, but it describes actually 11 interpreters/compilers refining them from simplistic to sophisticated, so it's more like 11 times 45 pages. You can process 45 pages ;-)
8:57:59
beach
_death: Sure, but I suspect that for languages with complicated syntax rules, there will be many more cases where the entire buffer parse result will be invalidated by a single keystroke.
9:00:00
_death
beach: depends on the keystroke :).. but I think it seems to work in practice, so IDEs (and emacs..) adopt or experiment with it
9:00:13
mfiano
beach: tree-sitter is supposed to be fault tolerant for things like that, though i don't know how that works in process
9:35:22
flip214
when using FORMAT with ~s, can I make the output (nested in a sublist) of floats like with ~f instead of ~e? for this use case 123456789123.456 is easier to read/compare than 1.234…e9.
9:45:17
pjb
(format nil "(~{~F~^ ~})" '(123456789123.456 100000000.2 0.0000012345)) #| --> "(123456790000.0 100000000.0 0.0000012345)" |#
9:46:25
pjb
(setf *read-default-float-format* 'double-float) (format nil "(~{~F~^ ~})" '(123456789123.456 100000000.2 0.0000012345)) #| --> "(123456789123.456 100000000.2 0.0000012345)"" |#
9:47:43
loke[m]
"A declare expression, sometimes called a declaration, can occur only at the beginning of the bodies of certain forms; that is, it may be preceded only by other declare expressions, or by a documentation string if the context permits."
10:00:23
flip214
of course, if I knew how many levels deep the sublists go (yeah, so more like a tree), I could use ~{ ~}. In fact, I already do, for one level ;)
10:31:14
beach
Shinmera: As you know, I object to the term "compiled language", but I can understand that you may have to simplify things, given the audience.
10:32:52
beach
Shinmera: "We explore... games in detail" sounds like "in detail" refers to the games. Maybe "We explore in detail ... games"
10:34:15
beach
Shinmera: "In CLOS methods ..." looks like "methods" are attached to CLOS. I would insert a comma: "In CLOS, methods ...".
10:37:04
beach
Shinmera: "All of the methods require" I would write as "Each of the methods requires".
10:40:50
susam
Hello beach! That other nick (sp) is just my other nick connected via Matrix bridge. I was just testing out the Matrix-Libera bridging.
10:45:50
beach
Shinmera: My (admittedly small) family says that demonstrative pronouns should be followed by a noun phrase. "To implement this [...], "
10:46:55
beach
Shinmera: "to the enemy class' superclass list" -> "to the list of superclasses of the enemy class"
10:47:40
beach
Shinmera: "when determining the set of" is a dangling participle that many people don't like. "when the set of ... is determined".
10:49:59
beach
"when segregating behaviours" [also a dangling participle] "when behaviors are segregated"
10:53:48
beach
Shinmera: "when handled, the condition causes the stack to unwind", except that is not true. Handling a condition does not cause the stack to unwind.
10:55:51
Shinmera
in this first section I'm talking about handler-case, as that's the construct analogous to try/catch in other languages. I then refine it to distinguish with handler-bind later.
10:56:11
beach
And it is not the handling that causes it. It's the non-local control transfer that is part of the macro HANDLER-CASE.
10:57:04
jackdaniel
fwiw I have a local utility handler-case* that executes the handler /before/ unwinding the stack (built on top of handler-bind)
11:10:43
madnificent_
Xach: Probably not the best time to say so, but with QuickLisp being down I realized I do appreciate it existing very much. It's been a game changer. There's something stopping me from adding things I need to it which I can't point my finger to so I'm sure it'll keep gaining momentum. Thank you.