digitalmars.D - Alternative template instantiation syntax
- =?utf-8?Q?Simen_Kj=C3=A6r=C3=A5s?= (19/19) Jan 26 2012 A pattern in D is this:
- Peter Alexander (2/3) Jan 27 2012 What problem does this solve?
- Timon Gehr (7/26) Jan 27 2012 It looks like Yoda speak to me. I don't think it is going to fly. If we
- F i L (6/8) Jan 27 2012 This syntax makes a lot of sense, but why have the '=' at all?
- a (5/14) Jan 27 2012 I guess one reason is that it fits better with the rest of the
- F i L (5/22) Jan 27 2012 Every proposal here would break D, so I'm not sure what you mean
- Timon Gehr (8/30) Jan 27 2012 Because then we have
- F i L (1/2) Jan 27 2012 Ahh I see now, that makes sense.
A pattern in D is this: alias Foo!q{ stuffs } MyFoo; Where Foo is a templated struct/class. In many ways, this is similar to defining a new type, and I therefore throw out the suggestion that the syntax should reflect this. I may be wrong, but I think this syntax is unused and fitting: Foo MyFoo!q{ stuffs } This is clearly symmetrical with the definition of normal types: class MyClass { } struct MyStruct { } enum MyEnum { } Critique? Thoughts?
Jan 26 2012
On Friday, 27 January 2012 at 01:24:54 UTC, Simen Kjærås wrote:Critique? Thoughts?What problem does this solve?
Jan 27 2012
On 01/27/2012 02:24 AM, Simen Kjærås wrote:A pattern in D is this: alias Foo!q{ stuffs } MyFoo; Where Foo is a templated struct/class. In many ways, this is similar to defining a new type, and I therefore throw out the suggestion that the syntax should reflect this. I may be wrong, but I think this syntax is unused and fitting: Foo MyFoo!q{ stuffs } This is clearly symmetrical with the definition of normal types: class MyClass { } struct MyStruct { } enum MyEnum { } Critique? Thoughts?It looks like Yoda speak to me. I don't think it is going to fly. If we get alias name = othername; as has been suggested a few times, your example would look like: alias MyFoo = Foo!q{ } Is that good enough?
Jan 27 2012
Timon Gehr wrote:alias MyFoo = Foo!q{ }This syntax makes a lot of sense, but why have the '=' at all? Why not just: alias Num float; alias MyFoo Foo!q{ };
Jan 27 2012
On Friday, 27 January 2012 at 22:02:55 UTC, F i L wrote:Timon Gehr wrote:I guess one reason is that it fits better with the rest of the language, it feels more natural. Also, wouldn't your proposal require making the current syntax illegal and breaking pretty much all of existing D code?alias MyFoo = Foo!q{ }This syntax makes a lot of sense, but why have the '=' at all? Why not just: alias Num float; alias MyFoo Foo!q{ };
Jan 27 2012
On Friday, 27 January 2012 at 22:20:47 UTC, a wrote:On Friday, 27 January 2012 at 22:02:55 UTC, F i L wrote:Every proposal here would break D, so I'm not sure what you mean by "my" proposal. Also, because aliases are non-lvalue definitions, I don't think '=' makes a lot of sense, but I'm not an expert on the matter.Timon Gehr wrote:I guess one reason is that it fits better with the rest of the language, it feels more natural. Also, wouldn't your proposal require making the current syntax illegal and breaking pretty much all of existing D code?alias MyFoo = Foo!q{ }This syntax makes a lot of sense, but why have the '=' at all? Why not just: alias Num float; alias MyFoo Foo!q{ };
Jan 27 2012
On 01/27/2012 11:29 PM, F i L wrote:On Friday, 27 January 2012 at 22:20:47 UTC, a wrote:Because then we have alias symbol1 symbol2; which means symbol2 is an alias for symbol1 and alias symbol1 symbol2!(...) which means symbol1 is an alias for symbol2!(...). It does not seem right.On Friday, 27 January 2012 at 22:02:55 UTC, F i L wrote:Timon Gehr wrote:alias MyFoo = Foo!q{ }This syntax makes a lot of sense, but why have the '=' at all? Why not just: alias Num float; alias MyFoo Foo!q{ };No, they are all additive and backwards-compatible changes. (the old syntax would persist as an alternative) And in D the lhs of a = initializer is not required to be an lvalue anyway: enum x = 1;I guess one reason is that it fits better with the rest of the language, it feels more natural. Also, wouldn't your proposal require making the current syntax illegal and breaking pretty much all of existing D code?Every proposal here would break D, so I'm not sure what you mean by "my" proposal. Also, because aliases are non-lvalue definitions, I don't think '=' makes a lot of sense, but I'm not an expert on the matter.
Jan 27 2012
No, they are all additive and backwards-compatible changes.Ahh I see now, that makes sense.
Jan 27 2012