Yes!freak wrote:If anything, this could be a warning not an error.
Please check for syntax that doesn't make ANY sense
Re: Please show all syntax errors
C provides the infinitely-abusable goto statement, and labels to branch to. Formally, the goto is never necessary, and in practice it is almost always easy to write code without it. We have not used goto in this book. -- K&R (2nd Ed.) : Page 65
Re: Please show all syntax errors
I also agree with the warning.
I can't tell you how many logical warnings I must signal to users...the demands of a flexibile application.
I can't tell you how many logical warnings I must signal to users...the demands of a flexibile application.

Re: Please show all syntax errors
Computers are not particularly good at knowing when things make sense or not.My wish refers only to internal functions such as Mid(), where ignoring the return value doesn't make any sense.
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Please show all syntax errors
Yes, I agree.freak wrote:The compiler has to be consistent in its error reporting. Otherwise it just creates confusion.Little John wrote:My wish refers only to internal functions such as Mid(), where ignoring the return value doesn't make any sense. Implementing my wish will not cause any disadvantage to the PB programmer.Trond wrote:And there are many functions where the return value is not always needed. What would you do about those?
From the documentation, and from a proper error message.freak wrote:How is a beginner supposed to know that for function X the returnvalue is always needed and for function Y it can sometimes be ignored?
Not necessarily. And I think the risk that this will happen is pretty small.freak wrote:For him it will just look like the compiler is missing an error.
Error messages generated by the compiler could read like this:
These error messages will be consistent, the user will always get the same message for the same error. And the message clearly tells to which function it refers. Actually, this principle is not new to PB, e.g.:The result of Mid() must be assigned or used.
The result of FindString() must be assigned or used.
etc ...
Code: Select all
NewMap x.i(1024) ; OK
NewMap y.i() ; OK
Dim z.i() ; Syntax error
And e.g. when using OpenWindow(), assigning or using the result is optional, as opposed e.g. to Mid(), where assigning or using the result will be mandatory (according to my suggestion). So IMHO nothing that is strange to PureBasic or confusing will be introduced by this suggestion.
Re: Please show all syntax errors
What about ReplaceString()?
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Please show all syntax errors
Using the result of ReplaceString() is optional.Trond wrote:What about ReplaceString()?
Re: Please show all syntax errors
Quite the contrary. If the replace produces a new string (default option) the result must be used, if the replace is done in place (an option) the result must be ignored. So in neither case is it optional, it depends on the parameters.Little John wrote:Using the result of ReplaceString() is optional.Trond wrote:What about ReplaceString()?

-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Please show all syntax errors
Sorry, I'm not a native English speaker. With "optional" I mean: "Not always required."
Since it depends on the parameters, using the result of ReplaceString() is not always required.
Since it depends on the parameters, using the result of ReplaceString() is not always required.
Re: Please show all syntax errors
If you really plan to implement such a warning message, i hope you
make it optional. I does not need a compiler, who says to me what
is logical and what not ... it would be really annoying if there would
be always a warning where is nothing.
It is true, a perfect programmed code must use each result to check,
if there is an error or not. But PB is not supposed to be only for
clean code, it is used to create little fast results, too.
MFG PMV
make it optional. I does not need a compiler, who says to me what
is logical and what not ... it would be really annoying if there would
be always a warning where is nothing.
It is true, a perfect programmed code must use each result to check,
if there is an error or not. But PB is not supposed to be only for
clean code, it is used to create little fast results, too.

MFG PMV
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Please show all syntax errors
I'm pretty sure you won't get always a warning, because you don't have always lines such asPMV wrote:... it would be really annoying if there would
be always a warning where is nothing.
Code: Select all
Mid(s$, 7)
FindString(a$, b$, 1)

And in case that is in the code: It's not nothing, but it's garbage.
Sorry, it seems you didn't get my point.PMV wrote:It is true, a perfect programmed code must use each result to check,
if there is an error or not.
I'm not asking for using each result. But what is the purpose of using Mid() or FindString() and ignoring their results

Re: Please show all syntax errors
I really don't follow this post at all. It's the programmer's responsibility to not make a mistake like this. I certainly wouldn't want to waste precious seconds because the compiler wants to try and tell ME how to write my logic.
Re: Please show all syntax errors
For a change I see the point of the requester. Why not use the compiler's help to avoid stupid mistakes? We all make them... (Hell, I even am married!)
I would like it if the compiler would throw a warning if a statement is used which would not make sense if the return value isn't used for anything. Obviously only for those specific statements. If there is an alternate syntax (ReplaceString etc,) or if the statement could be used without the need for a return value (OpenWindow for example) then there's no warning to be thrown.
Again, whenever the language / compiler can help the programmer it is good, even programmers make mistakes! (Did I mention I also have kids?)
I would like it if the compiler would throw a warning if a statement is used which would not make sense if the return value isn't used for anything. Obviously only for those specific statements. If there is an alternate syntax (ReplaceString etc,) or if the statement could be used without the need for a return value (OpenWindow for example) then there's no warning to be thrown.
Again, whenever the language / compiler can help the programmer it is good, even programmers make mistakes! (Did I mention I also have kids?)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Please show all syntax errors
I haven't done a mistake like this and i will not do it.Little John wrote:Sorry, it seems you didn't get my point.PMV wrote:It is true, a perfect programmed code must use each result to check,
if there is an error or not.
I'm not asking for using each result. But what is the purpose of using Mid() or FindString() and ignoring their results
You shouldn't write programs while you are drunk.

I get your point, but like i posted, i doesn't want a compiler who
says me what is logical and what not. If i need some from this sort,
i will use a (strikt) OOP-language.

That is my point, nothing more.

MFG PMV
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Please show all syntax errors
@blueznl:
Thanks for your post! I'm really happy that here are at least a few people who understand the problem.
But for average people like me, such an error check can help to prevent bugs.
Thanks for your post! I'm really happy that here are at least a few people who understand the problem.

Then you will not notice any difference, when such an error check is built into the compiler. So what is your problem?PMV wrote:I haven't done a mistake like this and i will not do it.
But for average people like me, such an error check can help to prevent bugs.
Re: Please show all syntax errors
Bet i will. If fred adds such a warning for some cases, one caseLittle John wrote:Then you will not notice any difference, when such an error check is built into the compiler. So what is your problem?
will be a problem for me. He is only a human. Unbelievable,
of course for me too, but thats true. And thats the problem.
If this feature is deactivate able ... i have no problem. Thats what
i have written.

MFG PMV