From: Mathieu Bouchard Date: 2005-02-04T18:26:38+09:00 Subject: Re: [Terminology] What's the Ruby/OO name for this paradigm? On Thu, 3 Feb 2005, E S wrote: > In my current project, one of the main paradigms is code such as in > the following example. I'm wondering if there's a Ruby/OO designation > for it so that I wouldn't have to always show some excerpt when > describing the project. It's sort of an inverse continuation passing > scheme (which, in itself, isn't exactly a prime OO term). > > Anything? Input on the style welcome, too, by the way: is this hard to > understand/unintuitive/there's a better way/etc.? It is called "delayed evaluation". The pattern is that instead of having a value of type A, you have a function taking no arguments whose return is of type A. Some take this concept further, ensuring the function is only actually called once, and the result is cached (Scheme has a macro called DELAY for that). That's the kind of thing you'd do to have lazy semantics in a non-lazy language. Don't listen to those who might call this "currying". Currying means decomposing the argument list like this: f = lambda{|a,b,c| a*b+c } p f[4,10,2] g = lambda{|a| lambda{|b| lambda{|c| a*b+c }}} p g[4][10][2] here g is called the currying of f. typewise, that's (A*B*C)->D becoming A->(B->(C->D)). _____________________________________________________________________ Mathieu Bouchard -=- Montr�al QC Canada -=- http://artengine.ca/matju