Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Correct implementation of letrec* ?
Anyone like to venture an opinion as to whether this is a 100% correct
implementation of letrec* ?

(define-syntax letrec*
(syntax-rules ()
((letrec* ((variable expression) ...) body ...)
(let ((variable (void)) ...)
(set! variable expression) ...
body ...))))

Where (void) returns an undefined value, such as (if #f 0).

Thank you,

Andrew Wilcox
email: scheme[at]andrewwilcox.name

Report this thread to moderator Post Follow-up to this message
Old Post
Andrew Wilcox
12-07-04 09:04 PM


Re: Correct implementation of letrec* ?
Andrew Wilcox <scheme@andrewwilcox.name> writes:

> Anyone like to venture an opinion as to whether this is a 100% correct
> implementation of letrec* ?
>
>      (define-syntax letrec*
>        (syntax-rules ()
>          ((letrec* ((variable expression) ...) body ...)
>           (let ((variable (void)) ...)
>             (set! variable expression) ...
>             body ...))))
>
> Where (void) returns an undefined value, such as (if #f 0).

letrec* should allow internal definitions, while the translation
doesn't. It can be fixed by replacing body ... with (let () body ...).

Not incorrect but does not detect some errors: it is an error to
evaluate a variable before it has been bound, while the translation
guarantees that the error will not be detected, even if the
implementation otherwise detects similar errors.

--
__("<         Marcin Kowalczyk
\__/       qrczak@knm.org.pl
^^     http://qrnik.knm.org.pl/~qrczak/

Report this thread to moderator Post Follow-up to this message
Old Post
Marcin 'Qrczak' Kowalczyk
12-08-04 01:57 AM


Re: Correct implementation of letrec* ?
In article <7_KdnXB4at2edijcRVn-sg@gwi.net>,
Andrew Wilcox  <scheme@andrewwilcox.name> wrote:
> Anyone like to venture an opinion as to whether this is a 100% correct
> implementation of letrec* ?

Yes, except if you want to signal an error if an uninitialized
variable is used.

If you are interested in the specification and implementation of
letrec and letrec*, you may want to read Waddell, Sarkar and Dybvig's
"Fixing Letrec": http://www.cs.indiana.edu/~dyb/pubs/fixing-letrec.pdf


Lauri Alanko
la@iki.fi

Report this thread to moderator Post Follow-up to this message
Old Post
Lauri Alanko
12-08-04 01:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Scheme archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:24 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.