View Full Version : What is the meaning of a naked type?
04-10-2011, 09:42 PM
The BNF allows for the following statement:
What is its meaning??
04-11-2011, 10:38 AM
Similarly, this is also legal syntax according to the BNF.
What is the meaning/purpose of a function prototype declared within a function??
The grammar is not a full description of valid shader code. There are semantic rules as well.
04-14-2011, 08:27 PM
Thanks... but this seems very sloppy language definition to me.
Why should syntax be allowed for which there is no valid semantic meaning?
These questions are motivated by the fact that I am writing a glsl compiler right now. Knowing that these constructions are meaningless I will probably tighten up the syntax.
04-14-2011, 09:44 PM
Just because the syntax matches the BNF doesn't mean that it has meaning.
Almost all language specs are like that. Take C++ for example; It pains me that I'm not allowed to write:
x ^= y ^= x ^= y ;
It's syntactically legal according to BNF but semantically it's totally illegal and gets you a compilation error. (Because the C++ spec says that you aren't allowed to change the value of a variable more than once in a single expression...a restriction that cannot be expressed in BNF).
I'll leave it as an "exercise for the reader" to figure out why that particular statement would be so useful (x and y are integers).
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.