[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: specification by implications and example

This page is part of the web mail archives of SRFI 17 from before July 7th, 2015. The new archives for SRFI 17 contain all messages, not just those from before July 7th, 2015.

Shriram Krishnamurthi <shriram@xxxxxxxxxxx> writes:

> > But this is allowed:
> >         (set! ((if (random) car cdr) x) v)
> But when Matthias asked whether the grammar was
>   (set! exp exp)
> you said "No - that would be ambiguous".  I took a guess as to what
> that might mean, but you say my guess at something that would be
> erroneous is "valid syntactically".  So now I know neither what the
> comment about ambiguity refers to nor what the SRFI permits.

`((if (random) car cdr) x)' is not an expression in this context,
just like `x' is not an expresion in the context of `(set! x v)'.
In both cases, they could be called "lvalue expressions", but
Scheme does not have such a concept.

The indended definition is this and nothing more:

(define-syntax set!
  (syntax-rules ()
    ((set! (proc args ...) value)  ;; Assuming Alternative 1
     ((setter proc) args ... value))
    ;; ((set! (proc args ...) value) ;; Assuming Alternative 2
    ;;  ((setter proc) value args ...))
    ((set! var value)
     (%%builtin-set! var value))))
	--Per Bothner
per@xxxxxxxxxxx   http://www.bothner.com/~per/