*sigh*

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Dec 27 07:25:10 PST 2011


On 12/27/11 1:56 AM, Caligo wrote:
> At the moment I don't see how anything serious can be done with D. In
> the past few weeks, while working on a _toy_ project, I've
> encountered several bugs that have caused a lot of problems and
> wasted a lot of time.  Sorry, but it's just frustrating.  it's
> gotten to the point where I have to rum DMD every time I add/modify
> 10 lines of code just to make sure the compiler doesn't die.
>
> Two of the bugs were causing 'internal errors', but I never managed
> to isolate the issue so that I could bug report them.  I can't
> reproduce them outside of my project, but at the moment I have
> managed to not have them get triggered.  I also use GDC-4.6, which
> sometimes performs better.
>
> *sigh*

The way I see it is, you are a customer (and one who has had enough
faith to hang around for a while), so your issues should be given
priority. We can and we should improve quality in the abstract, but at
the end of the day it's about the human beings who are using the language.

---------------------------8<------------------------------8<--------------------------------------------------
> struct A{
>
> A opBinary(string op)(const ref A a){ A rt; return rt; }
>
> void fun(){ } }
>
> struct B{
>
> A _a; alias _a this; }
>
>
> void main(){
>
> B b1, b2, b3; b3 = (b1 - b2).fun(); }
>
--------------------------->8------------------------------>8--------------------------------------------------
>
> Which causes:
>
> dmd: glue.c:1065: virtual unsigned int Type::totym(): Assertion `0'
> failed. Aborted
>
> DMD 2.57, 64-bit.

Let me make a couple of points about this code. (To be clear, neither 
justifies the presence of an internal compiler error.)

First, you are returning a reference to a local. That is automatically 
suspicious, although I assume this is reduced code from something 
meaningful.

Second, you are exploring a territory that is hardly accessible with 
other languages - operator overloading with consolidated implementation 
in conjunction with subtyping. That means it's not run-of-the-mill stuff 
the compiler is failing with, it's stuff that you would need to abandon 
wholesale if you switched languages.

Again, that's not a justification for the code not working with a 
meaningless error message. I want to warn against the paradoxical "I 
can't get creative use of feature X working, therefore I'm going back to 
my old language where I can't even think of X."

That _all_ being said, creative use of creative D features is a prime 
attraction factor of D and we must have them down perfectly. As I 
mentioned once, very often the first use of D by newcomers is not some 
shit task; shit tasks can be done in any language. It's some difficult 
task that D features promise a miraculous solution for, one that would 
be quite hard to achieve with other languages.


Andrei


More information about the Digitalmars-d mailing list