Re: ref is pointer sugar?

2010-08-06 Thread Pluto
== Quote from Jacob Carlborg (d...@me.com)'s article > On 2010-08-06 15:33, Pluto wrote: > > == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article > >> On Fri, 06 Aug 2010 08:51:31 -0400, Pluto wrote: > >>> Are these equivalent? > >>> > >>> S s;//struct > >>> > >>> void f(ref S s){s.x

Re: ref is pointer sugar?

2010-08-06 Thread Jacob Carlborg
On 2010-08-06 15:33, Pluto wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article On Fri, 06 Aug 2010 08:51:31 -0400, Pluto wrote: Are these equivalent? S s;//struct void f(ref S s){s.x++;} f(s); void f2(S* s){(*s).x++;} f2(&s); They are pretty much equivalent. I think

Re: ref is pointer sugar?

2010-08-06 Thread Pluto
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article > On Fri, 06 Aug 2010 08:51:31 -0400, Pluto wrote: > > Are these equivalent? > > > > S s;//struct > > > > void f(ref S s){s.x++;} > > f(s); > > > > void f2(S* s){(*s).x++;} > > f2(&s); > They are pretty much equivalent. I think th

Re: ref is pointer sugar?

2010-08-06 Thread Pluto
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article > On Fri, 06 Aug 2010 08:51:31 -0400, Pluto wrote: > > Are these equivalent? > > > > S s;//struct > > > > void f(ref S s){s.x++;} > > f(s); > > > > void f2(S* s){(*s).x++;} > > f2(&s); > They are pretty much equivalent. I think th

Re: ref is pointer sugar?

2010-08-06 Thread Steven Schveighoffer
On Fri, 06 Aug 2010 08:51:31 -0400, Pluto wrote: Are these equivalent? S s;//struct void f(ref S s){s.x++;} f(s); void f2(S* s){(*s).x++;} f2(&s); They are pretty much equivalent. I think the code generated actually will be exactly the same. However, the compiler treats ref differently

ref is pointer sugar?

2010-08-06 Thread Pluto
Are these equivalent? S s;//struct void f(ref S s){s.x++;} f(s); void f2(S* s){(*s).x++;} f2(&s); If so, why is it stated that ref is very rarely used? It looks like something I would use a lot with structures.