Daniel Nugent
2/23/2006 4:22:00 AM
Unlikely. The variables passed into the promise would still have
their references to the outside. You get exactly the same effect as
capturing the variables in a closure and in fact, the given examples
are kinda contrived, it would make more sense to assign CUSTOMERS as a
local variable inside of the promise block, because then it can't be
affected outside of the closure.
However, currently, there IS a block parameter (that of the promise
itself, something to do with circular programming, which sounds
intriguing, but I have hella no idea what it means [PLEASE SEND
LINKS]), but it doesn't seem like you'd use it in most cases.
If you wanted something like, I dunno, currying a promise, you could
just wrap it in a lambda.
On 2/22/06, Shashank Date <shanko_date@yahoo.com> wrote:
> Hi,
>
> Daniel Nugent <nugend@gmail.com> wrote: table_name = "CUSTOMERS"
> x = promise {table_name.dup}
> table_name = "MONKEYS"
> puts x
> =>"CUSTOMERS"
>
> Would avoid the problem. Though it's good to point out that you
> likely want to avoid changing the state of any variable that's
> captured by a promise closure (unless of course you plan on exploiting
> just that).
>
>
>
> All this being said, is there any merit in the idea of passing block parameters? I was toying with it briefly and decided to give it a shot on a whim. Will try and come up with a more convincing answer.
>
> Thanks for all your inputs.
> -- shanko
>
>
> ---------------------------------
> Brings words and photos together (easily) with
> PhotoMail - it's free and works with Yahoo! Mail.
>
--
-Dan Nugent