D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5803 - Inaccuracies in the specification of the grammar
Summary: Inaccuracies in the specification of the grammar
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: Other Windows
: P3 normal
Assignee: No Owner
URL:
Keywords: bootcamp, spec
Depends on:
Blocks:
 
Reported: 2011-03-30 23:03 UTC by Rainer Schuetze
Modified: 2024-12-15 15:21 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Rainer Schuetze 2011-03-30 23:03:45 UTC
The language definition has a number of smaller and larger inaccuracies. You can find a comparison chart of the grammar in the docs and a grammar used to parse the public test suite and the runtime library (minus some deprecated features) here:

http://www.dsource.org/projects/visuald/wiki/GrammarComparison

This is with respect to the state of the documentation in December 2010, so a few additions and modifications have already made it into the current documentation.
Comment 1 Don 2011-03-31 03:05:48 UTC
One fairly big mistake in there: there seems to be confusion between StructLiteral and StructStaticInitializer. 

Foo z = { x: 7, y: 56};
is a struct static initializer, not a struct literal.
Foo(7, 56); is a struct literal.
Comment 2 Trass3r 2011-03-31 04:22:11 UTC
I'm already working on folding some of the changes I agree with into my github fork @ https://github.com/Trass3r/d-programming-language.org

Will push soon.
Comment 3 Rainer Schuetze 2011-03-31 12:01:27 UTC
(In reply to comment #1)
> One fairly big mistake in there: there seems to be confusion between
> StructLiteral and StructStaticInitializer. 

Maybe I oversimplified here, but I was hoping for a generalization of the array/struct initializer and literals. 

IIRC the StructStaticInitializer is said to be deprecated anyway, but it might actually be possible to interpret it as a literal inside expressions with implicite conversions, similar how dmd deals with arrays, because the parser cannot decide which type of array a variable is declared as until the semantic pass.
Comment 4 Don 2011-03-31 13:11:27 UTC
(In reply to comment #3)
> (In reply to comment #1)
> > One fairly big mistake in there: there seems to be confusion between
> > StructLiteral and StructStaticInitializer. 
> 
> Maybe I oversimplified here, but I was hoping for a generalization of the
> array/struct initializer and literals. 
> 
> IIRC the StructStaticInitializer is said to be deprecated anyway, but it might
> actually be possible to interpret it as a literal inside expressions with
> implicite conversions, similar how dmd deals with arrays, because the parser
> cannot decide which type of array a variable is declared as until the semantic
> pass.

They have very different semantics. Given only a StructLiteral, you can always work out what type it is. But with a static initializer, you know nothing. This might be the only thing in the language like that. It's not implicit conversion, they don't have an initial type to convert from.

So  auto x = StructLiteral();  works, but auto x = structStaticInitializer cannot. Consequently, you can use a struct literal almost anywhere you can use a struct variable.

I've tried to get them deprecated but I don't know if that will happen. They are one of the most complicated things in the language, and the implementation is *full* of bugs.
Comment 5 berni44 2019-12-17 18:04:33 UTC
Is this still valid?
Comment 6 Rainer Schuetze 2019-12-17 19:44:52 UTC
I haven't looked through the full diff, but the very first two lines are still valid: both the module declaration and the other declarations are optional which isn't covered by the grammar found in the language spec.
Comment 7 dlangBugzillaToGithub 2024-12-15 15:21:46 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dlang.org/issues/4014

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB