chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] nested definitions


From: Peter Bex
Subject: Re: [Chicken-users] nested definitions
Date: Wed, 5 Sep 2012 23:21:03 +0200
User-agent: Mutt/1.4.2.3i

On Wed, Sep 05, 2012 at 02:12:31PM -0700, Andy Coolware wrote:
> Hi,

Hi Andy,

> > (define ((A)) 1)
> #<void>
> > A
> #<procedure:A>
> > (A)
> #<procedure>
> > ((A))
> 1
> 
> For my taste, a lot of happen here besides defining A. Scheme somehow
> is able to "figure out" and destruct A from ((A)) in order to make it
> possible. Interestingly enough:
> 
> http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-8.html#%_sec_5.2
> does not seem to cover that case.

Indeed, because this is a nonstandard Chicken extension.
This is documented in the manual, here:
http://wiki.call-cc.org/man/4/Extensions%20to%20the%20standard#curried-definitions

> So my question is, what really happens here?

It's a generalisation of the idea that
(define (x) ...) is shorthand for (define x (lambda () ...)).
(define ((x)) ...) is shorthand for (define x (lambda () (lambda () ...)))

(x) looks just like an application would look at a call
site, ((x)) is also what a "full" call would look like.

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]