chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [Chicken-users] Solved: Re: need help with hygieni


From: Jörg F . Wittenberger
Subject: Re: [Chicken-hackers] [Chicken-users] Solved: Re: need help with hygienic macros
Date: 18 May 2013 16:52:24 +0200

On May 18 2013, Jörg F. Wittenberger wrote:

Eventually I learned that the technique I've been looking for is known singe 2001 by the name "Petrofsky Extraction".

As I'm gaining experience with the Petrofsky extraction, I wonder
how useful it might by to have a version of SRFI-8 `receive`,
which avoids call-with-values (at least under circumstances).

Possible gains:

a) Some run-time errors are caught at compile-time.

b) Returning multiple values is to my knowledge more run-time
  expensive than tail calls in chicken.

Downside: `values` is only available as syntax here.
It would be an interesting exercise (I'm beyond my current capabilities)
to have it available as a first class procedure too.

Find attached some test files:

t1.scm: test cases with errors - non of which is caught at compiletime.
t2.scm: a (limited) version of receive, which catches some errors
       and avoids call-with-values.  However if the multi-value returning
       expression returns by calling some other procedure (instead of
       having a literal (values x ...) in tail position, the tail call
       needs to be wrapped in some crazy `values-from` form.
t3.scm: same as t2.scm, but with magic to handle avoid the need for
       `values-from`.

The trick in t3.scm however goes at the expense of always expanding into
call-with-current-continuation and call-with-values.  Just that it
returns prior to going through C_values.  But I'm afraid the additional
setup costs will be worse than the gain.

At the moment I'm contemplating if it would be possible to rewrite
(preferable using syntax-rules for educational purpose) an expression
such that tail calls are automatically wrapped by something like
`values-from`.

comments welcome

Best

/Jörg



............

Attachment: t1.scm
Description: t1.scm

Attachment: t2.scm
Description: t2.scm

Attachment: t3.scm
Description: t3.scm


reply via email to

[Prev in Thread] Current Thread [Next in Thread]