Request!? why i can't do these things in d????

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun May 4 19:25:02 PDT 2008


"d user." <cortigenb6 at yahoo.com> wrote in message 
news:fvlmpo$2bgq$1 at digitalmars.com...
> 1) implicit constructor conversion like in c++

This behavior is usually only useful for value types.  Value types in D are 
handled by structs, not classes.  And for structs, there is the (really 
really questionable design..) static opCall:

struct S
{
    int value;

    static S opCall(int x)
    {
        S ret;
        ret.value = x;
        return ret;
    }
}

...

S s = 5; // equvalent to S s = S(5)

D2 will be introducing proper constructors for structs.

> 2)import with *  like in java import  xx.xx.*

Ask most Java or Python programmers and you'll get a response similar to 
that of "goto".  They're questionably useful and tend to lead to sloppy 
style, unclear dependencies, and longer compile times. 





More information about the Digitalmars-d mailing list