[plt-scheme] What should (procedure? macro) return?

From: cametan (masashi.kameda at gmail.com)
Date: Sat Nov 14 14:24:41 EST 2009

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 and whatever it
is, it must give #f if it is not procedure; however, PLT Scheme gives
an error.

> (procedure? cond)
stdin::3601: cond: bad syntax in: cond

 === context ===
/usr/lib/plt/collects/scheme/private/cond.ss:21:13: go
/usr/lib/plt/collects/scheme/private/misc.ss:74:7

> (procedure? if)
stdin::3619: if: bad syntax in: if

 === context ===
/usr/lib/plt/collects/scheme/private/misc.ss:74:7

>

Of course, I know if and cond are not procedure. I definitely know
what they are.
But these evals should give #f back, shouldn't they?

I checked out some other scheme implementations.

In case of Gauche:

gosh> (procedure? cond)
#f
gosh> (procedure? if)
#f
gosh>

In case of Guile:

guile> (procedure? cond)
#f
guile> (procedure? if)
#f
guile>

I think these are what R5RS or R6RS expects.
On the other hand, in case of Scheme48:

(procedure? cond)

Warning: invalid variable reference
         cond
         #{Package 249 user}
         (&warning)

Error: undefined variable
       cond
       (package scheme-level-0)
1>
> (procedure? if)

Warning: invalid variable reference
         if
         #{Package 249 user}
         (&warning)

Error: undefined variable
       if
       (package scheme-level-0)
1>

Scheme 48 basically gives back what PLT does.

Well, which way is correct?
I still believe (procedure? macro) should give back #f; however is
there any reason to give errors?

Thanks.


Posted on the users mailing list.