digitalmars.D - Does anyone like the template syntax "!()" ?
- Tomás A. Rossi (6/6) Oct 11 2005 Does anyone like the template syntax Foo!(T) ?
-
Walter Bright
(5/8)
Oct 11 2005
I do
. - Stewart Gordon (15/20) Oct 13 2005 !(snip)
- Walter Bright (3/14) Oct 14 2005 Ouch!
- Jarrett Billingsley (4/8) Oct 11 2005 I'm with Walter on this one. That, and by now, !() just screams "templa...
- Tomás Rossi (5/13) Oct 11 2005 I'm not saying the opposite. I just wonder if there could be a workaroun...
- Regan Heath (5/23) Oct 11 2005 Yes.
- Tomás Rossi (7/31) Oct 11 2005 Well, you're right on that one.
- JT (3/8) Oct 11 2005 I agree with this - it seems out of place in D. But hey Im getting used
- Sean Kelly (7/10) Oct 11 2005 Overall, I think it's fairly intuitive in that it mimics function call s...
- John C (21/38) Oct 12 2005 Surely it's problematic only in terms of parsers being unable to distinq...
- Sean Kelly (8/25) Oct 12 2005 It will. But this is a problem C++ was sort of backed into because it c...
- Ivan Senji (3/8) Oct 12 2005 Yes, this would be really usefull, and has been suggested many, many
- Walter Bright (3/12) Oct 14 2005 It'll happen.
- Ivan Senji (3/21) Oct 14 2005 Great news. That is why people stay around D, not only is it great but
- BCS (27/36) Oct 14 2005 I know this is a tall order but...
- Walter Bright (15/33) Oct 14 2005 distinquish
- John C (7/42) Oct 15 2005 But in the templated form, b would have to be a type, not a variable (VC...
- Georg Wrede (2/45) Oct 15 2005 I think the current syntax is good enougn.
- Sean Kelly (6/24) Oct 15 2005 A type or an integral constant. Though a must be a type, so there is th...
- Walter Bright (16/33) Oct 15 2005 One major goal of D is to be able to parse the code without needing to
- Tomás Rossi (11/45) Oct 15 2005 You´re right about not to make the same mistake. As you said, <> has so ...
- Ben Hinkle (10/15) Oct 11 2005 It is unfortunate keyboards don't have another brace set.
- Don Clugston (26/36) Oct 12 2005 Another possibility that's more like C++ is <| and |>.
Does anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly. Isn't there an alternative? Best regards Tom
Oct 11 2005
"Tomás A. Rossi" <Tomás_member pathlink.com> wrote in message news:dihdcb$bb$1 digitaldaemon.com...Does anyone like the template syntax Foo!(T) ?I do <g>.I think it's better than C++ angular bracket syntax, but it's still alittleugly. Isn't there an alternative?It's not perfect, but I don't think there's a better solution.
Oct 11 2005
Walter Bright wrote:"Tomás A. Rossi" <Tomás_member pathlink.com> wrote in message news:dihdcb$bb$1 digitaldaemon.com...!(snip) Don't you mean I do !(g). ? :-) Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.Does anyone like the template syntax Foo!(T) ?I do <g>.
Oct 13 2005
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:diltki$1ku9$1 digitaldaemon.com...Walter Bright wrote:Ouch!"Tomás A. Rossi" <Tomás_member pathlink.com> wrote in message news:dihdcb$bb$1 digitaldaemon.com...!(snip) Don't you mean I do !(g). ? :-)Does anyone like the template syntax Foo!(T) ?I do <g>.
Oct 14 2005
"Tomás A. Rossi" <Tomás_member pathlink.com> wrote in message news:dihdcb$bb$1 digitaldaemon.com...Does anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly.I'm with Walter on this one. That, and by now, !() just screams "template" to me. <> does not.
Oct 11 2005
In article <dihjs7$580$1 digitaldaemon.com>, Jarrett Billingsley says..."Tomás A. Rossi" <Tomás_member pathlink.com> wrote in message news:dihdcb$bb$1 digitaldaemon.com...I'm not saying the opposite. I just wonder if there could be a workaround to that syntax as well. I repeat: i like it more than <>, but is !() the best? Thanks TomDoes anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly.I'm with Walter on this one. That, and by now, !() just screams "template" to me. <> does not.
Oct 11 2005
On Wed, 12 Oct 2005 01:20:58 +0000 (UTC), Tomás Rossi <Tomás_member pathlink.com> wrote:In article <dihjs7$580$1 digitaldaemon.com>, Jarrett Billingsley says...Yes. Regan p.s. If you have a suggestion as to a different syntax please post it."Tomás A. Rossi" <Tomás_member pathlink.com> wrote in message news:dihdcb$bb$1 digitaldaemon.com...I'm not saying the opposite. I just wonder if there could be a workaround to that syntax as well. I repeat: i like it more than <>, but is !() the best?Does anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly.I'm with Walter on this one. That, and by now, !() just screams "template" to me. <> does not.
Oct 11 2005
In article <opsyiecdxa23k2f5 nrage.netwin.co.nz>, Regan Heath says...On Wed, 12 Oct 2005 01:20:58 +0000 (UTC), Tomás Rossi <Tomás_member pathlink.com> wrote:Well, you're right on that one. But maybe someone else have a suggestion. I was trying to introduce a subject that is of my interest because that template syntax workaround !() is the only little spot in a really beautiful syntax (enhanced with respect to c++). Greetings TomIn article <dihjs7$580$1 digitaldaemon.com>, Jarrett Billingsley says...Yes. Regan p.s. If you have a suggestion as to a different syntax please post it."Tomás A. Rossi" <Tomás_member pathlink.com> wrote in message news:dihdcb$bb$1 digitaldaemon.com...I'm not saying the opposite. I just wonder if there could be a workaround to that syntax as well. I repeat: i like it more than <>, but is !() the best?Does anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly.I'm with Walter on this one. That, and by now, !() just screams "template" to me. <> does not.
Oct 11 2005
I agree with this - it seems out of place in D. But hey Im getting used to it. its really not that big of a deal. Tomás Rossi wrote:that is of my interest because that template syntax workaround !() is the only little spot in a really beautiful syntax (enhanced with respect to c++). Greetings Tom
Oct 11 2005
In article <dihdcb$bb$1 digitaldaemon.com>, Tomás A. Rossi says...Does anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly.Overall, I think it's fairly intuitive in that it mimics function call syntax. And it's better than <>, as nested tempate terminators (ie. >>) cause problems. Templates are one of the things I like best about D. They're both more powerful and more elegant than their C++ counterpart, lack of implicit instantiation notwithstanding. Sean
Oct 11 2005
"Sean Kelly" <sean f4.ca> wrote in message news:dihkfp$5s5$1 digitaldaemon.com...In article <dihdcb$bb$1 digitaldaemon.com>, Tomás A. Rossi says...Surely it's problematic only in terms of parsers being unable to distinquish between the termination of a template definition and a right-shift operator. requirement for a space between the brackets. Here's a sample of the syntax for parameterised types from different languages: Eiffel: class Vector[T] VB.NET 2.0: Class Vector(Of T) Sather: class Vector{T} O'Caml: class ['T] ref Vector Variations on a theme. They tend to use some form of paired braces, but even that's not really a requirement for a parameterised syntax. For example, the following is not inconceivable: class Vector->T {...} (Actually just an excuse to find a purpose for C++'s pointer operator.)Does anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly.Overall, I think it's fairly intuitive in that it mimics function call syntax. And it's better than <>, as nested tempate terminators (ie. >>) cause problems.Templates are one of the things I like best about D. They're both more powerful and more elegant than their C++ counterpart, lack of implicit instantiation notwithstanding.Implicit instantiation is something D sorely needs. Either that, or some form of duck typing (yes, in a statically-typed language). var vec = new Vector!(T);Sean
Oct 12 2005
In article <diioe0$11fh$1 digitaldaemon.com>, John C says..."Sean Kelly" <sean f4.ca> wrote in message news:dihkfp$5s5$1 digitaldaemon.com...It will. But this is a problem C++ was sort of backed into because it confused too maky people the old way. So why create ambiguities if you don't have to? I'll admit that the <> template syntax seems natural, as the angle braces are commonly used for replacement grammars (BNF and such), but I've found no loss of clarity with the D syntax. The '!' seems a natural fit anyway as it's an imperative signifier. SeanIn article <dihdcb$bb$1 digitaldaemon.com>, Tomás A. Rossi says...Surely it's problematic only in terms of parsers being unable to distinquish between the termination of a template definition and a right-shift operator. requirement for a space between the brackets.Does anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly.Overall, I think it's fairly intuitive in that it mimics function call syntax. And it's better than <>, as nested tempate terminators (ie. >>) cause problems.
Oct 12 2005
John C wrote:Implicit instantiation is something D sorely needs. Either that, or some form of duck typing (yes, in a statically-typed language). var vec = new Vector!(T);Yes, this would be really usefull, and has been suggested many, many times.
Oct 12 2005
"Ivan Senji" <ivan.senji_REMOVE_ _THIS__gmail.com> wrote in message news:dijjrp$1u17$1 digitaldaemon.com...John C wrote:It'll happen.Implicit instantiation is something D sorely needs. Either that, or some form of duck typing (yes, in a statically-typed language). var vec = new Vector!(T);> Yes, this would be really usefull, and has been suggested many, many times.
Oct 14 2005
Walter Bright wrote:"Ivan Senji" <ivan.senji_REMOVE_ _THIS__gmail.com> wrote in message news:dijjrp$1u17$1 digitaldaemon.com...Great news. That is why people stay around D, not only is it great but also getting better. :)John C wrote:It'll happen.Implicit instantiation is something D sorely needs. Either that, or some form of duck typing (yes, in a statically-typed language). var vec = new Vector!(T);Yes, this would be really usefull, and has been suggested many, many times.
Oct 14 2005
In article <dip1m1$i50$3 digitaldaemon.com>, Walter Bright says..."Ivan Senji" <ivan.senji_REMOVE_ _THIS__gmail.com> wrote in message news:dijjrp$1u17$1 digitaldaemon.com...I know this is a tall order but... How about allow operations on templates to define there type with respect to there inputs. As an example, say we have a template with a value parameters defining a struct and we want the return type of a multiplication of two such struct to have a value parameters equal to the sum of the parameters of the operands. This could be done something like this: #template T (int i) One actual use of the would be a Unit type that allows things like the division of distance by time and return velocity. The exponents of the various dimensions of measurement could be carried as value parameters and operated on appropriately.John C wrote:It'll happen.Implicit instantiation is something D sorely needs. Either that, or someYes, this would be really usefull, and has been suggested many, many times.
Oct 14 2005
"John C" <johnch_atms hotmail.com> wrote in message news:diioe0$11fh$1 digitaldaemon.com..."Sean Kelly" <sean f4.ca> wrote in message news:dihkfp$5s5$1 digitaldaemon.com...distinquishIn article <dihdcb$bb$1 digitaldaemon.com>, Tomás A. Rossi says...Surely it's problematic only in terms of parsers being unable toDoes anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly.Overall, I think it's fairly intuitive in that it mimics function call syntax. And it's better than <>, as nested tempate terminators (ie. >>) cause problems.between the termination of a template definition and a right-shiftoperator. There's also distinguishing between a less than and greater than operator.I disagree, since both support only very limited template forms.and C++0x will probably remove the requirement for a space between the brackets.<> will always have parsing problems, and although one might be able to shift around where the seams show, it's still there. For example: a < b > * p; Is it: (a<b>) * (p) or: (a < b) > (*p) ? !() has no parsing ambiguities.
Oct 14 2005
"Walter Bright" <newshound digitalmars.com> wrote in message news:dip1m0$i50$2 digitaldaemon.com..."John C" <johnch_atms hotmail.com> wrote in message news:diioe0$11fh$1 digitaldaemon.com...But in the templated form, b would have to be a type, not a variable (VC++ doesn't find it ambiguous). I guess this isn't evaluated in the parsing phase, but does everything have to be valid to the parser? I'm not dissing D's syntax at all. I just wanted to point out that C++'s syntax isn't evil."Sean Kelly" <sean f4.ca> wrote in message news:dihkfp$5s5$1 digitaldaemon.com...distinquishIn article <dihdcb$bb$1 digitaldaemon.com>, Tomás A. Rossi says...Surely it's problematic only in terms of parsers being unable toDoes anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly.Overall, I think it's fairly intuitive in that it mimics function call syntax. And it's better than <>, as nested tempate terminators (ie. >>) cause problems.between the termination of a template definition and a right-shiftoperator. There's also distinguishing between a less than and greater than operator.I disagree, since both support only very limited template forms.and C++0x will probably remove the requirement for a space between the brackets.<> will always have parsing problems, and although one might be able to shift around where the seams show, it's still there. For example: a < b > * p; Is it: (a<b>) * (p) or: (a < b) > (*p) ?!() has no parsing ambiguities.
Oct 15 2005
John C wrote:"Walter Bright" <newshound digitalmars.com>I think the current syntax is good enougn."John C" <johnch_atms hotmail.com>But in the templated form, b would have to be a type, not a variable (VC++ doesn't find it ambiguous). I guess this isn't evaluated in the parsing phase, but does everything have to be valid to the parser? I'm not dissing D's syntax at all. I just wanted to point out that C++'s syntax isn't evil."Sean Kelly" <sean f4.ca>There's also distinguishing between a less than and greater than operator.<dihdcb$bb$1 digitaldaemon.com>, Tomás A. RossiSurely it's problematic only in terms of parsers being unable to distinquish between the termination of a template definition and a right-shift operator.Does anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly.Overall, I think it's fairly intuitive in that it mimics function call syntax. And it's better than <>, as nested tempate terminators (ie. >>) cause problems.I disagree, since both support only very limited template forms.and C++0x will probably remove the requirement for a space between the brackets.<> will always have parsing problems, and although one might be able to shift around where the seams show, it's still there. For example: a < b > * p; Is it: (a<b>) * (p) or: (a < b) > (*p) ?!() has no parsing ambiguities.
Oct 15 2005
In article <diqgpb$1qje$1 digitaldaemon.com>, John C says..."Walter Bright" <newshound digitalmars.com> wrote in message news:dip1m0$i50$2 digitaldaemon.com...A type or an integral constant. Though a must be a type, so there is that. But as one of Walter's primary goals for D was to produce a language that's very easy to parse, why introduce syntax that has known ambiguities?<> will always have parsing problems, and although one might be able to shift around where the seams show, it's still there. For example: a < b > * p; Is it: (a<b>) * (p) or: (a < b) > (*p) ?But in the templated form, b would have to be a type, not a variable (VC++ doesn't find it ambiguous). I guess this isn't evaluated in the parsing phase, but does everything have to be valid to the parser?I'm not dissing D's syntax at all. I just wanted to point out that C++'s syntax isn't evil.True enough. Sean
Oct 15 2005
"John C" <johnch_atms hotmail.com> wrote in message news:diqgpb$1qje$1 digitaldaemon.com..."Walter Bright" <newshound digitalmars.com> wrote in message news:dip1m0$i50$2 digitaldaemon.com...One major goal of D is to be able to parse the code without needing to consult the symbol table. This makes for both a dramatic simplification of the compiler, and it enables easy creation of third party tools that need to be able to parse the code. Furthermore, b can be a variable in C++ if it is a value parameter.<> will always have parsing problems, and although one might be able to shift around where the seams show, it's still there. For example: a < b > * p; Is it: (a<b>) * (p) or: (a < b) > (*p) ?But in the templated form, b would have to be a type, not a variable (VC++ doesn't find it ambiguous). I guess this isn't evaluated in the parsing phase, but does everything have to be valid to the parser?I'm not dissing D's syntax at all. I just wanted to point out that C++'s syntax isn't evil.Evil or not, the parsing problems of C++ templates are one reason why it has taken many years for any conforming C++ compilers to appear, and the general lack of 3rd party tools that can correctly parse C++. These concerns were brought up when <> was selected, and the concerns were dismissed. All the predicted downsides of <> have come to pass. There is nothing inherently superior to <>, it doesn't even look good - consider an expression using a mix of iostreams, templates, shift operators, and less/greater than. It's unreadable. I can't see a good reason to repeat the mistake.
Oct 15 2005
You´re right about not to make the same mistake. As you said, <> has so much problems and though I like !() better, it´s a shame because it's not a perfect and beautiful syntax either. But I guess it's all about tastes and I understand you had not much of a choice. If there were more symbols we could use to write our programs, that would be bliss. Regards Tom PS: Sorry for my English, I am a Spanish speaker (from Argentina)... though I do my best :) In article <dirh1o$2k4d$2 digitaldaemon.com>, Walter Bright says..."John C" <johnch_atms hotmail.com> wrote in message news:diqgpb$1qje$1 digitaldaemon.com...Tomás A. Rossi"Walter Bright" <newshound digitalmars.com> wrote in message news:dip1m0$i50$2 digitaldaemon.com...One major goal of D is to be able to parse the code without needing to consult the symbol table. This makes for both a dramatic simplification of the compiler, and it enables easy creation of third party tools that need to be able to parse the code. Furthermore, b can be a variable in C++ if it is a value parameter.<> will always have parsing problems, and although one might be able to shift around where the seams show, it's still there. For example: a < b > * p; Is it: (a<b>) * (p) or: (a < b) > (*p) ?But in the templated form, b would have to be a type, not a variable (VC++ doesn't find it ambiguous). I guess this isn't evaluated in the parsing phase, but does everything have to be valid to the parser?I'm not dissing D's syntax at all. I just wanted to point out that C++'s syntax isn't evil.Evil or not, the parsing problems of C++ templates are one reason why it has taken many years for any conforming C++ compilers to appear, and the general lack of 3rd party tools that can correctly parse C++. These concerns were brought up when <> was selected, and the concerns were dismissed. All the predicted downsides of <> have come to pass. There is nothing inherently superior to <>, it doesn't even look good - consider an expression using a mix of iostreams, templates, shift operators, and less/greater than. It's unreadable. I can't see a good reason to repeat the mistake.
Oct 15 2005
"Tomás A. Rossi" <Tomás_member pathlink.com> wrote in message news:dihdcb$bb$1 digitaldaemon.com...Does anyone like the template syntax Foo!(T) ?It is unfortunate keyboards don't have another brace set.I think it's better than C++ angular bracket syntax, but it's still a little ugly. Isn't there an alternative?probably not. The only one that occurs to me is replacing the '!' with a less obtrusive character like '.'. For example Foo.(T) or pkg.mod.class.(Foo,Bar). One advantage (perhaps) of .() over !() is that !( can appear as two tokens and so the lexer can't combine !( into one token while .( is never legal today so the lexer can always make .( a token. This is just thinking off the top of my head so if anyone can think of legal D code where .( is two tokens please correct me.
Oct 11 2005
Tomás A. Rossi wrote:Does anyone like the template syntax Foo!(T) ? I think it's better than C++ angular bracket syntax, but it's still a little ugly. Isn't there an alternative? Best regards TomAnother possibility that's more like C++ is <| and |>. (more typing, but doesn't suffer from the >> problem). There's few related options (syntax holes)... Foo<T> Foo!(T) Foo<|T|> Foo(|T|) Foo{|T|} Foo[|T|] Perhaps the colon could be used. I'm less confident about whether this would conflict with something. Can't be used with <> because of the ?: operator. Foo(:T:) Foo[:T:] -- well, it's an interesting syntax for arrays. Foo{:T:} The first one would mean that smilies would become a token :). I think the old argument that "< > doesn't look much like brackets" doesn't carry much weight with the rise of HTML/XML. But the >> problem is a serious one. It's not a great list to choose from. IMHO, these four are the best of a bad bunch: vector<real> a; vector!(real) b; vector(:real:) c; vector<|real|> d;
Oct 12 2005