5 ms·
People talk about forth having no syntax the same way people talk about lisp having no syntax: not entirely correctly. Of course, every textual representation o
by mruts 8y ago
People talk about forth having no syntax the same way people talk about lisp having no syntax: not entirely correctly. Of course, every textual representation of anything has a syntax, but when people talk about something not having a syntax what they really mean is that the syntax is uniform: there is only one global (uniform) syntax.
- benj111 8y agoI've always interpreted it as a lack of keywords etc. Both lisp and forth can be built up from a small number of primitives. Everything you use day to day is basically optional.
- MrEldritch 8y agoYeah, there's "no syntax" in the sense that you could adequately describe the syntax rules on a Post-it.
- boomlinde 8y ago> there is only one global (uniform) syntax. While I agree with the general sentiment that Forth does have a syntax, this statement is not true in Forth. Instead, syntax is extremely local, because words may take over the parser and compiler to implement their own syntax. For example, "(" (which is used for comments) is typically implemented as a word that immediately executes during the compilation phase, takes over the input loop and just reads and discards characters until it has discarded the matching ")" character before returning control to the regular compiler. It has its own little parsing loop going on with its own syntax, totally overriding any global syntax for as long as it feels like.
- bunderbunder 8y agoI'd argue that Lisp has a syntax in that you do need at least a context-free grammar to describe valid Lisp programs. With Forth, on the other hand, while there is a rule for deciding when one word ends and another ends, and how to interpret literals, I think that, for all practical purposes, there aren't actually any strings that are syntactically invalid. As the ANSI Forth standard puts it: > This Standard does not require a syntax or program-construct checker. (page 33)
- madhadron 8y ago> there is only one global (uniform) syntax. Not quite. You have access to the reader in Forth, and it's quite typical to write a word that takes over for the reader for some time and then hands back to the usual reader. Julian Noble used this to implement a subset of FORTRAN for computational physics (more convenient than postfix for doing that) and to make state machine transition tables into code. Sadly, he is no longer with us. Common Lisp also provides access to the reader, so you can do the same trick, but it's not a ubiquitous thing to do the way it is in Forth.