PenUltima Online

It is currently Thu Aug 21, 2008 4:00 pm

All times are UTC - 4 hours




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: use also 0 as index in arrays?
PostPosted: Tue Nov 14, 2006 8:59 am 
Offline

Joined: Wed Aug 30, 2006 9:24 pm
Posts: 81
Location: Italy
about use also 0 as index in arrays?

_________________
Admin/Scripter Innominabile
ZuluHotelItalia shard on m4d


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 9:53 am 
Actually, I'd prefer to ONLY use 0-based indexes in arrays, despite the changes in code it would require. It's just more consistent, IMO, with other languages.

However, I actually think it may be a bad idea to offer both 0-and 1-based arrays, just due to the confusion that could ensue. As much as I might prefer to have 0-based arrays in eScript, at least I always know that arrays in eScript are 1-based now, and no one has to worry about bugs related to assuming the incorrect base.


Top
  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 1:30 pm 
Offline

Joined: Wed Aug 30, 2006 9:24 pm
Posts: 81
Location: Italy
I think that if you "Add" a new member it should start from 1.
Also in { member1, member2, ecc... should start from 1

But only allow array[0] fo force element index ad zero?

_________________
Admin/Scripter Innominabile
ZuluHotelItalia shard on m4d


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 5:07 pm 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 6:30 am
Posts: 383
Location: San Diego, California
You think a lot of things.. should be changed in POL.
Some good, most bad.
This is a bad one.
You're like a.. suggestaholic.

It doesn't do anything beneficial, it would just be work changing something
because... thats how it is in some other language you also like to use?
Really, what is a good reason to do something like this?

Time is better spent fixing the last few bugs in 097 and implementing suggestions that benefit everyone.

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 6:09 pm 
Offline

Joined: Sun Mar 05, 2006 11:25 am
Posts: 118
Location: Italy
This time I have to agree with Austin
Do you ever consider the consequences of such changes?
Most pol scripters would have to update thousands of scripts (yes, thousands, not even hundreds) to take into consideration arrays starting with 0 index and this... to have which benefit? This is a proposal who could have a meaning only when gathering ideas for a new emu. It's a nonsense for an emu with so many years of life


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 11:09 pm 
Yup... it would be bad, bad to change it, and there wouldn't be any measurable benefit at all. However, I don't think he was asking to change the base from 1 to 0, but to offer 0 as an option, in addition to 1.

But, I think that's an even worse idea!

:razz:


Oh, and Austin... suggestions are cheaper than beer :lol:


Top
  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 3:49 pm 
Offline

Joined: Wed May 10, 2006 9:15 pm
Posts: 113
I always wondered what 0 did... I always figured that if it was given a value, it would be given the length of the array or something. But using 0 as the start of an array would screw up how gump returns work in their entirety, who currently use 0 as the value returned.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 4:02 pm 
The results of trying to read array[0] are:

Code:
error {"errortext" := "Array index out of bounds"}


Trying to set it likely returns the same error to the debug log, if enabled. The read error is the same as it would be upon entering any invalid number for the array index. Attempting to write to an as-yet non-existent index on an eScript array just happens to have the special behavior of causing the array to expand, so there isn't really a comparable error for writing to positive index values. Not sure what eScript would do if you used a double type to pass a number larger than the likely 4-byte int limit of array indexes, but that's just going off the deep end :D


As for gumps, I actually think that it would be been terribly helpful had eScript started out with 0-based indexes for that, as a practical reason. As it is now, when inserting values into gump arrays, you have to adjust the eScript index into the array by one from the value you set in the gump layout information. That's been my main gripe with eScript arrays. BUT...... I just happen to think that changing it now would cause even more confusion and trouble.


Top
  
 
 Post subject: Re: use also 0 as index in arrays?
PostPosted: Sun Nov 19, 2006 4:31 pm 
Offline
POL Core Developer

Joined: Mon Jan 30, 2006 1:28 pm
Posts: 292
Location: Germany, Bavaria
innominabile wrote:
about use also 0 as index in arrays?

no

Shinigami


Top
 Profile  
 
 Post subject: Re: use also 0 as index in arrays?
PostPosted: Mon Nov 20, 2006 2:04 am 
Offline
POL Developer
User avatar

Joined: Mon Feb 13, 2006 1:50 am
Posts: 830
Location: Indiana, USA
Shinigami wrote:
no

Shinigami


Agreed

_________________
POL Developer - The Penguin Scripter


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 4 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl