Offtopic from: Minor bug in which 'syntax error' is reached

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
luis
Addict
Addict
Posts: 3894
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Offtopic from: Minor bug in which 'syntax error' is reached

Post by luis »

This topic has been split from here: http://www.purebasic.fr/english/viewtop ... =4&t=62312
freak wrote: Yes, the error in question is a semantic error, not a syntactic one.

That's what I would have expected him to say after my first question.

But I think the fact this is a semantic error and not a syntax error is a little debatable IMHO, that's why I wrote this -> http://www.purebasic.fr/english/viewtop ... 33#p465633

For a programming language the sum of lexical and syntactical properties is a set of rules that defines the set of valid symbols and the ways they can be combined together to construct a valid, complete program or a just a code fragment in that language.

So, for example

Code: Select all

Debug c\cil\ma
has a valid syntax in the PB language, as a code fragment. You can't say it's wrong. It does respect the syntax.

But if you add further information to that fragment, like for example:

Code: Select all

Structure X
  cil.f
EndStructure

Define c.X

Debug c\cil\ma
than you discover there is an error in this complete program. Based on the new info not available before, the syntax is now wrong.

I would say the syntax is wrong because there is no semantic whatsoever in that code. It has no meaning. Its incoherent syntax, while formally valid line per line in a vacuum, is not valid as a whole, preventing you to derive any meaning from it.
What does it mean ? What could it mean ? You can't say it. It's broken. To me that is more a syntax error than a semantic one.
The compiler is not able to generate code for the above code, because the syntax is wrong and can not be translated to code.

Other times you have some kind of what I would call a semantic error, where you try to add a string to a number for example. In some language this can have an intrinsic semantic wrongness, the syntax could be valid but the semantic wrongness is big enough to stop the compiler from generating code.
In another language the compiler can assume from the semantic of the code maybe you would like to have them converted to a common type where the operation is possible. Other times is the programmer to make that explicit through some form of casting. That's all semantics.

On top of that you can have some kinds of semantic errors resulting in valid compilable code without any second guessing from the compiler but resulting in possible problems: data loss, loss of precision, etc.

These often results in the emission of warnings. This is potentially bad, unwanted semantic.

Anyway... where to place what involves some grey areas... after all these are all artificial separations, and different compilers may put similar errors in different categories depending on how they approach the problem of extracting meaning from the source code.

Here we are talking luxury. PB often could be more specific when reporting errors, this is one case: "cil is not a structure"
Instead you just understand something is wrong (in your code hopefully) and start looking closely at that line and its dependencies.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
TI-994A
Addict
Addict
Posts: 2704
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Minor bug in which 'syntax error' is reached

Post by TI-994A »

freak wrote:
Psychophanta wrote:This way a "syntax error" is reached in a command where no real syntax error exists:
Yes, the error in question is a semantic error, not a syntactic one.
So, just a miscommunication after all. The OP was simply trying to allude to an inappropriate error message.

In retrospect, the ambiguity of the post is the real cause of this confusion, along with the cocky attitude of the poster, who, instead of clarifying the situation, only decided to mock the good intentions of the misguided answers. Shame on you, Psychophanta. :lol:

Bottom line, illegal as the operation might be, the code is still syntactically sound. As freak has said, it's indeed a semantical error.

No amount of fancy footwork or huffing & puffing is going to change that. :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
luis
Addict
Addict
Posts: 3894
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Minor bug in which 'syntax error' is reached

Post by luis »

My last words: I may vomit.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
TI-994A
Addict
Addict
Posts: 2704
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Minor bug in which 'syntax error' is reached

Post by TI-994A »

luis wrote:My last words: I may vomit.
If those are your last words, you've lived a very sad life. :lol:

Nevertheless, your dying declarations are still...Image
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Minor bug in which 'syntax error' is reached

Post by freak »

TI-994A wrote:
freak wrote:
Psychophanta wrote:This way a "syntax error" is reached in a command where no real syntax error exists:
Yes, the error in question is a semantic error, not a syntactic one.
So, just a miscommunication after all. The OP was simply trying to allude to an inappropriate error message.

In retrospect, the ambiguity of the post is the real cause of this confusion, along with the cocky attitude of the poster, who, instead of clarifying the situation, only decided to mock the good intentions of the misguided answers. Shame on you, Psychophanta. :lol:
The original post isn't that ambiguous. From my perspective, it looks more like you people were actively trying to stir up an argument.

Anyway, since this is in Offtopic now... have fun with it. :wink:
quidquid Latine dictum sit altum videtur
User avatar
TI-994A
Addict
Addict
Posts: 2704
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Minor bug in which 'syntax error' is reached

Post by TI-994A »

freak wrote:...it looks more like you people were actively trying to stir up an argument.
Just good, clean fun. Although some people are just so touchy. :lol:
freak wrote:...have fun with it. :wink:
Thank you, Timo. :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply