Internal of ObjectScript -- source code of Standard Library
Hello,
I am interested about reading the source code of the primitives of the system. For example, I want to see how WRITE is implemented.
Can you help me to get a reflexive interrogation of the system ?
Kind regards,
Alin C Soare.
$ZV: IRIS 2024.1 for Windows 10
IRIS is NOT Open Source.
You may apply for engineering or support.
If you are hired you eventually may get some access to some source
Up to that you just have public documentation
😈
Hello @Alin Soare,
Can you give us more details on your needs and what you are unable to do?
The WRITE command is part of the basic instructions of IRIS (and even since the origin of the MUMPS language, pre-existing Caché, Ensemble, IRIS).
Hi,
The WRITE command, when passed no argument, does a reflexion on the system. I am not particularly interested about WRITE, but I want to learn how to do self-reflection on the system, to find out the system status, and for this the best source of inspiration could be the system itself. Apart from that, the source code of the system could be a source of inspiration for my own programs as well... Something like that Lisp or Smalltalk programmers do all the time...
Well, it simply list/write all defined variables in current stack level, something you can perform using standard Object Script commands and functions, no need to look at Write source code.
To do that you can use $order, $query, and indirection, with some trick needed for the variables you use to perform the listing, or, maybe simpler, you can use output redirection (to a string for example) and then...well, an argument less Write command 😊
Some hint for the first option:
USER>set a=1,b=2,b(1)=3,x=""
USER>set x=$order(@x)
USER>write x
a
USER>set x=$order(@x)
USER>write x
b
USER>set x=$query(@x)
USER>w x
b(1)
For output redirection, see IO Redirect in ObjectScript in Open Exchange.
Thank you. My point is, when I want to do something that I know that a predefined function already does, how can I get inspiration from its code about how to reproduce that behavior myself ?
On the other hand, are you sure that your method is that same that WRITE uses to interrogate the environment ?
Why should I care? Why do you care?
When the product isn't Open Source, you probably can't.
System Utility %ETN.int takes a snapshot with all actual variables somehow similar to WRITE command
Description: Using %ETN
It may give you some feeling how to analyze a running process.
ATTENTION:
reading requires some experience in ObjectScript
you might get lost
USER>s x=1, y=2, z=3, %="%"
USER>for {set % = $order(@%) quit:(%="") w !,%," ",@% }
x 1
y 2
z 3