Re: [Chicken-users] nested definitions
On Wed, Sep 05, 2012 at 02:12:31PM -0700, Andy Coolware wrote: > Hi, Hi Andy, > > (define ((A)) 1) > # > > A > # > > (A) > # > > ((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 ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] nested definitions
Hi Andy, On Wed, 5 Sep 2012 14:12:31 -0700 Andy Coolware wrote: > This is my first post here. I am interested in FP in general, Clojure > and Scala in specific. But reaching to roots as Scheme as well from > time. Welcome! > So I git stuck with a question inspired by "Structure and > Interpretation" http://www.youtube.com/watch?v=2Op3QLzMgSY at almost > end of the video @ 1:11:11 . > > So in Scheme we apparently can do such a definition: > >> (define ((A)) 1) > # >> A > # >> (A) > # >> ((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. > > So my question is, what really happens here? That's a syntactic sugar for curried definitions: http://wiki.call-cc.org/man/4/Extensions%20to%20the%20standard#curried-definitions Best wishes. Mario -- http://parenteses.org/mario ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] nested definitions
Hi, This is my first post here. I am interested in FP in general, Clojure and Scala in specific. But reaching to roots as Scheme as well from time. So I git stuck with a question inspired by "Structure and Interpretation" http://www.youtube.com/watch?v=2Op3QLzMgSY at almost end of the video @ 1:11:11 . So in Scheme we apparently can do such a definition: > (define ((A)) 1) # > A # > (A) # > ((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. So my question is, what really happens here? Thanks in advance, Andy ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users