mIRC Home    About    Download    Register    News    Help

Print Thread
Arrays #8129 24/01/03 11:10 PM
Joined: Dec 2002
Posts: 25
S
SubSpace Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 25
I'm far from a mIRC expert, but I don't think I've overlooked...
I'd like to see support arrays in the script language, and maybe named collections too.

I want to avoid crappy code like this:

Code:
var %max = 3
var %i = 1
while (%i <= %max) {
  var %variable_ [ $+ [ %i ] ]
  inc %i
}


(which, I might add, violates the behaviour of most variable scoping rules in 'real' languages :tongue:)

Last edited by SubSpace; 24/01/03 11:11 PM.
Re: Arrays #8130 25/01/03 01:53 AM
Joined: Dec 2002
Posts: 774
T
theRat Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
this is a mIRC scripting language, not "real language"
Code:
var $+(%,joke,%i) = lol


use hash tables...


Code:
//if ( khaled isgod ) echo yes | else echo no
Re: Arrays #8131 25/01/03 02:05 AM
Joined: Dec 2002
Posts: 25
S
SubSpace Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 25
So? Just because it is a scripting language it can't have a basic feature like arrays? :P

Re: Arrays #8132 25/01/03 05:04 AM
Joined: Dec 2002
Posts: 56
G
Gon_ Offline
Babel fish
Offline
Babel fish
G
Joined: Dec 2002
Posts: 56
I don't know if ARRAYS should be added. I read somewhere that Khaled regards the mirc language most comparable to C. And this is a good thing, imo, while mIRC is easy and accessable to all, it does teach people some basic things about programming. I think this should be encouraged. I know that when I started coding a real language my past experience with mIRC benefited me a lot. If mIRC had arrays I would of took to the real language a lot faster too. I'm not saying it's khaleds job to foster up coming programmers, but i'm saying there's no harm in having a learning curve in mIRC, where newbies can go from variables - hashtables - arrays. No, it shouldn't try to evolve into a real language itself, as that is pointless . Why create something just like C and have it 1000 times slower and bound to an IRC client? So it's no more useful to newbies, and advanced programmers would use C.

Re: Arrays #8133 25/01/03 01:57 PM
Joined: Dec 2002
Posts: 39
L
Larra Offline
Ameglian cow
Offline
Ameglian cow
L
Joined: Dec 2002
Posts: 39
I think arrays should be added since they are a BASIC feature in every coding languaje.

Re: Arrays #8134 25/01/03 02:30 PM
Joined: Dec 2002
Posts: 25
S
SubSpace Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 25
Aye, but...

arrays alone would not really add much except for cleaner code, I suppose.. What I'd like to see along with array support is shift/unshift, push/pop and insert/delete functionality. Preferrably with multi-dimensional support or a way to put arrays into arrays.

Imagine if you were writing an fServe like script, how much cleaner the keeping of the transfer queue would be, for instance.

Also, a foreach statement would be nice, to iterate over all the array elements.

I know it seems a lot, but if this was added, it would really add something more to the language than a little cleaner coding: a LOT cleaner coding cool

Last edited by SubSpace; 25/01/03 02:31 PM.
Re: Arrays #8135 25/01/03 06:28 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
They wouldn't just be cleaner, they'd be faster. Remember mIRC has to parse

Your example of:

var %variable_ [ $+ [ %i ] ]

Would be array %variable

and then %variable[%i]

see how that is much easier to parse than having to worry about evaluation brackets, $+, etc. So it is cleaner, easier to read, and faster to parse... not really seeing a downside.

Re: Arrays #8136 25/01/03 07:33 PM
Joined: Dec 2002
Posts: 25
S
SubSpace Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 25
The downside is that Khaled would need to introduce a string representation for arrays, in case they are used with /set.. That will be kinda ugly, probably.

Also, I don't know if [ ] can be used to provide the index, since they're already used for the evaluation thing. I believe they require some spacing, but that is not a good way to differentiate.. %variable(%index) should be reasonably easy to parse though..

Re: Arrays #8137 25/01/03 11:00 PM
Joined: Jan 2003
Posts: 87
T
Tat Offline
Babel fish
Offline
Babel fish
T
Joined: Jan 2003
Posts: 87
//echo .... I am ...[ $ $+ me ]
If doing something along the line of nicks[1] would cause problems, then the me in that line would have to fully evaluate. The [] don't function if they they have a character directly juxaposed. Furthermore, I say mIRC needs to have arrays and for loops. These are pretty standard throughout most languages. And 'while' you only need one type of loop to do anything you need... It really would be nice to have a few more basic structures. I'm not going to start clammoring for stacks and queues or some basic database functionallity. arrays and for loops shouldn't be that hard. Heck you could modify a while loop and hash table and just 'say' that they are arrays and for loops pretty easily.

Tat

Re: Arrays #8138 26/01/03 02:55 AM
Joined: Jan 2003
Posts: 154
B
BoredNL Offline
Vogon poet
Offline
Vogon poet
B
Joined: Jan 2003
Posts: 154
the beauty of mIRC is that you can start simply with it, then move forward. There is not much of a learning curve to get started, whereas with all other programming languages, there is a lot more of a learning curve. To add more features to mIRC scripting isn't making things harder for newbies, but instead allowing advanced scripters to script more easily, and not have the guilt of being an 'unclean' scripter. lol

I for one hate unclean code.. It's just so.. inefficient..

The goal of any language for scripting or programming should be to create the most efficient script. For running, compiling or parsing, and lest not forget the person who is behind the script.. Creating the script itself should be a process which can be done efficiently. (easy, but has a lot of capabilities)


- Wherever you go there you are.[color:lightgreen]
Re: Arrays #8139 28/01/03 04:43 AM
Joined: Jan 2003
Posts: 87
T
Tat Offline
Babel fish
Offline
Babel fish
T
Joined: Jan 2003
Posts: 87
Heh, just noticed the while loop charge that it violates scope. It doesn't in most languages. The value declared in a function is scoped for the function. While loops lack independant scopes. For loops however have a scope. But, a varable scoped for a function could easily be used by a for loop with its own scoping just as a global could be used by a function...