PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
ECompiler: for loop variable declaration (minor issue)

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
ncrsn



Joined: 10 Feb 2006
Posts: 107

PostPosted: Mon Apr 07, 2008 11:03 pm    Post subject: ECompiler: for loop variable declaration (minor issue) Reply with quote

Code:
for (i := 5; i > 0; i -= 1)
    // Do stuff
endfor


This does no compile: "Variable i has not been declared on line N".

Code:
for (var i := 5; i > 0; i -= 1)


Won't compile either: "Don't know what to do with 'var' in SmartParser::parseToken".

Code:
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.

Author Message
CWO



Joined: 04 Feb 2006
Posts: 677
Location: Chicago, IL USA

PostPosted: Tue Apr 08, 2008 5:11 am    Post subject: Reply with quote

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.

Author Message
ncrsn



Joined: 10 Feb 2006
Posts: 107

PostPosted: Tue Apr 08, 2008 5:29 am    Post subject: Reply with quote

Yeah, so, are you saying that error messages should be more specific?

Author Message
*Edwards



Joined: 29 Dec 2007
Posts: 61
Location: Montreal, Canada

PostPosted: Tue Apr 08, 2008 6:07 pm    Post subject: Reply with quote

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

Code:
var i
for( i:=x ...


The core could automatically "declare" i inside the "for" loop as a foreach loop.

Code:
foreach thing in ...


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

Atleast, that's how I understand the suggestion.

Author Message
CWO



Joined: 04 Feb 2006
Posts: 677
Location: Chicago, IL USA

PostPosted: Tue Apr 08, 2008 6:33 pm    Post subject: Reply with quote

try this:

Code:
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.

Author Message
Luth
POL Developer


Joined: 03 Oct 2007
Posts: 21

PostPosted: Tue Apr 08, 2008 9:53 pm    Post subject: Reply with quote

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

....


seriously?


(lol)

Author Message
OldnGrey



Joined: 04 Feb 2006
Posts: 500

PostPosted: Tue Apr 08, 2008 11:27 pm    Post subject: Reply with quote

Only when you run out of things to do of course.....

Author Message
itec



Joined: 10 Feb 2006
Posts: 33
Location: Finland

PostPosted: Wed Apr 09, 2008 2:38 am    Post subject: Reply with quote

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 9:36 am; edited 2 times in total

Author Message
ncrsn



Joined: 10 Feb 2006
Posts: 107

PostPosted: Wed Apr 09, 2008 8:23 am    Post subject: Reply with quote

*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.

Author Message
Madman
POL Developer


Joined: 05 Feb 2006
Posts: 30

PostPosted: Sun Apr 13, 2008 4:33 pm    Post subject: Reply with quote

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.

Author Message
Luth
POL Developer


Joined: 03 Oct 2007
Posts: 21

PostPosted: Wed Apr 16, 2008 3:16 pm    Post subject: Reply with quote

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:
Quote:
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.

Author Message
ncrsn



Joined: 10 Feb 2006
Posts: 107

PostPosted: Wed Apr 16, 2008 5:28 pm    Post subject: Reply with quote

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)

Author Message
Luth
POL Developer


Joined: 03 Oct 2007
Posts: 21

PostPosted: Wed Apr 16, 2008 6:33 pm    Post subject: Reply with quote

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. Cool 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.

Quote:
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. Very Happy

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

Post new topic   Reply to topic    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty