Things that may be removed

bearophile bearophileHUGS at lycos.com
Mon Dec 22 05:55:00 PST 2008


Don:

Thank you for your list, the first true good answer to this post of mine :-)

> * C-style declarations

I agree that having two ways to do the same thing is generally very bad. But I have personally seen how much useful they are when translating C code to D, so I think some intermediate solution may be better (a way to denote a single C declaration? A way to switch them on only in a module like the module(safe) syntax? With pragmas? I don't know).


> * \n, \r as a string (free up the backslash character)

Do you mean things like?
writefln("hello" \n);
I agree. I don't think they are much useful.


> * Octal (it's not 1952 any more)

More than a year ago I have offered solutions to this. In the meantime Python3 has implemented something similar. It helps avoid bugs.


> * the comma operator (allow in selected places, eg for(; ;++a, ++b)).

I agree. It's quite dangerous. In some places it's useful, so better to limit how and where it can be used.


> * package. In DMD, it's a broken implementation of a broken concept.

I think the D module system needs a public brainstorming to fix it :-)


> * The postincrement and postdecrement operators (make x++, x-- identical 
> to ++x, --x, except that it is illegal to use the return value.

I am not sure this is exactly what I want, but I agree they are tricky and not intuitive enough, and deserve some improvements in D.


>Allowing 
> operator overloading of the postfix operators was a silly hack in C++. 
> It's a freedom nobody wants).

I don't understand much.


> * .sort for AAs.

AAs don't have a sort.
you can do:
aa.keys.sort or aa.values.sort, but I think this is useful (I'd just like the ability to give a sorting "key" to such methods, but this is something more than the current D, so it's off topic in this thread that is about the things that may be removed).


> * Object.toString(). Encourages bad design. It's not powerful enough to 
> be useful.

Here I don't agree much with you. toString is mostly for debugging, for developers, etc. So I think it's useful and good enough (I may want a way to add a second default way to represent an object/struct, to allow a lower-level representation, like __repr__ of Python, but it's not essential).

Your list is longer than the "lists" written by other people, but I think there are some other redundant things that may be removed from the language. Your list is nice and I mostly like it, but it's mostly about small things :-)

Among the small things, are all those quotation ways to like q{} good? (Recently some people have said it's "dangerous" syntax, and I agree).

Another redundant syntax is to define a struct (statically):
auto x = Foo(20, 10)
Foo x = {20, 10};
Here I don't see the point of keeping the C syntax too.

There are several other things, mostly coming from C, that may be redundant. As you may remember, part of this question of mine regarding the things that can be removed was born from this point 11 here:
http://yosefk.com/c++fqa/defective.html#defect-11

Bye,
bearophile



More information about the Digitalmars-d mailing list