On 25/10/2009 08:47, bearophile wrote:
Yigal Chripun:
there should be no syntactic difference between an int and a user
defined type.
for example I should be able to do:
struct foo : int {}
With "alias this" D2 is able to do something like that, but it uses a
nonstandard syntax... So here things may be improved in D2.
Bye,
bearophile
This is one aspect that D inherited from C which I really dislike.
adding alias this to the mix is adding a sin to a crime (as the Hebrew
saying goes).
Scala shows how this can be properly designed.
D has many (sometimes very powerful) hacks that could and should be
replaced with a much better general solution.
for instance there's special handling of void return types so it would
be easier to work with in generic code. instead of this compiler hack a
much simpler solution is to have a unit type and ditch C style void. the
bottom type should also exist mainly for completeness and for a few
stdlib functions like abort() and exit()