Implicit enum conversions are a stupid PITA
Walter Bright
newshound1 at digitalmars.com
Thu Mar 25 11:08:57 PDT 2010
grauzone wrote:
> Walter Bright wrote:
> That's funny that you're saying this. Casts are totally messed up in D.
> Some casts do safe operations (casts between objects and interfaces),
> some are absolutely ridiculous and only useful in low level situations
> (casting array slices), some are safe whenever the compiler feels like
> it (array casts of array literals versus array slices), and some
> fundamentally break other language features, even accidentally (immutable).
The unsafe casts are not allowed in safe mode.
> casts are easily grepable, but you never know what a specific cast
> actually does. Think about what this means for generic templated code.
>
> In summary, I'd say casting rules in D are the worst spawn of hell.
>
> I mean, that's ok, it doesn't exactly make D useless. And you can always
> introduce your own safe (exe bloating, sigh) casting template functions.
> But I still find it funny that you say this.
Sure, but I think it misses the point a bit. My point was that one should strive
to eliminate casts from your code. A type system that requires a lot of casts is
going to be less safe than one that does not.
>> Implicit integral conversions are not without problems, but when I
>> found C I threw Pascal under the nearest bus and never wrote a line in
>> it again. The taste was so bad, I refused to even look at Modula II
>> and its failed successors.
>
> For your information, programming in Delphi (modern Pascal dialect) was
> quite a joy. It combined the advantages of the low level programming of
> C (pointers, inline assembler), was safer than C, and included a sane
> object model similar to Java/C#. Sounds familiar?
If there's a particular aspect of Delphi you feel would be a good fit for D,
please make a proposal. There's no surprise you like both C# and Delphi, as they
were created by the same person!
> (Yeah, the template fetishists must have been very unhappy with it.)
>
> I really don't understand why you're bashing Pascal at large. You must
> have had only experience with early Pascal dialects... and then never
> looked at anything that smelled like Pascal... and this as a language
> designer??
There are thousands of languages out there. If I did due diligence researching
them all, I'd never finish, as new languages get created faster than anyone
could ever study them. At some point, you've gotta pick and choose what you're
going to look at in depth. Each language family is based on a core set of
principles that get carried from one version to the next. Pascal's core set is
unbearably restrictive to me. Sure, a lot of people strongly disagree, and
that's fair, it is subjective, after all.
Furthermore, like I said, anyone can propose features from any language they
feel would make a good fit for D. None will be automatically rejected just
because it came from a Pascal family language.
> PS: while you guys are talking about new "absolutely necessary" language
> features, people new to D are despairing to get a working D installation
> and *trying* to use external libraries from dsource (that kind of
> struggling really isn't nice to watch), and people "old" to D are
> desparing over compiler regressions and random bugs that have global
> effects on middle-sized to large codebases (circular dependency and
> optlink bugs come to mind). The situation is slowly improving, but too
> slow and problems *never* get completely eliminated.
I understand the issues, but we have to get the feature set for D2 finalized
before it can be made stable. D1 is stable. The optlink problems have been
solved months ago. The compiler regressions have been unanticipated effects from
fixing long standing problems in bugzilla, and fixing them has been taken care
of reasonably quickly.
I'd welcome your help in fixing issues you feel are most important. There are a
lot of people working hard on them, but we can use more help. After all, there
is no corporation pouring billions into D. We're a bunch of volunteers.
More information about the Digitalmars-d
mailing list