3 ms·
>Besides dynamic variables, there is also plain old variable mutation. Scheme macros are much more complex than what you described, because of hygiene. For the
by qwertyuiop924 10y ago
>Besides dynamic variables, there is also plain old variable mutation. Scheme macros are much more complex than what you described, because of hygiene. For the sake of making Scheme look better, I left macros out of my grammar. The Nix expression language has none of these things.
Fair enough, but:
>I should take a look at the guix APIs to craft a bigger subset.
What? No.
Those don't add any complexity to the language. You don't add every function to your BNF syntax, do you? This is what I meant about regularity: The sexpr and atoms are the only syntactic elements (except quote and friends, which are syntactic sugar for sexprs).
Most of the things you included in your scheme BNF syntax aren't syntax, they're special forms. Special forms are not syntactically distinct, they are semantically distinct. So while define, if, and lambda are part of the semantics, they aren't part of the syntax.
Macros, too, have no syntactic differentiation: You actually CAN'T add macros to the BNF of the syntax, because there is no syntax to add.
If that's not regular, I don't know what is.
>Nix's lack of a top level (the <Items>* in Scheme) is a big boon for simplicity, especially concerning imports from other files which I forgot to include.
How? What's so complex about having multiple forms at toplevel?
- Ericson2314 10y ago> What? No. Those don't add any complexity to the language Oh, believe me, I'm all about the separation between language and library. I mean the smallest subset of Scheme necessary to use the api. For example, it might use string maps instead of association lists. > Most of the things you included in your scheme BNF syntax aren't syntax, they're special forms. This is just terminology. We have a hierarchy of languages here: 1. All terminating Scheme programs are Scheme programs 2. All Scheme programs are valid s-exprs 3. All s-exprs are plain text 4. All plain text is valid bytestring. ... > Macros, too, have no syntactic differentiation: You actually CAN'T add macros to the BNF of the syntax, because there is no syntax to add. I was doing a grammar for scheme programs, not anything else on that list. Macros invocation requires its own non-terminals because its arguments are arbitrary sexprs, not merely unevaluated expressions. > How? What's so complex about having multiple forms at toplevel? Imports. file=expression makes Nix's `import <some-path>` dead simple. Scheme's is necessarily more complicated.
- qwertyuiop924 10y ago>Oh, believe me, I'm all about the separation between language and library. I mean the smallest subset of Scheme necessary to use the api. For example, it might use string maps instead of association lists. Look, first off, in a scheme system, there's no reason to use string maps. Symbols or strings can be used for alist lookup, and alists are plenty fast for these purposes. Secondly, this is how a scheme experession is run, AFAIK. (define foo (map odd? '(1 2 3 4))) First off, in a scheme that has it, the readtable is run, transforming shortcuts like '<expr> into (quote <expr>). Then the expression is parsed into a memory representation of a sexpr. This could be a series of cons cells, but a lot of schemes use something else. What happens next is pretty implementation dependant, but in an interpreter, the resultant expression is evaluated. The evaluator sees the define - note this, in your model, the parser would catch this - dectects that it is a special form, and passes the expr to the code handing define. That code then evaluates the cddr of the expr, and binds the result to the symbol in the cadr. In some implementations, the cadr can be a list, but this isn't standard. Note that all the parser did was translate some syntactic sugar, and give the interpreter the datastructure representing the sexpr. Because that, AFAIK, is all the parser does. I could be wrong, but tell me if I am, don't just go on as if I'd said nothing. >I was doing a grammar for scheme programs, not anything else on that list. Macros invocation requires its own non-terminals because its arguments are arbitrary sexprs, not merely unevaluated expressions. ...An unevaled expression IS an arbitrary sexpr. What else can it be?