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).
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).
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).
three(args) {
do the actual work;
return the actual result;
}
Is that the same thing you're using it for?
martin
···
E S <eero.saynatkari@kolumbus.fi> 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).
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]
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.?