Results 1 to 5 of 5

Thread: What is the meaning of a naked type?

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    3

    What is the meaning of a naked type?

    The BNF allows for the following statement:

    int;

    What is its meaning??

  2. #2
    Junior Member
    Join Date
    Apr 2011
    Posts
    3

    Re: What is the meaning of a naked type?

    Similarly, this is also legal syntax according to the BNF.

    Code :
    void main(){
          int a=3;
          void bar();
          a+=2;
    }

    What is the meaning/purpose of a function prototype declared within a function??

  3. #3
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: What is the meaning of a naked type?

    The grammar is not a full description of valid shader code. There are semantic rules as well.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  4. #4
    Junior Member
    Join Date
    Apr 2011
    Posts
    3

    Re: What is the meaning of a naked type?

    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.

  5. #5
    Senior Member
    Join Date
    May 2010
    Posts
    207

    Re: What is the meaning of a naked type?

    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:
    Code :
       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).

    -- Steve

Similar Threads

  1. Replies: 3
    Last Post: 05-13-2008, 10:29 AM
  2. Replies: 3
    Last Post: 01-01-1970, 12:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •