digitalmars.D - suggestion of implicit new
- shinichiro.h (23/28) May 31 2006 Hi all,
- Tom S (9/24) May 31 2006 Well, it is ambiguous if the class contains a static opCall, but then
- Craig Black (5/24) May 31 2006 I'll second that. It seems like the nicest proposal so far to eliminate...
- Regan Heath (6/31) May 31 2006 Thirded.. in fact I seem to recall Walter expressed a liking for it, as ...
- shinichiro.h (3/6) May 31 2006 Oops! I missed the static opCall. Sorry.
- Rémy Mouëza (9/15) Jun 02 2006 Some people have suggested to use a 'var' keyword as in Javascript or th...
Hi all,
I guess D syntax can allow implicit new expression like following:
class C {
this() {}
this(int x) {}
}
void func() {
C c = C(); // not new C()
c = C(3); // not new C(3)
}
I think the syntax is cute. And the syntax is not ambiguous and does
not make DMD slower. I have succeeded to implement the syntax into
GDC-0.18 (based on DMD-0.157). The following patch worked.
4076,4078c4076,4080
< // fd = search_function(ad, Id::call);
< // if (fd)
< {
---
Expression *e = new DotIdExp(loc, e1, Id::call);
if (dynamic_cast<TypeExp *>(e1)) {
e = new NewExp(loc, NULL, e1->type, arguments);
return e->semantic(sc);
} else {
4080d4081
< Expression *e = new DotIdExp(loc, e1, Id::call);
Any thought?
------------------
shinichiro.h
May 31 2006
shinichiro.h wrote:
Hi all,
I guess D syntax can allow implicit new expression like following:
class C {
this() {}
this(int x) {}
}
void func() {
C c = C(); // not new C()
c = C(3); // not new C(3)
}
I think the syntax is cute. And the syntax is not ambiguous and does
not make DMD slower. I have succeeded to implement the syntax into
Well, it is ambiguous if the class contains a static opCall, but then
again, I'd suggest that syntax instead of the current 'auto' storage
modifier.
auto C c = new C(); // would become C c = C();
// and
C c = new C(); // would stay the same
--
Tomasz Stachowiak /+ a.k.a. h3r3tic +/
May 31 2006
"Tom S" <h3r3tic remove.mat.uni.torun.pl> wrote in message news:e5l5o1$1foc$1 digitaldaemon.com...shinichiro.h wrote:I'll second that. It seems like the nicest proposal so far to eliminate the multiple meanings of "auto". -CraigHi all, I guess D syntax can allow implicit new expression like following: class C { this() {} this(int x) {} } void func() { C c = C(); // not new C() c = C(3); // not new C(3) } I think the syntax is cute. And the syntax is not ambiguous and does not make DMD slower. I have succeeded to implement the syntax intoWell, it is ambiguous if the class contains a static opCall, but then again, I'd suggest that syntax instead of the current 'auto' storage modifier.
May 31 2006
On Wed, 31 May 2006 23:10:58 -0500, Craig Black <cblack ara.com> wrote:"Tom S" <h3r3tic remove.mat.uni.torun.pl> wrote in message news:e5l5o1$1foc$1 digitaldaemon.com...Thirded.. in fact I seem to recall Walter expressed a liking for it, as the solution to the double meaning of "auto", but then I later read all these threads re-hashing "auto" again and again, with no-one mentioning this and I think maybe I imagined it. Reganshinichiro.h wrote:I'll second that. It seems like the nicest proposal so far to eliminate the multiple meanings of "auto".Hi all, I guess D syntax can allow implicit new expression like following: class C { this() {} this(int x) {} } void func() { C c = C(); // not new C() c = C(3); // not new C(3) } I think the syntax is cute. And the syntax is not ambiguous and does not make DMD slower. I have succeeded to implement the syntax intoWell, it is ambiguous if the class contains a static opCall, but then again, I'd suggest that syntax instead of the current 'auto' storage modifier.
May 31 2006
Well, it is ambiguous if the class contains a static opCall, but then again, I'd suggest that syntax instead of the current 'auto' storage modifier.Oops! I missed the static opCall. Sorry. ------------------ shinichiro.h
May 31 2006
In article <20060601132500.408f82ef.hamaji nii.ac.jp>, shinichiro.h says...Some people have suggested to use a 'var' keyword as in Javascript or the auto c = new C (); would become: var c = new C (); and there is no more ambiguity with the static opCall. Personnaly I would have prefer a keyword like 'let' as in OCaml that as a strong and inferred type system.Well, it is ambiguous if the class contains a static opCall, but then again, I'd suggest that syntax instead of the current 'auto' storage modifier.Oops! I missed the static opCall. Sorry. ------------------ shinichiro.h
Jun 02 2006









"Regan Heath" <regan netwin.co.nz> 