Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For..Next
#2
I think you perhaps have too much faith in our developers.  Our ability to generate and make an intellegent AI for the IDE isn't the same as what you'll find elsewhere where some company lie Microsoft can spend millions in paying whole teams of programmers to work on features.  Big Grin

Consider the way a lot of folks program, and then consider this scenario

FOR x = 0 TO _WIDTH
      PSET (x, y), foo


Now, here it'd make sense that there could only be an error for   FOR... WITHOUT NEXT.... FOR x.

But, let's keep typing a little more:

FOR x = 0 TO _WIDTH
    PSET (x,y) , foo
NEXT
PRINT "Hello World"

Error gone!  Life is good!


But now the user goes up and adds a new line of code:

FOR x = 0 TO _WIDTH
    FOR y = 0 TO _HEIGHT
        PSET (x,y), foo
    NEXT
    PRINT "Hello World"

Now, which NEXT is actually missing here?   They didn't write the code with NEXT x explicitly defined when they wrote that first FOR...NEXT previously.  Is it the x which is now left dangling without a NEXT?   Or is it the y, since they just inserted it into the code?

What is the user looking to produce at this point??    Is it:

FOR x = 0 TO _WIDTH
    FOR y = 0 TO _HEIGHT
        foo = foo + y
    NEXT
    PSET (x,y), foo
NEXT
PRINT "Hello World"


If so, then it was the y which was missing the NEXT.


OR were they writing something like this:

FOR x = 0 TO _WIDTH
    FOR y = 0 TO _HEIGHT
        PSET (x,y), foo
    NEXT
    PRINT "Hello World"
NEXT


If so, then it's the x which is missing the NEXT instead!



Personally, I wouldn't have a clue as to hazard a guess at which the end user might end up actually deciding they're wanting to use in their program -- but I have a feeling we'd just annoy a lot of folks if we said, "FOR... WITHOUT NEXT... FOR x", and we got it wrong and it was really their Y which didn't have that NEXT associated with it.

I can just see the post on the forums now:   "You dummies!! I just spent 327 hours trying to debug my code to find where my FOR Y loop was missing a NEXT, and it wasn't!!  I want my money back!!!   This is a total waste!!!  ARRAAAAGGGHHH!!!!!"

And thus we just keep the generic warning:

FOR.... WITHOUT NEXT....   whichever dang next that might be for ya!   Big Grin
Reply


Messages In This Thread
For..Next - by Dimster - 05-17-2024, 03:27 PM
RE: For..Next - by SMcNeill - 05-17-2024, 03:58 PM
RE: For..Next - by Dimster - 05-17-2024, 05:00 PM
RE: For..Next - by PhilOfPerth - 05-18-2024, 01:56 AM
RE: For..Next - by DSMan195276 - 05-18-2024, 04:28 AM
RE: For..Next - by Dimster - 05-18-2024, 01:09 PM
RE: For..Next - by Kernelpanic - 05-18-2024, 03:48 PM



Users browsing this thread: 6 Guest(s)