[plt-scheme] Self evaluating "objects"

From: Jos Koot (jos.koot at telefonica.net)
Date: Mon Jul 14 06:01:10 EDT 2008

Why bother about eval? Nevertheless:

From: http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-17.html#node_idx_1266

(eval expression environment)    procedure 
Evaluates expression in the specified environment and returns its value. Expression must be a syntactically valid Scheme expression represented as a datum value, and environment must be an environment, which can be created using the environment procedure described below.
If the first argument to eval is determined not to be a syntactically correct expression, then eval must raise an exception with condition type &syntax. Specifically, if the first argument to eval is a definition or a splicing begin form containing a definition, it must raise an exception with condition type &syntax. 

See also: http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-4.html#node_idx_52

In #lang scheme and mzscheme and pretty-big the value of a procedure is that procedure. There is #!r6rs though, but:

(library (aap)
 (import (rnrs eval (6)) (rnrs base (6)) (rnrs io simple (6)))
 (write (eval (lambda (x) x) (environment '(rnrs base (6))))))

writes #<procedure>, which seems not to conform to R6RS, for a procedure is not a datum value.
On the other hand with:

(eval '(define a 1) (environment '(rnrs))))

an error is reported: define: not allowed in an expression context in: (define a 1) which does conform to R6RS.
BTW both R5RS and R6RS require two arguments for eval (the expression to be evaluated and an environment)

----- Original Message ----- 
From: "Cristian Baboi" <cristian.baboi at gmail.com>
To: <plt-scheme at list.cs.brown.edu>
Sent: Monday, July 14, 2008 8:00 AM
Subject: [plt-scheme] Self evaluating "objects"

> Hello!
> I've tried the following expression in PLT 4.0.2 and Gambit-C 4.2.8 and  
> got different answers:
> (eval (lambda (x) x))
>> (eval (lambda (x) x))
> #<procedure>
> Gambit-C
>> (eval (lambda (x) x))
> *** ERROR -- Ill-formed expression
> #<procedure #4>
> 1>
> I've browsed trough R5RS and R6RS and I was not able to figure out which  
> behavior is the right one.
> Is this implementation dependent or it is prescribed by some standard ?
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080714/a899db82/attachment.html>

Posted on the users mailing list.