User bio
404 bio not found
Member since Jul 25, 2017
Posts:
Replies:
If you want to work with class parameters, you can choose between two basic variants
Parameter GlobalName1 = "^Global";
Parameter GlobalName2 = {$name(^Global)};
ClassMethod Test()
{
set @$name(@..#GlobalName1)@("index")="abc" // using variante 1
write @..#GlobalName2@("index") // using variante 2
}
If you have set the "handling of undefined" settings to 2 then in either case (you set x to a nullstring OR x is undefined) in statements like
if $d(@x@(whatever))
set d=$d(@x@(whatever))
you get a <SYNTAX> error, because nullstring (the value of x) is not a valid name for a local or global variable.
In a terminal session issue the following commands and check each output with mine:
kill // kill all local variables
write x="" // the output is 1 (because of your setting)
if $d(@x) // the output is a <SYNTAX> because "" is not a valid name
set d=$d(@x) // the output is a <SYNATX> because "" not a valid name
If your output is different from the above, than please contact the WRC
My $ZV is IRIS for UNIX (Ubuntu Server LTS for x86-64) 2021.2 (Build 649U) Thu Jan 20 2022 08:49:51 EST
Certifications & Credly badges:
Julius has no Certifications & Credly badges yet.
Global Masters badges:







Followers:
Following:
Julius has not followed anybody yet.
First, measuring execution times on modern operating systems where multiple processes run in parallel (on multiple CPUs) is challenging. The following demo application assigns a value to a variable in four different ways:
– in a single method
– in two methods, both in the same class
– in two methods where one method code is in an inherited class, and
– in two methods where one method is in a different class
As expected, the first is the fastest (keyword: loop unrolling) and the last is the slowest, the other two take about the same time.
Class DC.Times Extends (%RegisteredObject, TimesAbstract) { ClassMethod ShowTimes() { while $zh#1 {} set t1=$zh for i=1:1:1E6 { do ..Complete() } set t1=$zh-t1 while $zh#1 {} set t2=$zh for i=1:1:1E6 { do ..OneClass() } set t2=$zh-t2 while $zh#1 {} set t3=$zh for i=1:1:1E6 { do ..InhClass() } set t3=$zh-t3 while $zh#1 {} set t4=$zh for i=1:1:1E6 { do ..TwoClass() } set t4=$zh-t4 write $j(t1,9,5), $j(t2,9,5), $j(t3,9,5), $j(t4,9,5),! } /// The complete application is carried out in one method ClassMethod Complete() { set x=12345 set y=12345 } /// The entire application is done in the same class, but with different methods /// Both methods are local (OneClass + LocTask) ClassMethod OneClass() { set x=..LocTask() set y=..LocTask() } /// The entire application is done in the same class, but with different methods /// One method is local (InhClass) the other is inherited (InhTask) ClassMethod InhClass() { set x=..InhTask() set y=..InhTask() } /// The entire application uses two methods in two different classes ClassMethod TwoClass() { set x=##class(DC.Times2).ExtTask() set y=##class(DC.Times2).ExtTask() } /// As an "application" we simply return a constant value ClassMethod LocTask(val) { quit 12345 } } Class DC.Times2 Extends %RegisteredObject { /// As an "application" we simply return a constant value ClassMethod ExtTask(val) { quit 12345 } } Class DC.TimesAbstract [ Abstract ] { /// As an "application" we simply return a constant value ClassMethod InhTask(val) { quit 12345 } }
Some time values
USER> USER>f i=1:1:3 d ##class(DC.Times).ShowTimes() 0.10833 0.19660 0.19649 0.22001 0.10837 0.19657 0.19608 0.22000 0.10826 0.19661 0.19603 0.21992 USER> USER>f i=1:1:3 d ##class(DC.Times).ShowTimes() 0.10998 0.19711 0.19643 0.22006 0.10830 0.19657 0.19624 0.22013 0.10822 0.19684 0.19628 0.22139 USER> USER>w $zv IRIS for UNIX (Ubuntu Server 22.04 LTS for x86-64) 2025.1 (Build 225_1U) Fri May 16 2025 12:18:04 EDT USER>
Second, the choice of development method (use of include files, class inheritance, multiple classes, a large method in an even larger class, etc.) depends on other factors such as maintainability, runtime priority, etc.