foo!(bar) ==> foo{bar}

Tiago Carvalho merlin3000 at gmail.com
Tue Oct 7 15:40:50 PDT 2008


Not beeing a very active template programmer I find the @ version the 
easiest on the eyes (since it appears there's no technical differences from 
!() ). Both in template@( int, float ) and the single type template at int 
suggested by Andre.

"Alexander Pánek" <alexander.panek at brainsware.org> wrote in message 
news:gcglje$22re$1 at digitalmars.com...
> Steven Schveighoffer wrote:
>> "Andrei Alexandrescu" wrote
>>> Leandro Lucarella wrote:
>>>> Jarrett Billingsley, el  6 de octubre a las 16:04 me escribiste:
>>>>> On Mon, Oct 6, 2008 at 3:52 PM, Walter Bright
>>>>> <newshound1 at digitalmars.com> wrote:
>>>>>> The foo.(bar) syntax seems to be sinking. The foo{bar} seems to be 
>>>>>> the most
>>>>>> practical alternative. So, how about putting it in the next D2 
>>>>>> release on a
>>>>>> trial basis, so people can try it out and see how it looks?
>>>>>>
>>>>> I guess it's OK but I still don't see why anything has to change.
>>>>> There are much bigger fish to fry.
>>>> Amen!
>>> New/potential users are big fish. There has been quite a bit of opinion 
>>> that the Slashed-Eye Sad Guy is offputting at least at first.
>>
>> You might be misinterpreting how people on this NG have responded.  Here 
>> is my anecdote (or at least what I can remember) when I first encountered 
>> D templates.
>>
>> I'm reading through the spec, and I get to templates, and they are 
>> specified with !().  My first reaction is, well that's dumb, why buck the 
>> trend?  C++, Java, C#, they all use <>, what gives?  Then I read the 
>> reasoning and I totally understand it.  From that point on, !() looks 
>> sooo much better to me than <>.  Never once did I not like the choice of 
>> !, it was all just a knee-jerk reaction to why Walter didn't choose 
>> something that looks the same as C++, especially when there are so many 
>> cases of him copying C++ syntax. It could have been @() or {} and I still 
>> would have reacted the same.
>>
>> My expectation for a new user to D is:
>>
>> 1. The user comes from a Java/C++/C#/etc. background and has the same 
>> initial reaction I had.  Then, depending on their personality, they get 
>> defensively angry or say, 'oh yeah, that makes a lot of sense!' and are 
>> done with it.  I'm guessing the latter would be more common.
>>
>> 2. They have no background in templates, and they say 'What's a 
>> template?'
>>
>> Now, change the template syntax to {} or @() or whatever (clearly not <>, 
>> as there are technical problems with it):
>>
>> 1. User comes from Java/C++/C#/etc., has the same initial reaction 'Why 
>> is this different?  Why make things different than C++ or whatever since 
>> everything else looks like C++?', then they read the explanation and 
>> either get defensively angry, or grasp the reasoning and move on.  Again, 
>> guessing the latter will be more common.
>>
>> 2. They have no background in templates, and they say 'What's a 
>> template?'
>>
>> Bottom line, I believe it matters not in the least what syntax is used. 
>> Templates are a hard concept to grasp to those who have never used them, 
>> regardless of the syntax.
>>
>> Just my view.  Note I can't speak for others that said they were put off 
>> by the !() syntax, but at least that's how I interpreted what they meant.
>>
>> -Steve
>
> As I had no proper background in any of those languages except some C, I 
> didn’t quite get what templates are in the first place. But, as I was kind 
> of diving into the world of compile-time programming through D, !() just 
> always was the way it works. It’s probably just a matter of your 
> background. But having no background and coming to D, reading the reasons 
> for the syntax, it clearly makes sense.
>
> I really don’t see any reason in changing it. Foo!(T) is just a template 
> instantiation for me, and good at that, as it’s a unique syntax you don’t 
> find anywhere else in D’s syntax, unlike {}. The other alternatives were 
> just too clumsy to mention (namely @() #(), although the latter would have 
> been the option with the least pukage included :P).
>
> Also just FYI, all this discussion has pretty much pushed D2 further away 
> from me. I really don’t feel like using it anytime soon at all. 




More information about the Digitalmars-d mailing list