5 ms·
They used Lisp to generate machine code. They didn't parse lisp at all. Imagine writing a library in your favorite language to do what they've done.
by cheez 7y ago
They used Lisp to generate machine code. They didn't parse lisp at all. Imagine writing a library in your favorite language to do what they've done.
- reikonomusha 7y agoThey did parse it, albeit indirectly, by Racket’s reader. Co2 is a language, not a bunch of function calls, so it’s not quite the same as building a library in your favorite language. The article even gives examples of new syntax they produced. Parsing Lisp in Lisp is so easy because it’s free.
- cheez 7y agohttps://github.com/dustmop/co2/blob/master/compile.scm#L3689 https://github.com/dustmop/co2/blob/master/compile.scm#L3689 Indeed, it's almost trivial.
- lispm 7y agoyou just need to implement read-syntax ...
- cheez 7y agoI wasn't being sarcastic, it was very simple the way they've done it. https://docs.racket-lang.org/reference/Reading.html#%28def._%28%28quote._~23~25kernel%29._read-syntax%29%29 https://docs.racket-lang.org/reference/Reading.html#%28def._...
- lispm 7y agoI'm saying that there is a larger machinery behind it. It just looks simple.
- cheez 7y agoWell ok but then technically a hello world is complex for the same reasons
- lispm 7y agoI'd say this depends of the complexity of the I/O system. This was the original claim, which you supported: 'Parsing Lisp in Lisp is so easy because it’s free.' The example you were pointing to is explicitly calling a parsing engine of Racket via 'read-syntax'. Actually more complicated than the usual s-expression reader - which does only read s-expressions, but has no further idea about Scheme syntax. Check the usual Scheme report / Racket documentation for the definition of Scheme syntax, syntax objects and its extension mechanisms (macros, ...). I'd say the whole thing is non-trivial. There is a grammar of Scheme, but it is not fixed, because there are extension mechanisms, which make parsing challenging. It's 'free' because it's a provided language facility - but not free in terms of complexity of the concepts to understand. And no, the syntax of s-expressions (-> data) is not the syntax of Lisp. It's just the syntax of s-expressions. Search the Scheme report for 'syntax'...
- colejohnson66 7y ago> Parsing Lisp in Lisp is so easy because it’s free. Are there any other languages that have this feature? I.E. where the data and the code are the same syntax?
- guicho271828 7y agoWell, if there is new such language then it would be eventually called a lisp dialect.
- kayamon 7y agoRebol springs to mind.
- lispm 7y ago> Parsing Lisp in Lisp is so easy because it’s free. You just have to implement an s-expression reader. Plus an interpreter, compiler or a code walker, which can actually parse the Lisp code.