Thread overview | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 11, 2005 Does anyone like the template syntax "!()" ? | ||||
---|---|---|---|---|
| ||||
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 |
October 11, 2005 Re: Does anyone like the template syntax "!()" ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomás A. Rossi | "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 a little > ugly. Isn't there an alternative? It's not perfect, but I don't think there's a better solution. |
October 12, 2005 Re: Does anyone like the template syntax "!()" ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomás A. Rossi | "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. |
October 12, 2005 Re: Does anyone like the template syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomás A. Rossi | 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 |
October 12, 2005 Re: Does anyone like the template syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | 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... >> 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. > > 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 Tom |
October 12, 2005 Re: Does anyone like the template syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomás Rossi | 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...
>>
>> "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.
>>
>>
>
> 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?
Yes.
Regan
p.s. If you have a suggestion as to a different syntax please post it.
|
October 12, 2005 Re: Does anyone like the template syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | 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: >> 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... >>>> 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. >>> >>> >> >> 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? > >Yes. > >Regan > >p.s. If you have a suggestion as to a different syntax please post it. 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 Tom |
October 12, 2005 Re: Does anyone like the template syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomás Rossi | 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
|
October 12, 2005 Re: Does anyone like the template syntax "!()" ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomás A. Rossi | "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. |
October 12, 2005 Re: Does anyone like the template syntax "!()" ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomás A. Rossi | 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 Tom
>
>
Another 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;
|
Copyright © 1999-2021 by the D Language Foundation