mIRC Homepage
Posted By: funfare brackets question - 16/03/17 12:05 AM
I understand brackets fairly well, but consider this intentionally flaky code:
alias test {
  echo -a a $+ [ $+ b c d e ]

this prints:
ac d e

i'm curious about what's going on which causes the 'b' to dissapear.
Posted By: Raccoon Re: brackets question - 16/03/17 06:05 AM
Somebody else could explain it better than I, but there are some hard to describe interactions with evaluation brackets and concatenation. However, in practice, the formula that gets used the most looks like this:

a [ $+ [ b ] $+ [ c ] ]

as in

set -e %foo. $+ $cid $+ $chan Hello World.
echo -a %foo. [ $+ [ $cid ] $+ [ $chan ] ]

same as

set -e $+(%,foo.,$cid,$chan) Hello World.
echo -a $($+(%,foo.,$cid,$chan),2)

Posted By: Khaled Re: brackets question - 17/03/17 11:20 AM
The [ ] brackets force evaluation of items inside the brackets before items outside of them can be evaluated.

In this case, $+ [ $+ b ] is saying: append b to the $+ outside of [ before it can be evaulated. This results in $+b.

$+anything is treated as $+ (which I think has always been the case).
Posted By: funfare Re: brackets question - 19/03/17 09:07 PM
interesting, thanks khaled.
© mIRC Discussion Forums