# Re: "Pointer" to an object? (i.e. reflect changes to origina

**URL:** <https://www.ruby-forum.com/t/re-pointer-to-an-object-i-e-reflect-changes-to-origina/148118>\
**Category:** Ruby\
**Created:** [September 9, 2008, 2:58pm UTC](https://www.ruby-forum.com/t/re-pointer-to-an-object-i-e-reflect-changes-to-origina/148118 "2008-09-09T14:58:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [September 9, 2008, 2:58pm UTC](https://www.ruby-forum.com/t/re-pointer-to-an-object-i-e-reflect-changes-to-origina/148118/1 "2008-09-09T14:58:59Z")

</div>

> Both lambda and proc work  
> as well, incidentally. Actually, from what I’ve read they’re identical  
> in 1.8 (which is what I’m using), but not in 1.9,

Not exactly.

- lambda and Proc are different to each other in both ruby1.8 and  
ruby1.9.  
Also, they are different in the same way 🙂

- in ruby1.8, proc {} is a synonym for lambda {}

- in ruby1.9, proc {} is a synonym for Proc.new {}

So to play it safe, never use proc {} - always use lambda {} or Proc.new  
{}

For a detailled discussion of the differences, see  
[http://innig.net/software/ruby/closures-in-ruby.rb](http://innig.net/software/ruby/closures-in-ruby.rb)

(although I disagree with his rant: these inconsistencies are carefully  
considered to make Ruby “do the right thing” in various scenarios)

If you are using closures in the way discussed in this thread, then I  
think  
lambda {} is probably the best choice as you get a true closure which is  
fully independent of the thread of execution where it was defined.

Regards,

Brian.

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [September 9, 2008, 3:18pm UTC](https://www.ruby-forum.com/t/re-pointer-to-an-object-i-e-reflect-changes-to-origina/148118/2 "2008-09-09T15:18:20Z")

</div>

Hi Brian –

On Tue, 9 Sep 2008, Brian C. wrote:

> > Both lambda and proc work  
> > as well, incidentally. Actually, from what I’ve read they’re identical  
> > in 1.8 (which is what I’m using), but not in 1.9,
> 
> Not exactly.

I think the statement as written is correct: lambda and proc are the  
same in 1.8 (with Proc.new being different from both), but in 1.9,  
lambda is one thing and proc/Proc.new are another (and the same as  
each other).

> - lambda and Proc are different to each other in both ruby1.8 and ruby1.9.  
> Also, they are different in the same way 🙂
> 
> - in ruby1.8, proc {} is a synonym for lambda {}
> 
> - in ruby1.9, proc {} is a synonym for Proc.new {}
> 
> So to play it safe, never use proc {} - always use lambda {} or Proc.new {}

The original plan, as of RubyConf 2004, was to deprecate proc  
entirely. At least, I got Matz to say he would on that occasion 🙂 I  
rather wish that had happened. In any case, there’s also -\>(){} in 1.9  
of course…

David
