mIRC Homepage
Posted By: hixxy Choosing identifier scope - 24/10/05 05:04 PM
I think it'd be nice it we could change the scope an identifier is called in to the calling script, for example:

Code:
alias im return $::ifmatch
//if (x == y) echo -a $im


$im would be the same as $ifmatch, rather than $null because $ifmatch was called in the scope of the calling script, not the $im identifier.
Posted By: qwerty Re: Choosing identifier scope - 24/10/05 08:20 PM
In case of $ifmatch/$ifmatch2/$v1/$v2 it already works:

alias im return $ifmatch

//if (5 isnum) echo -a $im

($ifmatch is a sort of global variable, much like &binvars)

In fact I can't think of any case where this cannot be done the above way, except for $1, $2, $1- etc but who would want to make a replacement for them? They are as short as they can be already. Can you think of any other example where this would be useful?
Posted By: hixxy Re: Choosing identifier scope - 25/10/05 02:47 AM
Your post made me look at my code again. It was a stupid mistake on my part:

Code:
alias im return $ifmatch
alias test {
  if ([color:red]![/color]$1) echo -a $im
}


The ! shouldn't have been there.
Posted By: qwerty Re: Choosing identifier scope - 25/10/05 10:44 AM
Now I'm thoroughly confused. I never saw any "!" in any of your posts and I'm not sure how it fits in here. The code in your 2nd post works fine, but I don't see how it is an example of the usefulness of the proposed feature.
Posted By: Rand Re: Choosing identifier scope - 25/10/05 11:29 AM
I'm thinking perhaps hixxy realised that we're able to "return $ifmatch" hehe.. and just realised the code that he/she originally used, was the reason it didn't work. That's just my guess though..
Posted By: qwerty Re: Choosing identifier scope - 25/10/05 11:57 AM
Heh that does make perfect sense. Funny how sometimes you miss the obvious...
Posted By: hixxy Re: Choosing identifier scope - 25/10/05 12:26 PM
Spot on smile
© mIRC Discussion Forums