semantics and syntaxes

This is a discussion on semantics and syntaxes within the C++ Programming forums, part of the General Programming Boards category; I'd like somebody to please explain the meaning of 'semantics' and 'syntaxes' as it relates to the C++ language using ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    10

    semantics and syntaxes

    I'd like somebody to please explain the meaning of 'semantics' and 'syntaxes' as it relates to the C++ language using English as reference...

    For example, write a phrase or sentence in english and tell me which is the semantic and which is the syntax. I want to beleive this is possible.

    Thank you very much for your time...

    Regards,
    'kk'

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    I'd like somebody to please explain the meaning of 'semantics' and 'syntaxes' as it relates to the C++ language using English as reference...
    Syntax:
    I - personal pronoun, the subject of the sentence
    'd like (= would like) - verb, the action
    somebody - the object of the sentence
    etc.

    Semantics:
    What you meant when you arranged those phrases like you did.

    Or ponder the Colourless green ideas
    Last edited by anon; 01-03-2008 at 01:14 PM.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    "add y to x"

    "x += y;"

    "x = x + y;"


    All three are semantically equal. They all mean the same. However, only the last two are syntactically correct C/C++. The first is syntactically correct english.

    Compared to an english test, if you have spelling mistakes or gramatical mistakes, it's syntax errors. If your text is perfect english, but doesn't express what you originally wanted to say, it has semantic errors.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You may want to study the Wikipedia site here: http://en.wikipedia.org/wiki/Semantics

    It has a specific area regarding "Computer Language" and Semantics.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21