Why can't we make reference variables?
Nick Sabalausky
SeeWebsiteToContactMe at semitwist.com
Tue Aug 28 19:07:15 PDT 2012
On Wed, 29 Aug 2012 03:16:20 +0200
"Tommi" <tommitissari at hotmail.com> wrote:
> On Wednesday, 29 August 2012 at 00:34:02 UTC, cal wrote:
> > On Wednesday, 29 August 2012 at 00:21:29 UTC, Tommi wrote:
> >> In this situation, I think, the most convenient and sensible
> >> thing to do is to make a reference to the data, and use that
> >> reference multiple times. We could make a pointer, but then
> >> we'd be stuck with the nasty syntax of dereferencing:
> >
> > This works currently:
> >
> > struct Test
> > {
> > void foo() const
> > {
> > writeln("FOO");
> > }
> > }
> >
> > void main()
> > {
> > immutable(Test)* ptr = new immutable(Test);
> > ptr.foo();
> > }
>
> Now, that's a surprise for someone coming from C++. But even
> though ptr looks like a reference variable in your example, it
> doesn't look like it at all in this example:
>
I've been primarily a D guy for years, and even I'm surprised by that!
O_O
More information about the Digitalmars-d
mailing list