Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this recommendation mean on InterSystem Russia's github coding guidelines (macro)?

Tags:

objectscript

These coding guidelines mention (rightfully so, I believe) to "[...]insert spaces after comma in functions/methods argument list".

Follows an example, but then this comes after:

For obvious reasons this recommendation not applies to arguments in $$$macro-call, where such extra spaces will break final result.

I'm not a seasoned ObjectScript developer, far from it, so out of curiosity I tried this:

ClassMethod foo()
{
    #define concat(%1, %2) %1 _ %2
    w $$$concat("foo", "bar"), !
}

And when executing this method it returns the "expected" result:

foobar

So, what are those "obvious reasons" this recommendation is referring to?

like image 703
fge Avatar asked Nov 30 '25 02:11

fge


1 Answers

Developers are lazy, and we are not an exception. While macro-definitions so flexible, I can write a lot interesting things, to simplify development process. You can see one of my examples here at github.

#define NewTempGN(%gn,%i) set %i=$i(^CacheTemp.MyApp),%gn=$name(^CacheTemp.MyApp(%i))

you can't add space after comma, because this space also will appear before variable, and such code may became illegal syntactically.

$$$NewTempGN(gn, ii)
#; transform to
set  ii=$i(^CacheTemp.MyApp),gn=$name(^CacheTemp.MyApp( ii))

One more example

#define forAll(%gn,%key) set %key="" for { set %key=$order(@%gn@(%key)) quit:%key=""
#define forEnd }

#; some global structure which you want to write
set gn=$na(^mtemp("test"))
set @gn@("val1")
set @gn@("val2")
set @gn@("val1")

#; and simple use with macro
$$$forAll(gn,val)
   write !,val
$$$forEnd
like image 142
DAiMor Avatar answered Dec 05 '25 07:12

DAiMor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!