dissect works as follows:
parse_dissect_ takes the string to be executed, parses it using the J
rules, and replaces each token with a sequence that saves the
intermediate results. So, if you looked at '1 2 + 3 4' each operand
would be saved, as well as each atom of the result.
parse_dissect_ returns that string, and ds executes it. It has to be
done this way so that the string will be executed in the same context
that ds was executed in. My hope is that someday dissect will be
integrated with debug so that when a sentence blows up ds will be called
automatically, in the context of the failing sentence. This is why ds
must be tacitly defined.
After execution, the results are all saved in locales created by
parse_dissect_, and ds calls display_dissect_ to show the result.
There is a fine point:
parse_dissect_ is running in its own locale, but it needs to know what
names were locally defined in the locale ds was executed in. That is
the job of z458095869_dissectnopath_ . dissectnopath is a locale that
has no path. Thus, listing the names in dissectnopath will show only
the local names (sc. nothing from z). These names are assembled into a
table and passed into parse_dissect_, where they are used during parsing.
[If you fix z458095869_dissectnopath_, you take it out of its special
locale, and it will pick up whatever names are lying around.]
Henry Rich
On 6/2/2013 9:32 AM, Raul Miller wrote:
I am trying to understand how ds (dissect.ijs addon) works
So I define a name with a rank, and ds properly shows that rank
avg=:(+/ %#)"1
ds 'avg p: i. 3 4'
And, I can take the definition of ds and plug it in, and that works
the same way:
ds
[: ([: (display_dissect_) 0:@". ::1:)`>@.(32 = 3!:0) [:
(parse_dissect_) 0&# :[ (([ ; 18!:5@(''"_) ; ]) ,
z458095869_dissectnopath_@(''"_)) ]
([: ([: (display_dissect_) 0:@". ::1:)`>@.(32 = 3!:0) [:
(parse_dissect_) 0&# :[ (([ ; 18!:5@(''"_) ; ]) ,
z458095869_dissectnopath_@(''"_)) ]) 'avg p: i. 3 4'
But when I try to get the result that has the rank of the name that I
defined, that is empty:
$z458095869_dissectnopath_''
0 3
But if I fix the definition, it works fine:
$z458095869_dissectnopath_ f.''
11 3
What's going on here?
Thanks,
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm