Jump to page: 1 2
Thread overview
Is it true scope declarations are being removed?
Jan 21, 2011
Sean Eskapp
Jan 23, 2011
Trass3r
Jan 23, 2011
Andrej Mitrovic
Jan 23, 2011
bearophile
Jan 24, 2011
Kagamin
Jan 23, 2011
Trass3r
Jan 24, 2011
so
Jan 24, 2011
Andrej Mitrovic
Jan 24, 2011
Andrej Mitrovic
Jan 24, 2011
Jonathan M Davis
Jan 24, 2011
Jonathan M Davis
Jan 24, 2011
Trass3r
Jan 24, 2011
Jonathan M Davis
January 21, 2011
Someone mentioned to me that scope declarations, e.g.

scope class A{}
or
scope A myNewObject;

are being removed from the language. Is this true? If so, how will RAII-type classes be implemented?
January 23, 2011
Sadly true.
They intend to replace it with a library based solution, I don't know why.
January 23, 2011
I don't understand it either. AFAIK they are being removed because they're unsafe, and are being replaced by an unsafe library solution.
January 23, 2011
Andrej Mitrovic:

> I don't understand it either. AFAIK they are being removed because they're unsafe, and are being replaced by an unsafe library solution.

I have hated see typedef and scoped classes go (I have even missed delete), but you need a bit of faith in the future and in Andrei & Walter. Andrei is not evil, and he's smart. D2 language is a very young language, and when a built-in feature looks not perfect, it's better to remove it now. If you remove it, you will have plenty of time in future to add it back, add something better implementation of it, or to find a better and very different solution, or even to add a more general language feature that allows you to implement the original half-broken feature in library code. While if something badly designed is left in the language, then you are struck with it forever, or almost forever. Generally in language it's 10-100 times simpler to add a new feature than to remove it :-) Better to start with a not complete D2 language, a language with holes waiting to be filled, that with a language with unfixable warts that you may "fix" just adding another better feature and pretending the old one doesn't exist any more (example: nullptr of C++0x).

Bye,
bearophile
January 23, 2011
> I don't understand it either. AFAIK they are being removed because
> they're unsafe, and are being replaced by an unsafe library solution.

I have the same feeling.
While I do understand why typedef is poorly designed (http://d.puremagic.com/issues/show_bug.cgi?id=5467) I can't imagine how a library-based scope is any better than before.
January 24, 2011
On Mon, 24 Jan 2011 00:11:48 +0200, Trass3r <un@known.com> wrote:

> Sadly true.
> They intend to replace it with a library based solution, I don't know why.

If the library solution is as good as the original, it is a big plus.
If only we could do the same for everything!
January 24, 2011
On Friday 21 January 2011 06:10:26 Sean Eskapp wrote:
> Someone mentioned to me that scope declarations, e.g.
> 
> scope class A{}
> or
> scope A myNewObject;
> 
> are being removed from the language. Is this true? If so, how will RAII-type classes be implemented?

std.typecons.scoped is the replacement for the builtin scope declaration. scope declarations are going away because they're inherently unsafe. Why they are then being put into the library, I'm not quite sure, other than the fact that D doesn't _stop_ you from doing unsafe stuff, it just seriously discourages it. I suppose that the big problem with having it in the language itself that the library solution doesn't quite have is that having it in the language kind of implies that it's okay and reasonable to do, which it isn't. It makes sense in specific circumstances, where you're know what all of the code involved is doing and can be sure that no reference to the scoped class will escape. And even then, why didn't you just make it a struct in the first place? There _are_ uses for scoped classes, but they're really not supposed to be the norm. They're unsafe, and you're begging for bugs if you use them heavily.

- Jonathan M Davis
January 24, 2011
> scope declarations are going away because they're inherently unsafe.

Pointers are inherently unsafe as well ;)
January 24, 2011
On Monday 24 January 2011 00:37:40 Trass3r wrote:
> > scope declarations are going away because they're inherently unsafe.
> 
> Pointers are inherently unsafe as well ;)

Well, you can't take those out of the core language and put them in the standard library. And there _are_ cases where pointers are perfectly safe. It's pointer arithmetic and taking the addresso of a local variable which is unsafe. Those are going to be restricted to SafeD. Andrei decided that scope was too unsafe to have in the language (and presumably Walter agreed) and it _can_ be put into the standard library. If you have a problem with it, take it up with him.

- Jonathan M Davis
January 24, 2011
bearophile Wrote:

> If you remove it, you will have plenty of time in future to add it back, add something better implementation of it, or to find a better and very different solution, or even to add a more general language feature that allows you to implement the original half-broken feature in library code.

Having plenty of time, algol must be perfect now.
« First   ‹ Prev
1 2