readonly?

David Nadlinger see at klickverbot.at
Wed Jul 11 08:54:48 PDT 2012


On Wednesday, 11 July 2012 at 10:05:40 UTC, Artur Skawina wrote:
> Because it doesn't let you have a real pointer to a class.

What is a »real pointer«? Class references are really just 
pointers, in a way – you can cast them to void*.

> The obvious alternative would be:
>
>    auto r = new Bar(); // reference
>    Bar* p = r;         // pointer to Bar; ref implicitly 
> converts to pointer.
>    auto pr = &r;       // typeof(pr)==Bar** ; can't do better 
> w/o ref types.
>
> So, does the current scheme have any advantages?

When discussing a language change, the question should always be: 
Does the _new_ scheme have any advantages?

David


More information about the Digitalmars-d-learn mailing list