ECompiler: for loop variable declaration (minor issue)

Archive of the older Feature Request Forum Posts
Locked
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

ECompiler: for loop variable declaration (minor issue)

Post by ncrsn »

Code: Select all

for (i := 5; i > 0; i -= 1)
    // Do stuff
endfor
This does no compile: "Variable i has not been declared on line N".

Code: Select all

for (var i := 5; i > 0; i -= 1)
Won't compile either: "Don't know what to do with 'var' in SmartParser::parseToken".

Code: Select all

var i;
for (i := 5; i > 0; i -= 1)
Works, but is not that cool looking.

Would be neat if compiler would either define the variable used in for loop if not yet defined or allow defining the variable in the beginning of the loop.
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

For the third code, the "Don't know what to do with 'var' in SmartParser::parseToken" is sometimes linked to what you had in the line before it like a missing ; or something.
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

Yeah, so, are you saying that error messages should be more specific?
User avatar
*Edwards
Forum Regular
Posts: 303
Joined: Fri Dec 28, 2007 11:19 pm

Post by *Edwards »

What ncrsn is trying to point is that instead of declaring a var used with "for" loop:

Code: Select all

var i
for( i:=x ...
The core could automatically "declare" i inside the "for" loop as a foreach loop.

Code: Select all

foreach thing in ...
"thing" doesn't have to be declared before the loop.

Atleast, that's how I understand the suggestion.
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

try this:

Code: Select all

for i := 0 to 5
  // Do stuff
endfor
I never have to declare and never have a problem.

And all I was pointing out before was that the error on the third try might have been a different error in his script on the line preceding what he put, not an error in what he put down.
Luth
Former Developer
Posts: 200
Joined: Mon Jan 30, 2006 8:10 am

Post by Luth »

... seriously? of all the things we have to fix, improve, and add....

....


seriously?


Image(lol)
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Post by OldnGrey »

Only when you run out of things to do of course.....
User avatar
itec
Novice Poster
Posts: 42
Joined: Thu Feb 09, 2006 11:48 pm

Post by itec »

The current logic for this is probably derived from C, where it works this way too. More then that, I'd like to see support for this:

for i := 5 to 1

Iterating backwards with this shorter version.
Luth wrote:... seriously? of all the things we have to fix, improve, and add....
And that's why we shouldn't talk about them? I can't see anything wrong with that. There's also a bunch of relevant bugs and feature suggestions that are waiting for a response from dev, (thanks to madman for going through a lot of these.)

edit. typo
Last edited by itec on Wed Apr 09, 2008 5:36 am, edited 2 times in total.
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

*Edwards wrote:The core could automatically "declare" i inside the "for" loop as a foreach loop.
Yes, that was my point.

To CWO:
Did you try compiling the code examples I wrote? If you had, you'd know the error messages were valid.

Using the for loop like you wrote is useful, yes, but sometimes it's not enough. And it does not change the way the more complex for loop works right now.

To Luth:
Your point is that because of your lack of time, things that aren't as important as some others should not be suggested? Is there a reason for this?

I did not say this is a must have in next release feature. Neither did anyone else. It's a shame you reacted like someone did. I'm sorry if this thread forced you to spend your valuable POL-time writing the post of yours and even googling the great image you had in it.

Not to mention all the really important threads that have no posts from devs but could need one more that this.
Madman
POL Developer
Posts: 62
Joined: Sun Feb 05, 2006 7:20 pm

Post by Madman »

Nah, make suggestions, worse thing is we'll say "no" or "no time now", and in that case I'll put it on the list at low priority and who knows, maybe someday someone will get bored of the hard stuff they're working on and do an easy, low priority one for giggles.
Luth
Former Developer
Posts: 200
Joined: Mon Jan 30, 2006 8:10 am

Post by Luth »

ncrsn wrote: To Luth:
Your point is that because of your lack of time, things that aren't as important as some others should not be suggested? Is there a reason for this?

I did not say this is a must have in next release feature. Neither did anyone else. It's a shame you reacted like someone did. I'm sorry if this thread forced you to spend your valuable POL-time writing the post of yours and even googling the great image you had in it.

Not to mention all the really important threads that have no posts from devs but could need one more that this.
Brilliant deduction, but couldn't have been further from the point. One should think the Oh-So-Serious picture I attached would have hinted at the attitude with which I made my statements, but as is all too often the case, it seems to have gone unnoticed. To be blatant: it was intended to show the innate humor of the suggestion, akin to picking out new drapery when there are two walls and half the roof missing, instead of criticizing the validity of the request.

But if devs can't post without you thinking they inherently speak with the Holy Righteousness and Authority of God, then so mote it be. Thanks for the compliment, really, but perhaps its best if you ignore everything I post from now on (including this one; ponder that paradox for awhile), as I don't see altering my personality or refraining from posting as viable alternatives. I'd hate to say something jokingly and start you on a Holy Jihad or something. You might tail Austin, though; he's as close to a fallen deity as anyone on this project.

In case anyone else was doubtful of my post, here's a completely bland reply that you can use to placate yourselves in the prior's stead:
Yes, I, too, would like the niceties of a more traditional for-loop. I'm sure this suggestion will be noted and attended in due fashion according to its assigned priority and the availability of developers.
Amen.
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

Neither am I willing to alter my behavior at your request. Instead I prefer changing for the better through learning.

I did think that you'd be a representative of POL development unless otherwise stated. To an end user like me (if there are any), things work out easier if one knows that if a dev says something, other devs will (officially) agree. And if someone in the team knows something related, others know that too. And so on. Naive as that might be.

That's why I missed the joke.

So I'll keep reading your posts and should I have something to say, I'll reply. Just like I did before.

But unless stated that one should, I try not to take your message as an official statement. Especially if it has a bit of humour in it.

When the time comes we'll see if I fail or do we both get on to laugh.

(edit: joke intented)
Luth
Former Developer
Posts: 200
Joined: Mon Jan 30, 2006 8:10 am

Post by Luth »

No, I'm not a policy maker, nor an authority of any sort, and have said as much in a couple other threads. I do not, and will not, speak for anyone else on the dev team, or anyone else for that matter. I'm merely "just another poster" and conduct myself as such. My title as "Developer" means just that, I write core server code; I'm a code junky, nothing more. Occasionally I inject my opinions into intra-staff discussions, but thats about as Authoritarian as I can claim to be. Had my title instead been "Member", I can assure you my post would be just as you see it. I found it funny, reading this forum, to go from "big" requests, like recent client compatibility, death hooks, and the like, to suddenly come across "I want a prettier for-loop." I chuckled. 8) Its a perfectly valid request, and I was not mocking its worth, merely its scope. I agree that it'd be nice to have a traditional for-loop, but the scale struck my funny bone, much like watching someone crush out a cigarette while the building burned down around him.
To an end user like me (if there are any), things work out easier if one knows that if a dev says something, other devs will (officially) agree.
In regards to this, one of us is naive. It may be me, and I may be reprimanded for such a blasphemous breach of protocol. If it is policy for devs to have a committee hearing before we are allowed to address the forums, then I was regretfully not informed. If such a policy does exist, and the other staff must now despairingly agree to the 11th Commandment I've thus written, in essence they are forced to agree that they find humour in the scope of this request only in comparison to the magnitude of rest of the posts on this forum. While not new to POL, I am new to this Most On High position. Even if that is a blunder on my part, men have been forced to conform to far worse, I'm sure, and I'll likely get off with only a mild beating. :D

*edit*
Did you hear about the cat that swallowed an entire ball of yarn? It gave birth to a litter of mittens.
Image(star trek lol)
Locked