[plt-scheme] What should (procedure? macro) return?
At Sat, 14 Nov 2009 11:24:41 -0800 (PST), cametan wrote:
> According to R5RS, how procedure? works is
>
> >Returns #t if obj is a procedure, otherwise returns #f.
>
> That's all.
> R6RS says:
>
> >Returns #t if obj is a procedure, otherwise returns #f.
>
> Same way.
> This implies, I believe, its argument can be anything
Yes, the argument can be any *value*. But to deliver a value to a
procedure, you must write a valid procedure-call expression.
The problem with
(procedure? cond)
is not that `procedure?' returns the wrong result, but that
`(procedure? cond)' isn't an expression according to R5RS. No
expression is evaluated, and the `procedure?' procedure is never
called.
Along the same lines,
(procedure? [ )
does not produce #f, even though an open square bracket is not a
procedure. The above is a syntax error, and so `procedure?' isn't
called.
In the same way that R5RS prohibits square brackets, R5RS says that
`cond' has to be used after an open parenthesis to form a valid
expression. More generally, both R5RS and PLT classify misuse of a
syntactic-form identifier as a syntax error.
At the same time, R5RS generally allows implementations to give a
meaning to things that are prohibited in R5RS. So, Gauche and Guile are
probably free to produce #f for `(procedure? cond)' without violating
R5RS, even though `(procedure? cond)' is not a valid R5RS expression
(at the top level, assuming that `cond' is not redefined).