5 ms·
Logo is close to "a lisp with no parentheses", and it also doesn't have any special forms. You can have parens, but they are optional. Compare: item random
by RodgerTheGreat 5y ago
Logo is close to "a lisp with no parentheses", and it also doesn't have any special forms. You can have parens, but they are optional. Compare:
item random size :list :list
(item (random (size :list)) :list)
It poses challenges for making parse-trees, though, especially since Logo traditionally has dynamic scope: you can't actually know the valence of a function until it is evaluated!
- throwamon 5y agoI'm not familiar with Logo. How are you supposed to know where parentheses are implicitly opened and closed?
- RodgerTheGreat 5y agoIf you know the valence (argument count) of a given word, you know how many following expressions to read, recursively. Parens in s-exprs simply make the valence an explicit syntactic feature of each evaluation. Some dialects of Logo have procedures which permit a variable number of arguments, and in those cases you might be required to include parens. In the places where you need a list (or block), square brackets are used. for example, a classic turtle-graphics phrase: repeat 4 [forward 10 right 90] The primitive `repeat` takes a number and a list, and evaluates the list. The list consists of the primitive `forward`, which takes a number, and then the primitive `right` which takes a number. As for how you parse Logo expressions into a tree form, the strategy I've taken in my interpreters is "don't". Parse everything into flat lists of words, and then at interpretation time peel off words one at a time, measure their valence, and recur.
- throwamon 5y agoOh, that makes sense. Your explanation made me realize I was assuming a few things about the language that apparently aren't true. Thank you.