4 ms·
Wouldn't a parser library that returns a data structure that is the one passed to the equivalent of EVAL and also the one acted on by macros fit this definition
by sanderjd 6y ago
Wouldn't a parser library that returns a data structure that is the one passed to the equivalent of EVAL and also the one acted on by macros fit this definition? And then also the ability to easily serialize it back into textual syntax? If so, this doesn't seem to require S-Expressions or lisp, but rather, like the parent comment said, just a good macro and parser library design. (It is true that languages haven't generally seemed to prioritize this feature, I'm just saying that I don't see any reason it must be fundamentally unique to lisps.)
- lispm 6y agoLisp is written in the data structure. But that's not a requirement for macros. One can write macros from a parsed AST. But that's not what Lisp does.
- p_l 6y agoThink of it more in terms of how the language is specified. Common Lisp is specified in terms of data structure, not text, and you can depend on that particular data structure and manipulate it etc. a 3rd party library that, to be portable, needs to ultimately serialize to text, does not support homoiconicity.
- sanderjd 6y agoIs it really specified in terms of data structure? Are there not rules in the language specification regarding how s-expressions are parsed? Could I create a, for instance, C-like syntax that parses to and can be serialized from this data structure specification, and call that a valid Common Lisp? If so, neat! I do think more languages should be less defined by their concrete syntax.
- p_l 6y agoYes - the standard does cover "Common Lisp Reader", but it's essentially a self-contained chapter - every special form, standard macro etc. is defined in term of the data structures. So what you'd have is, at most, an extension - to be compatible with Common Lisp, CL:READ would still need to read S-Expressions with standard readable, and CL:WRITE write S-Expressions, but nothing stops you from adding extra reader that uses a different syntax.