| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
May 05, 2008 Request!? why i can't do these things in d???? | ||||
|---|---|---|---|---|
| ||||
1) implicit constructor conversion like in c++
2)import with * like in java import xx.xx.*
3)char[10] s=new char[10]{a,b,c,d,.....};
thanks
| ||||
May 05, 2008 Re: Request!? why i can't do these things in d???? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to d user. | d user. escribió: > 1) implicit constructor conversion like in c++ I don't know what is it. > 2)import with * like in java import xx.xx.* I don't know why, but I guess it's because searching a symbol in a package in D is not like searching a type in a package in Java. In Java you just need to look for a file named like the type, while in D you need to parse the whole module, maybe do semantic analysis, and then see where the symbol is. > 3)char[10] s=new char[10]{a,b,c,d,.....}; char[10] c = [ 'a', 'b', 'c', ... ]; | |||
May 05, 2008 Re: Request!? why i can't do these things in d???? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to d user. | "d user." <cortigenb6@yahoo.com> wrote in message news:fvlmpo$2bgq$1@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. | |||
May 08, 2008 Re: Request!? why i can't do these things in d???? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote:
>> 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.
I suggest instead creating an "all.d" file that consists of just a bunch of imports that are needed, then just import all;
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply