chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Memoizing a procedure


From: Peter Bex
Subject: Re: [Chicken-users] Memoizing a procedure
Date: Mon, 29 Nov 2010 09:16:13 +0100
User-agent: Mutt/1.4.2.3i

On Sun, Nov 28, 2010 at 11:42:20PM -0300, Hugo Arregui wrote:
> I didn't know about keyword arguments in scheme. It's SRFI-88 stuff?

Like Alan said it's DSSSL-style.  Optional arguments can also be
implemented through let[*]-optionals or manually by using dotted
tail notation and then checking the length of that list.

> >And not for procedures returning zero or multiple values.
> 
> You right.

That's easy to fix using call-with-values or receive, though.
You should be able to replace the set! call by set!-values, but
alas, it doesn't allow setting to a list.

> Collateral question: it's there a difference between define vars into
> make-memoized directly or inside a let?

No, that's just a matter of taste; I generally prefer nested let because
it's more explicit about the scope of these variables.  Inner define
expands into a letrec according to the standard, so it's more or less
equivalent.
(see 
http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-8.html#%_sec_5.2.2
 )

> Cool, this is a pretty good example for around mode.

Feel free to add it to the wiki page for the "advice" egg if you
think it's useful.

> Thanks again Peter!

You're welcome!

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth



reply via email to

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