[r6rs-discuss] [Formal] Allow compilers to reject obvious
jmarshall at alum.mit.edu
Tue Feb 27 01:13:21 EST 2007
On 2/26/07, Anton van Straaten <anton at appsolutions.com> wrote:
> Joe Marshall wrote:
> > I disagree. You can't make a judgement about (if (foo)) without at least
> > assigning some interpretation to the token `if'.
> I'm a little confused by this. Ignoring, for the moment, Lisp/Scheme's
> unique approach to syntax, it is certainly possible to identify an
> expression such as (if (foo)) as being a syntax error without coming to
> any conclusion about the type of the term that it was intended to
I wasn't trying to say anything too complicated here, but suppose the
expression (if (foo)) were part of this larger expression:
(let ((if (lambda (x) (+ x 3)))
(foo (lambda () 7)))
Clearly the validity of the expression depends on the surrounding bindings.
Of course you probably meant `at top level'. But even at top level, you have to
have some sort of model that tells you that `if' isn't being shadowed.
Now I'm not makng any claims about what the entire expression `(if (foo))'
means, I'm only saying that in order to get far enough to decide that it
*says* `if', but that the standard definition of if requires more clauses,
that you need to have some analysis of the code. Since you are
analyzing code without running it, you have some sort of type system.
(This type system doesn't tell you squat about the runtime values,
it simply tells you that the code is well-formed.)
> RnRS defines 'if' as syntax which requires at least a <consequent>
> clause. Lacking such a clause, it's not possible to talk about that
> 'if' as a valid term, so it's not meaningful to talk about the term's
> type. I suppose one could argue that if one is willing to accord it
> provisional status as a term, that it's not possible to give such a term
> a type, and therefore this is a type error. That seems perverse to me,
> and it's not something I've noticed the static type community doing.
> So am I missing something?
Yes. I was just referring to the notion of deciding that an s-expression
that starts with the symbol `if' has something to do with the RnRS
conditional syntax, not with what might be returned if you attempt to
More information about the r6rs-discuss