libera/#commonlisp - IRC Chatlog
Search
7:30:46
beach
From the glossary, we learn that a "function designator" is either a function object or a symbol.
7:33:29
beach
#'<name> is taken by READ to be a reader macro, so READ returns (FUNCTION <name>) whereas '<name> is taken by read to be a different reader macro so READ returns (QUOTE <name>).
8:13:29
beach
rendar: READ turns a sequence of characters into a data structure in memory that we call an S-expression. An S-expression is either an atom or a CONS cell containing an S-expression it its CAR slot and another S-expression in its CDR slot.
8:13:51
beach
rendar: The evaluator does not handle sequences of characters, but these S-expressions.
8:30:14
beach
Yes, you can say that. It creates a CONS cell that contains its first argument in the CAR slot and its second argument in the CDR slot.
8:33:37
beach
I mentioned what READ does, because the other day, from what you said, it seemed that you were mixing up reading and evaluation.
8:50:57
pve
Hi, do any of the commonly used utility libraries (e.g. alexandria) provide this utility, perhaps under a different name?
9:00:32
pjb
pve: it could be just (define-namespace recipe), the variable name could be a gensym too. Otherwise no, it's not a general enough concept.
9:02:35
pve
pjb: ok thanks, I included the variable name because I think I prefer defvar here, so existing entries won't be clobbered if the form is re-evaluated
9:04:06
pve
although I didn't give it much thought yet.. your gensym idea is good, so I might do that
9:24:33
pjb
the advantage of using a gensym here (or make-symbol), is that since the variable name is not interned, it cannot be used outside of the code generated by the macro, so you're safe from interferences or side-effects from outside.
9:29:43
pve
yes I see, but just to be clear: re-evaluating that will effectively erase existing entries?
9:31:40
kakuhen
depends on what you're invoking; defvar will assign to a dynamic variable if it's unbound, otherwise it doesn't change the binding
9:31:58
kakuhen
defparameter has the opposite behavior: always assigns a given initial value to a dynamic variable
9:42:16
pjb
pve: alternatively, you could store the hash-table in the symbol-plist of the name of the namespace.
11:52:55
jcowan
beach: The term "S-expression" seems to be incurably ambiguous: it can mean an internal representation or an external one. (The question of what these representations represent I leave to Kantians.)
12:06:04
hexology
maybe it's good to come up with an alternative term for the "internal" variety (hy calls it a "model"), then define terms unambiguously and adhere strictly to the distinction
12:06:41
hexology
i can't speak for lisp specifically, but i find that this is a useful communication technique in fields with confusing terminology. it's a local lexical binding but for language :)
12:09:37
random-nick
why would s-expression mean an internal representation? as far as I know those are called lists
12:11:05
_death
lisp terminology has been around for a long time, so a person who has been sufficiently exposed to it has a good sense of the channel transition matrix for practical block lengths
12:13:48
hayley
Using the definition "an S-expression is either an atom or a CONS cell ..." how is an "S-expression" different to, say, an "object"?
12:13:49
beach
I find it interesting that some people have opinions about pedagogy, yet instead of using those opinions to teach newbies about Common Lisp, they seem to wait until someone else does, only to complain about the pedagogical techniques used by that someone else.
12:16:52
hayley
Just asking, since a few days ago I got into a "discussion" which involved confusing internal and external representations, and the two "layers" of Lisp syntax, and would like to avoid having that experience again.
12:22:32
hayley
In particular, someone was trying to tell me that one could encode any data types using S-expressions (with just lists, symbols and numbers and such). They are correct, but they wrongly claimed it was specific to S-expressions; I don't think it is, because one would need their own "evaluator" of sorts to produce a graph of objects from the list structure read. One could do just the same with any other syntax.
12:25:29
hexology
beach: i hope i didn't give you the impression that i was complaining. that was not my intention.
12:26:40
beach
I can't say I much care anymore. I am getting used to this state of things. Or rather, I now know what to expect.
12:30:38
hayley
On the other hand, the S-expression syntax (or first layer of syntax) is quite permissive, and one can read forms that don't make any sense as Lisp code. But I wouldn't be so bothered if I had to encode everything as a function call, if I had to use some other syntax. Say, writing (person "Hayley" (in "#lisp")) isn't profoundly better than person("Hayley", in("#lisp")) or something like that.
12:31:06
hayley
(We could indeed use reader macros, as is done in Cleavir, to introduce syntax that denotes objects, but I had the sense that I was talking to (or, "past") someone who had an idealised notion of "Lisp" rather than any particular language, because they couldn't distinguish between internal and external representations.)
12:35:01
hexology
hayley: i think the thing about s-expressions is that a(b, c, d) is a very unnatural way to represent a list in writing, while (a b c d) more or less looks like "a list of things"
12:36:15
hayley
In this example, person(...) does not denote a list, though, it denotes some information about a person. A list is one of many kinds of things one might want to represent.
12:38:48
hexology
i don't hate the clojure mindset here, of breaking the equivalence between s-expr "lists" and null-terminated-singly-linked-lists
12:39:11
hexology
re: person(...) vs. (person ...), it was a pretty eye-opening moment when i realized that you couldn't effectively write a static analyzer (e.g. a tree-sitter grammar) for an s-expr language and expect to be able to highlight function calls, provide sensible indenting, etc. without encoding lots of special cases
12:39:43
hexology
static analysis seems to be the biggest deficiency of highly-uniform syntax. you need some kind of runtime information and/or a big list of special cases.
12:40:03
hayley
Still, though, (person "Hayley") is a list, which might denote information about myself under some interpretation. In a way the first interpretation is just "syntax", and the latter is "semantics".
12:42:01
hayley
With regards to analysis: you "just" need to reason about the second (or now "semantic") layer of syntax. I don't know how easy that would be with libraries that seem designed for a single-layer syntax. But, in a way, an evaluator needs to "parse" the list structure to figure out what action it should take; a syntax highlighter should do the same.
12:45:19
hexology
vim has a pretty clever "lispwords" system for indenting lisp-like languages, idk if emacs has an equivalent
12:46:41
hayley
A friend wanted to write an implementation of a language using S-expressions for some assignment work, but had to produce a single-layer syntax. They sent me the parser code and it was quite nasty. Imagine having separate rules for DEFUN forms, LET forms, and such. Though I've seen similar in published code, unfortunately.
12:48:40
hayley
(And when that parser is written by hand in an unsafe language, fuzzing will find somewhat amusing crashes most of the time, because of the sheer number of cases that one has to implement without making mistakes.)
12:53:31
morganw
I think emacs is the opposite, the built-in parser is originally for lisp and things get more difficult the further removed you get from lisp.
12:53:37
jcowan
beach: I intended no offense, but in fact one does not need to be a carpenter to point out that a table wobbles.
12:55:47
hayley
morganw: Suppose I want to model decay, and I write something like (let ((lambda 0.5)) (expt lambda time)). The "lambda" just before "0.5" is highlighted like it starts a LAMBDA form, when it doesn't.
12:56:49
hayley
(The highlighting seems correct in emacs-lisp-mode, but I still get information on the LAMBDA special form in the mini-buffer, which is wrong.)
13:00:16
hayley
(Or perhaps I should have written (let ((lambda 0.5)) (exp (* -1 lambda time))) but that doesn't really matter.)
13:02:27
morganw
The documentation mode is a separate part, I'd guess it isn't using all of the parser information.
13:47:59
White_Flame
rendar: for playing around with the reader to see what it does, (read-from-string "'(foo #.(+ 1 1))") might be an easier interface, which streams from the string you give. As well as (setf *print-pretty* nil) so you can see the raw gory details printed