Jump to content

UBound Return Discussion


JohnOne
 Share

Recommended Posts

I have been thinking about this for a couple of days now and I have to say that I am gratified to learn something new from JohnOne. Despite my efforts to rationalize the implementation in AutoIt (by means of what seemed to be the only reasonable explanation), it saddens me that things like this come up every once in a while. I would like to see AutoIt taken more seriously by the rest of the World. If only I had time to study, I would put in much more effort.

Conventions can be misleading and should never be followed blindly. By the same token, they should never be contravened without good reason. I guess it's too late to change the way Ubound works in AutoIt: doing so would break just about every script that's ever been written (ouch).

Edited by czardas
Link to comment
Share on other sites

I truly believe that the more AutoIt is brought inline with mainstream, the more coders it will attract, and I'd hope that's what everyone wants.

Thoughts going of topic, sorry.

End.

I'm with you all the way. Perhaps our little diversion could be split off to a new topic in Technical Discussion - from #249 onward.

Edited by czardas
Link to comment
Share on other sites

eh, this thread is a bag of dix anyway, I feel at home.  thread snipping has once again defeated meta comments on the thread itself.

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I have been thinking about this for a couple of days now and I have to say that I am gratified to learn something new from JohnOne. Despite my efforts to rationalize the implementation in AutoIt (by means of what seemed to be the only reasonable explanation), it saddens me that things like this come up every once in a while. I would like to see AutoIt taken more seriously by the rest of the World. If only I had time to study, I would put in much more effort.

Conventions can be misleading and should never be followed blindly. By the same token, they should never be contravened without good reason. I guess it's too late to change the way Ubound works in AutoIt: doing so would break just about every script that's ever been written (ouch).

Think out of the box, and you'd soon see that changes like that can be made without breaking any scripts. All that's needed are two things - awareness of the box and alarm clock set to 14.12.2016.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Hmm, changes to default behaviour are gonna break nearly everything, whatever size or shape the box is. I think element zero should be ditched and force LBound to be equal to 1. That would constitute progress IMO! All these mismatching counting systems are causing too many upsets. Damn those medieval Arabic scholars inventing zero! :huh2:

@JohnOne I used to play that piece very badly. :D

Edited by czardas
Link to comment
Share on other sites

Or If $array[0] always returned the correct ubound, and was not an element that could be set by the user?  Might as well make things hard for the devs :)

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Hmm, changes to default behaviour are gonna break nearly everything, whatever size or shape the box is. I think element zero should be ditched and force LBound to be equal to 1. That would constitute progress IMO! All these mismatching counting systems are causing too many upsets. Damn those medieval Arabic scholars inventing zero! :huh2:

@JohnOne I used to play that piece very badly. :D

In active development if you want to change the behavior of some function then introduce new function with the exact same functionality. In your case maybe ...ArraySize(). After period of soaking (one release ahead) remove all the references to the old function from the documentation while keeping it part of the language undocumented. That would give users enough time to adopt to the new function. Active users would soon start to simply replace all occurrences of the old function with the new one because the documentation for the old function would be gone. Then release again. Then let it soak more and (1 year later?) remove the old function from the language completely and make new release.
After that if you'd want you could add new function to the language - for example Ubound().

Would that break "nearly everything"?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Hah Indeed, disturbing the masses is the quickest way to get them to learn.   Script Breaking changes should be revealed in the console after you hit F5 not in the documentation before hand.  amirite?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Can you freeze a frog in a similar fashion.

I think you can only pretend to boil frogs, pretending to freeze them doesnt work

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I realise I'm coming to this discussion a bit late in the day. Think to the way languages such as C that don't have  a For ... Next method of looping the return UBound() makes perfect sense to me. When used in the equivalent while loop.

Local $a[100]
Local $i = 0
while $i < UBound()
    $something= $a[$i]
    $i += 1
wend

To find the highest addressable element in an array I simply created a wrapper for UBound many years ago and put it in a UDF of useful little functions that I include in just about every script. For me MaxAIndex() is now part of the AoutoIt language.

Func MaxAIndex($array)
 Return Ubound($array) - 1
EndFunc

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...