Please check for syntax that doesn't make ANY sense

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Please show all syntax errors

Post by Little John »

PMV wrote:Bet i will. If fred adds such a warning for some cases, one case
will be a problem for me. He is only a human. Unbelievable,
of course for me too, but thats true. And thats the problem.
I don't understand what you mean. Are you saying that you think Fred will not be able to implement such an error check correctly?
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Please show all syntax errors

Post by PMV »

If you are not able to see such mistakes on your own, why
should other people be able to do really hard work without mistakes? :wink:

If he implements such a logic to check this cases to generate
the warnings like you want, doesn't you think he will make much
much more checks for many more case? And one or two of this
other cases could generate false-positives. :wink:
If he has done the work, it is not much more work to make it
deactivateable. :)

MFG PMV
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Please show all syntax errors

Post by Little John »

PMV wrote:If he implements such a logic to check this cases to generate
the warnings like you want, doesn't you think he will make much
much more checks for many more case?
Fred will probably make several changes to the compiler in the future. We cannot know what these will be.
This thread is only about the suggestion that I made here. And since you wrote
PMV wrote:I haven't done a mistake like this and i will not do it.
you will not notice any difference when my suggestion will be implemented.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Please show all syntax errors

Post by blueznl »

I do not understand the resistence. It is about adding a warning to CERTAIN commands which DEFINITELY require the use of return values.

As such, those commands that might be used otherwise would NOT trigger a warning.

How can such an additional help to the programmer thus cause false warnings??!?
( 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... )
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Please show all syntax errors

Post by Mistrel »

blueznl wrote:How can such an additional help to the programmer thus cause false warnings??!?
The request is so fundamental that it does not compute as a bug. :|

Also, I suspect this would only work for PureBasic commands and not user commands, since the resources spent by the compiler trying to define our logic would be a waste. But then it would be inconsistent. So why bother?

I can't support this without a way to quantify how much of a performance penalty there would be at compile time.

I can also imagine the warnings to be annoying.. just another window to close while pouring over test code. "Yes, yes, I know. I just didn't feel like commenting that line" and so fourth.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Please show all syntax errors

Post by PB »

Well, here's my view on this whole issue: it's much ado about nothing.
Somebody made a typo in their app, and didn't use a command in the
way the manual says. Now they want a compiler check added, which
will slow down compilation for everyone else because of their typo.
Shouldn't they just learn from their mistake, and not make it again?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Please show all syntax errors

Post by rsts »

You can probably make a case for some additional syntax checking

HOWEVER

I'd prefer they work on things that really advance the language capabilities and leave things like this to the programmers.

Someone want to write a syntax checker? Have at it. There are better uses for Fred's time and abilities.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Please show all syntax errors

Post by Little John »

blueznl wrote:I do not understand the resistence.
I don't understand it, too.
Mistrel wrote:The request is so fundamental
blueznl wrote:It is about adding a warning to CERTAIN commands which DEFINITELY require the use of return values.
Exactly. I don't consider that fundamental.
Mistrel wrote:Also, I suspect this would only work for PureBasic commands and not user commands,
Yes, that's the reason why my suggestion does only refer to built-in commands of PureBasic. :-)
Mistrel wrote:I can't support this without a way to quantify how much of a performance penalty there would be at compile time.
I doubt that this would make compilation much slower. If that would be the case, I suspect Freak would have mentioned it in his reply. The compiler has got many things to do anyway, this little extra check will probably only be a small percentage.
PB wrote:Somebody made a typo in their app, and didn't use a command in the
way the manual says. Now they want a compiler check added, which
will slow down compilation for everyone else because of their typo.
:lol:

When people try to execute e.g. the following code

Code: Select all

Dim x()
then PB will raise an error.
That's useless and ugly. The compiler shouldn't do such a check. I never made such a mistake, and I'm not going to make it. Why don't people just use the command in the way the manual says? Why does anyone need such a compiler check, which will slow down compilation for everyone else because of their typo? :lol:
PB wrote:Shouldn't they just learn from their mistake, and not make it again?
Oh, THE SOLUTION (TM): People should just stop making mistakes.
Why didn't anyone think of that before?
rsts wrote:There are better uses for Fred's time and abilities.
This is a valid argument. Please note that I neither consider my suggestion "fundamental", nor most important or something. I just wanted to make a small sugesstion, and was rather surprised when I saw what it triggered here. It's anyway Fred's and Freak's decision, how they prioritize all wishes, suggestions, and their own ideas.
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Please show all syntax errors

Post by PMV »

Little John wrote:When people try to execute e.g. the following code

Code: Select all

Dim x()
then PB will raise an error.
That's useless and ugly. The compiler shouldn't do such a check. I never made such a mistake, and I'm not going to make it. Why don't people just use the command in the way the manual says? Why does anyone need such a compiler check, which will slow down compilation for everyone else because of their typo? :lol:
Because this is a syntax-error -> the compiler can not create the executable
because it doesn't know which size the array will have. There is no special check
implemented for this. This is the result of a missing argument expected from
the compiler at this point.

Btw. i doesn't think the compilation would need much more time because of your wish. :)
Fred will probably make several changes to the compiler in the future. We cannot know what these will be.
And that is, why i made my wish. Thats all. :wink:

MFG PMV
Flower
User
User
Posts: 22
Joined: Fri Jan 08, 2010 8:05 am
Location: United States

Re: Please show all syntax errors

Post by Flower »

If all mainstream C/C++ compilers allow

Code: Select all

NULL;
and

Code: Select all

for(;;);
and

Code: Select all

i = i++;
Why would PureBasic forbids something that is much more sensible? :wink:
And, how many different logical errors could we check for?
Registered PureBasic user since 4.50
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Please show all syntax errors

Post by Little John »

Flower wrote:Why would PureBasic forbids something that is much more sensible? :wink:
I'm not talking about anything "that is much more sensible".
I'm talking about a particular kind of bugs in our programs. PB could help us to find them. This change in PB would not cause any disadvantage.

I kindly ask everyone, to read what I exactly suggested before "replying" here, and to stay on topic!
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Please show all syntax errors

Post by Mistrel »

But it isn't a bug. I mean, it's a logic error. But that's not really the same thing?

It's like comparing:
Whoops. Forgot to remove some old code from here.
vs.
Oh, crap. What the heck did I break now!? Nuclear meltdown in 10.. 9.. 8..
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Please show all syntax errors

Post by Little John »

Mistrel wrote:
Whoops. Forgot to remove some old code from here.
The problem is not forgetting to remove some old code.
The problem arises, when some code is missing.

The correct syntax for Mid() is e.g.

Code: Select all

s$ = Mid(s$, 3)
If the leading part

Code: Select all

s$ =
is missing, then it's not correct syntax anymore. Then s$ unintentionally will not be altered here.
Something like that happened to me by accident (probably when doing some cut and paste -- I don't remember exactly anymore). This was a bug in my program -- believe it or not.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Please show all syntax errors

Post by freak »

Little John wrote:The correct syntax for Mid() is e.g.

Code: Select all

s$ = Mid(s$, 3)
If the leading part

Code: Select all

s$ =
is missing, then it's not correct syntax anymore.
Sorry, but that is not true. All returnvalue assignments are optional in PureBasic. Both for procedures and library functions. Using Mid() without a returnvalue is correct syntax by current rules. Whether or not it makes sense is not the point. This is how the rules currently are.

What you are asking for here is a change of syntax rules, which is why it doesn't surprise me that people are resistent to the idea.
quidquid Latine dictum sit altum videtur
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Please show all syntax errors

Post by Little John »

freak wrote:Using Mid() without a returnvalue is correct syntax by current rules. Whether or not it makes sense is not the point. This is how the rules currently are.

What you are asking for here is a change of syntax rules, which is why it doesn't surprise me that people are resistent to the idea.
OK, I've changed the thread title from
Please show all syntax errors
to
Please check for syntax that doesn't make ANY sense
I'm still surprised why people are so resistent to the idea, since my suggested change will not have any negative effect for them.

Regards, Little John
Post Reply