It's not so bad after expand/optimize, but still pretty bad.

But it seems to me that if you want to do this as a macro, you either
have to make a (small) closure for each number of arguments, or you
have to duplicate the (large) body code for each number of arguments.
Is there an escape?

On Thu, May 28, 2009 at 8:35 AM, Derick Eddington
<[email protected]> wrote:
> On Thu, 2009-05-28 at 06:20 +1000, Ramana Kumar wrote:
>> I'm not sure about the "lots of distinct procedures" point. Because I
>> would actually expect lambda* to be used quite a lot. I'm imagining
>> someone essentially renames lambda* to lambda, and maybe there would
>> also be a library (perhaps based on cut/cute) that re-exports (rnrs)
>> procedures as curried versions. However since Ikarus expands
>> everything to case-lambda anyway, maybe there are optimizations in
>> place such that having long case-lambdas isn't as expensive as you
>> think? I don't know - it does seem likely that you'll need to allocate
>> all those tiny procedures... The number you also need to consider
>> (along with the number of uses of lambda*) is how many arguments
>> procedures usually have. It's usually << 10, so the number of lines
>> never gets huge.
>
> case-lambdas with many cases isn't what I was talking about.  The issue
> is the number of unique procedure expressions, in the final expansion,
> which each result in a unique compiled procedure object-code occupying
> memory (and maybe a serialized pre-compiled file).
>
> Do:
>
>  (expand '(lambda* (a b c d e f) "return-value")
>          (interaction-environment))  ;; or wherever your lambda* is
>
> :)
>
> There are a ton of created procedures.  I counted 96.
> (lambda* (a b c) "return-value") results in 12.  This is happening
> because you have many recursive expansions of lambda* which each have
> their own recursive expansions and so on.
>
> Compared to:
>
>  (expand '(lambda/curry (a b c d e f) "return-value")
>          (environment '(xitomatl curry)))
>
> Which results in only one procedure expression.
>
> --
> : Derick
> ----------------------------------------------------------------
>
>

Reply via email to