[Issue 5286] To avoid a problem with Template syntax

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 30 05:10:22 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5286



--- Comment #4 from bearophile_hugs at eml.cc 2010-11-30 05:08:50 PST ---
(In reply to comment #1)
> I don't agree it is a source of confusion. I don't know anyone who has been
> confused by it.

Me! I'm the first then.


(In reply to comment #2)
> I should add that in cases like this, one should be able to document a trail of
> confusion, such as is well known with (a & b || c).

The D2 template instantiation syntax is present in D2 only, and only for few
months. So there is no 30 years old series of bug examples like the C syntax (a
& b || c).

Something similar is true for the new D2 operator syntax, that I think is
bug-prone because it doesn't enforce statically only the allowed operators.

So if you ask for a long trail of documented bugs you will need several years
of D2 bugs, and then it may be too much late to fix D2 syntax. So my suggestion
is to be more careful right now, because there is no better alternative.

Here is some documentation, I have had a bug caused by the !x D2 template
syntax in a program that defines a template linked list node:

struct Node(T) {
    T data;
    Node!(T)* next;

    this(T data_, Node!(T)* next_=null) {
        data = data_;
        next = next_;
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list