View mode: basic / threaded / horizontal-split · Log in · Help
December 22, 2008
Re: Things that may be removed
bearophile wrote:
> There are some things I'd like to see added to the D language, but what things can be removed from it?
> 
> "Perfection is attained, not when no more can be added, but when no more can be removed."
> -- Antoine de Saint-Exupéry.
> :-)
> 
> "There should be one-- and preferably only one --*obvious* way to do it."
> -- Python Zen, emphasis added by me :-)
> 
> Bye,
> bearophile

That is an excellent question.
Some items in my list are controversial, the first two have already been 
mentioned.

* C-style declarations
* SFINAE
* \n, \r as a string (free up the backslash character)
* #line (make it a pragma instead)
* Octal (it's not 1952 any more)
* the comma operator (allow in selected places, eg for(; ;++a, ++b)).
* package. In DMD, it's a broken implementation of a broken concept.
* The postincrement and postdecrement operators (make x++, x-- identical 
to ++x, --x, except that it is illegal to use the return value. Allowing 
operator overloading of the postfix operators was a silly hack in C++. 
It's a freedom nobody wants).
* is() expressions (I love what you can do with it, but it's 
unintuitive, and traits is a much better solution)
* .sort for AAs.
* Object.toString(). Encourages bad design. It's not powerful enough to 
be useful.
December 22, 2008
Re: Things that may be removed
Don wrote:
> bearophile wrote:
>> There are some things I'd like to see added to the D language, but 
>> what things can be removed from it?
>>
>> "Perfection is attained, not when no more can be added, but when no 
>> more can be removed."
>> -- Antoine de Saint-Exupéry.
>> :-)
>>
>> "There should be one-- and preferably only one --*obvious* way to do it."
>> -- Python Zen, emphasis added by me :-)
>>
>> Bye,
>> bearophile
> 
> That is an excellent question.
> Some items in my list are controversial, the first two have already been 
> mentioned.
> 
> * C-style declarations
> * SFINAE
> * \n, \r as a string (free up the backslash character)
> * #line (make it a pragma instead)
> * Octal (it's not 1952 any more)
> * the comma operator (allow in selected places, eg for(; ;++a, ++b)).
> * package. In DMD, it's a broken implementation of a broken concept.
> * The postincrement and postdecrement operators (make x++, x-- identical 
> to ++x, --x, except that it is illegal to use the return value. Allowing 
> operator overloading of the postfix operators was a silly hack in C++. 
> It's a freedom nobody wants).
> * is() expressions (I love what you can do with it, but it's 
> unintuitive, and traits is a much better solution)
> * .sort for AAs.
> * Object.toString(). Encourages bad design. It's not powerful enough to 
> be useful.

Just a comment:

Octal could be useful in chmod-ing, although saying 0321 != 321 is still 
confusing. I'd suggest keeping octal but change the way of declaring it 
(e.g. python's 0o321 or even toBase!(8, "321").)
December 22, 2008
Re: Things that may be removed
On Mon, Dec 22, 2008 at 7:46 AM, Don <nospam@nospam.com> wrote:
> That is an excellent question.
> Some items in my list are controversial, the first two have already been
> mentioned.
>
> * C-style declarations
> * SFINAE
> * \n, \r as a string (free up the backslash character)
> * #line (make it a pragma instead)
> * Octal (it's not 1952 any more)
> * the comma operator (allow in selected places, eg for(; ;++a, ++b)).
> * package. In DMD, it's a broken implementation of a broken concept.
> * The postincrement and postdecrement operators (make x++, x-- identical to
> ++x, --x, except that it is illegal to use the return value. Allowing
> operator overloading of the postfix operators was a silly hack in C++. It's
> a freedom nobody wants).
> * is() expressions (I love what you can do with it, but it's unintuitive,
> and traits is a much better solution)
> * .sort for AAs.

I suppose you mean for normal arrays.  How about reverse as well?

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

I agree with absolutely everything you've listed here.
December 22, 2008
Re: Things that may be removed
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
December 22, 2008
Re: Things that may be removed
Jarrett Billingsley:
> I suppose you mean for normal arrays.  How about reverse as well?

I'd like to see better and faster "reverse" and "sort", but I think they are useful. Why do you want to see them removed? I think built-in types may enjoy more methods, not less.

Bye,
bearophile
December 22, 2008
Re: Things that may be removed
On Mon, Dec 22, 2008 at 8:59 AM, bearophile <bearophileHUGS@lycos.com> wrote:
> Jarrett Billingsley:
>> I suppose you mean for normal arrays.  How about reverse as well?
>
> I'd like to see better and faster "reverse" and "sort", but I think they are useful. Why do you want to see them removed? I think built-in types may enjoy more methods, not less.

So they can be replaced with library methods.  The built-in sort
doesn't even allow you to sort on a predicate.  Even if we extend the
built-in sort to support this, it'll never be as flexible as some
people want it.  If a sort function can perform just as well or better
than the built-in sort while being more flexible, what's the point of
having the built-in sort?
December 22, 2008
Re: Things that may be removed
Don wrote:
> bearophile wrote:
>> There are some things I'd like to see added to the D language, but 
>> what things can be removed from it?
>>
>> "Perfection is attained, not when no more can be added, but when no 
>> more can be removed."
>> -- Antoine de Saint-Exupéry.
>> :-)
>>
>> "There should be one-- and preferably only one --*obvious* way to do it."
>> -- Python Zen, emphasis added by me :-)
>>
>> Bye,
>> bearophile
> 
> That is an excellent question.
> Some items in my list are controversial, the first two have already been 
> mentioned.
> 
> * C-style declarations
> * SFINAE
> * \n, \r as a string (free up the backslash character)
> * #line (make it a pragma instead)
> * Octal (it's not 1952 any more)
> * the comma operator (allow in selected places, eg for(; ;++a, ++b)).
> * package. In DMD, it's a broken implementation of a broken concept.
> * The postincrement and postdecrement operators (make x++, x-- identical 
> to ++x, --x, except that it is illegal to use the return value. Allowing 
> operator overloading of the postfix operators was a silly hack in C++. 
> It's a freedom nobody wants).
> * is() expressions (I love what you can do with it, but it's 
> unintuitive, and traits is a much better solution)
> * .sort for AAs.
> * Object.toString(). Encourages bad design. It's not powerful enough to 
> be useful.

This looks like a pretty darn good list. Could you give detail on what's 
wrong with #line (lack of minimalism I suppose?) and how you'd replace 
obj.toString? Also, is() is a built-in thing so traits can't do all it does.


Andrei
December 22, 2008
Re: Things that may be removed
== Quote from Don (nospam@nospam.com)'s article
> bearophile wrote:
> > There are some things I'd like to see added to the D language, but what things
can be removed from it?
> >
> > "Perfection is attained, not when no more can be added, but when no more can
be removed."
> > -- Antoine de Saint-Exupéry.
> > :-)
> >
> > "There should be one-- and preferably only one --*obvious* way to do it."
> > -- Python Zen, emphasis added by me :-)
> >
> > Bye,
> > bearophile
> That is an excellent question.
> Some items in my list are controversial, the first two have already been
> mentioned.
> * C-style declarations
> * SFINAE
> * \n, \r as a string (free up the backslash character)
> * #line (make it a pragma instead)
> * Octal (it's not 1952 any more)
> * the comma operator (allow in selected places, eg for(; ;++a, ++b)).
> * package. In DMD, it's a broken implementation of a broken concept.
> * The postincrement and postdecrement operators (make x++, x-- identical
> to ++x, --x, except that it is illegal to use the return value.

Why?  This is a nice piece of syntactic sugar to make relatively simple code more
concise.

> Allowing
> operator overloading of the postfix operators was a silly hack in C++.
> It's a freedom nobody wants).
> * is() expressions (I love what you can do with it, but it's
> unintuitive, and traits is a much better solution)

Agreed.  I love D's compile-time reflection but there are about 100 overlapping
ways to do it, and that's a bit excessive.

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

Please, no.  I love Object.toString().  Sometimes, both in finished products and
when printf-debugging, it's nice to just be able to get a basic string
representation of an object.  Can you please explain how it encourages bad design?
December 22, 2008
Re: Things that may be removed
Hello Don,

> bearophile wrote:
> 
>> There are some things I'd like to see added to the D language, but
>> what things can be removed from it?
>> 
>> "Perfection is attained, not when no more can be added, but when no
>> more can be removed."
>> -- Antoine de Saint-Exupéry.
>> :-)
>> "There should be one-- and preferably only one --*obvious* way to do
>> it." -- Python Zen, emphasis added by me :-)
>> 
>> Bye,
>> bearophile
> That is an excellent question.
> Some items in my list are controversial, the first two have already
> been
> mentioned.
> * C-style declarations
> * SFINAE
> * \n, \r as a string (free up the backslash character)
> * #line (make it a pragma instead)
> * Octal (it's not 1952 any more)
> * the comma operator (allow in selected places, eg for(; ;++a, ++b)).
> * package. In DMD, it's a broken implementation of a broken concept.
> * The postincrement and postdecrement operators (make x++, x--
> identical
> to ++x, --x, except that it is illegal to use the return value.
> Allowing
> operator overloading of the postfix operators was a silly hack in C++.
> It's a freedom nobody wants).
> * is() expressions (I love what you can do with it, but it's
> unintuitive, and traits is a much better solution)
> * .sort for AAs.
> * Object.toString(). Encourages bad design. It's not powerful enough
> to
> be useful.


Can I add foreach_reverse? :)

-JJR
December 22, 2008
Re: Things that may be removed
dsimcha wrote:
> == Quote from Don (nospam@nospam.com)'s article
>> * The postincrement and postdecrement operators (make x++, x-- identical
>> to ++x, --x, except that it is illegal to use the return value.
> 
> Why?  This is a nice piece of syntactic sugar to make relatively simple code more
> concise.

I think he refers to defining them as distinct functions. He doesn't 
want to render either usage invalid.


Andrei
1 2 3 4 5
Top | Discussion index | About this forum | D home