April 20, 2013
On 4/9/2013 3:20 AM, Bruno Medeiros wrote:
> A bit more annoying is the case with the extern declaration, with the C++
> parameter:
>    extern(C++)
> here you have to look at a special identifier (the C, D, PASCAL part) and see if
> there is a ++ token ahead, it's a bit more of special-casing in the parser. Here
> I think it would have been better to change the the language itself and use
> "CPP" instead of "C++". A minor simplification.

I think the special case is worth it.

April 20, 2013
On 04/20/2013 08:36 PM, Walter Bright wrote:
> On 4/9/2013 3:20 AM, Bruno Medeiros wrote:
>> A bit more annoying is the case with the extern declaration, with the C++
>> parameter:
>>    extern(C++)
>> here you have to look at a special identifier (the C, D, PASCAL part)
>> and see if
>> there is a ++ token ahead, it's a bit more of special-casing in the
>> parser. Here
>> I think it would have been better to change the the language itself
>> and use
>> "CPP" instead of "C++". A minor simplification.
>
> I think the special case is worth it.
>

Without doubt.
April 23, 2013
On 02/04/2013 03:13, Walter Bright wrote:
> On 4/1/2013 4:18 PM, Brian Schott wrote:
<snip>
>> 1) Grammar defined in terms of things that aren't tokens. Take,
>> for example, PropertyDeclaration. It's defined as an "@" token
>> followed by... what? "safe"? It's not a real token. It's an
>> identifier. You can't parse this based on checking the token type.
>> You have to check the type and the value.
>
> True, do you have a suggestion?
<snip>

Er, do away with the meaningless @?  Since nobody seems to have succeeded in explaining how the @-attributes differ from the rest, it seems the right way to go.

Stewart.

-- 
My email address is valid but not my primary mailbox and not checked regularly.  Please keep replies on the 'group where everybody may benefit.
April 23, 2013
If at some point custom attributes will be allowed, @ would be a nice syntax for that.

Things like @safe could be attributes implemented by the standard library - would cut down on the number of keywords.
April 24, 2013
On Tuesday, April 23, 2013 21:51:54 Stewart Gordon wrote:
> Er, do away with the meaningless @? Since nobody seems to have succeeded in explaining how the @-attributes differ from the rest, it seems the right way to go.

That would mean creating more keywords, which would break code. By using @, we avoid having to create new keywords, which I believe was the whole point in the first place. Which attributes got @ on them was fairly arbitrary, but they do definitely serve a purpose. And any new attributes in the future will probably have @ on them for the same reason.

- Jonathan M Davis
April 24, 2013
On Wednesday, April 24, 2013 00:34:54 Diggory wrote:
> If at some point custom attributes will be allowed, @ would be a nice syntax for that.
> 
> Things like @safe could be attributes implemented by the standard library - would cut down on the number of keywords.

We already have custom attributes using @. They're called User Defined Attributes and were added a couple releases ago IIRC.

- Jonathan M Davis
April 24, 2013
On 2013-04-24 03:40, Jonathan M Davis wrote:

> That would mean creating more keywords, which would break code. By using @, we
> avoid having to create new keywords, which I believe was the whole point in
> the first place. Which attributes got @ on them was fairly arbitrary, but they
> do definitely serve a purpose. And any new attributes in the future will
> probably have @ on them for the same reason.

You can't use the same reasoning anymore since we have UDA. Those will conflict with new keywords starting with an @.

-- 
/Jacob Carlborg
April 24, 2013
On Wednesday, 24 April 2013 at 01:40:52 UTC, Jonathan M Davis wrote:
> On Tuesday, April 23, 2013 21:51:54 Stewart Gordon wrote:
>> Er, do away with the meaningless @? Since nobody seems to have
>> succeeded in explaining how the @-attributes differ from the rest, it
>> seems the right way to go.
>
> That would mean creating more keywords, which would break code. By using @, we
> avoid having to create new keywords, which I believe was the whole point in
> the first place. Which attributes got @ on them was fairly arbitrary, but they
> do definitely serve a purpose. And any new attributes in the future will
> probably have @ on them for the same reason.
>
> - Jonathan M Davis

Please don't.

This was the approach taken by Java with the @overload and friends, which leads to ugly code in my opinion.

Once I worked in a project which took a similar approach, we would have annotations as a way to extend the core grammar. Each team eventually grew its own set of annotations, to the point the amount of annotations became bigger than the core grammar itself, with overlapping meaning.

--
Paulo
April 26, 2013
On Wednesday, April 24, 2013 08:39:21 Jacob Carlborg wrote:
> On 2013-04-24 03:40, Jonathan M Davis wrote:
> > That would mean creating more keywords, which would break code. By using @, we avoid having to create new keywords, which I believe was the whole point in the first place. Which attributes got @ on them was fairly arbitrary, but they do definitely serve a purpose. And any new attributes in the future will probably have @ on them for the same reason.
> 
> You can't use the same reasoning anymore since we have UDA. Those will conflict with new keywords starting with an @.

True. Adding @blah now risks conflicts where it didn't before, but it still risks fewer conflicts that adding a keyword, since a keyword could be used anywhere, so adding blah as a keyword would conflict with all uses of blah - including @blah - whereas adding @blah would just conflict with @blah. There was also some discussion on how to make it so that @blah might not cause conflicts (via namespacing or somesuch), but I don't recall if anything came of that or how much of applies to the actual UDA implementation.

So, it makes more sense to go with adding an @ attribute than a keyword if we have to add a new attribute, because it'll conflict with less, but it's definitely true that we no longer have a way to avoid creating conflicts when adding attributes without altering the grammar in a manner similar to when we made it possible to have attributes starting with @. So, it's that much more important that we only add new attributes when we really need them.

- Jonathan M Davis
April 26, 2013
On Saturday, 20 April 2013 at 08:31:34 UTC, Brian Schott wrote:
> This uses ANTLR, as the other parser generators can't handle D's grammar.

I'm beginning to think that ANTRL is not up to the task either. I've somehow managed to get the grammar to the point where it correctly parses several phobos modules but takes a half hour to do so.