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

Scheme BNF



    Date: 25 Mar 86 12:23:34 PST (Tue)
    From: willc%tekchips%tektronix.csnet at CSNET-RELAY.ARPA
    	     <[MC.LCS.MIT.EDU].860721.860324.JAR>

            [Someone (Dybvig maybe?):]
            Can we also have (BEGIN) return an unspecified value instead of
            being invalid syntax?

        [JAR:]
        I am certainly opposed to this.

    Care to say why?

I should have said more.  COND is already complicated with an exception
because it says that if no guard returns true and there's no ELSE, then
the value is unspecified.  People like this because it make COND work
well in statement positions where you don't care about the effect
anyhow.  So, in consequence, (COND) makes sense, without having to say
explicitly that (COND) is legal.  But in order to allow (BEGIN) to work,
we have to add an exception to the description "BEGIN evaluates the
forms sequentially, and returns the value of the last form" - you have
to say "...except that if there are no forms, the value is unspecified".
I have written interpreters and compilers that deal with (BEGIN) and
they always have an extra conditional in them to be able to deal with
that as a special case.  And if I had written the BNF as (BEGIN
<statement>* <expression>), as I probably should have, that wouldn't
have worked.  I guess you could make some of the same arguments here
that you do to allow (COND); programs which generate Scheme programs
might know that the thing they're generating is a list of statements to
be put in a statement position, so they might reasonably want to
generate (BEGIN).  But I hate exceptions and unnecessary conditionals.
The COND exception seems unavoidable, and to disallow (COND) we'd need
an exception in the form of a rationale explaining why it was disallowed
even though its semantics is clear; but a (BEGIN) exception does seem
avoidable and unnecessary.  I guess I don't care as much about this as I
thought I did.

By the way: (COND) and (CASE x) are not disallowed by the textual
description in the RRRS, they're only disallowed because the prototype
lines say (COND clause1 clause2 ...) instead of (COND clause1 ...).  The
first means one or more, the second would mean zero or more.

Jonathan