[plt-scheme] about letrec and continuation : which behavior is correct ? and why ?

From: Andre Mayers (andre.mayers at usherbrooke.ca)
Date: Tue Aug 19 11:37:30 EDT 2008

If I summarize 
(letrec ((x (call/cc list)))
  (if (pair? x)
      ((car x) (lambda () x))
      (pair? (x))))

is an illegal program because the init of x is evaluated twice. 

Therefore the behaviour of drscheme and Sketchy LISP are inappropriate. 


-----Message d'origine-----
De : plt-scheme-bounces at list.cs.brown.edu
[mailto:plt-scheme-bounces at list.cs.brown.edu] De la part de Matthias
Envoyé : August-19-08 11:20 AM
À : Abdulaziz Ghuloum
Cc : Matthew Flatt; andre.mayers at usherbrooke.ca; 'PLT List'
Objet : Re: [plt-scheme] about letrec and continuation : which behavior is
correct ? and why ?

On Aug 19, 2008, at 10:44 AM, Abdulaziz Ghuloum wrote:

> On Aug 19, 2008, at 7:10 AM, Matthew Flatt wrote:
>> The R5RS/R6RS `letrec' is different, and the result with that other
>> `letrec' should be #f:
> An R6RS implementation may (or may not) raise an &assertion when the
> <init> continuation is invoked the second time, right?  To me, that
> says that "it is an error" (in the R5RS sense) to evaluate an <init>
> continuation more that once, so, the program is incorrect.

I assume w/ "incorrect" you mean "is not a legal program".

It never ceases to amaze me that the Report specifies that some
syntactically legal expressions are NOT programs but you can only
find out (as far as I know) that they are NOT programs by RUNNING
them. (Of course all this means is that compilers and interpreters
accept and deal with 'things' that are not legal programs in the
spirit of a report, though I can't think of another language with
this property.)

-- Matthias

  For list-related administrative tasks:

Posted on the users mailing list.