Clifford Reiter wrote:
. . I hope ISI doesn't drop support for ws until their support for
. . scripts is rather complete. I.e., functions and objects
. . (included boxed) can be saved to a script by the system (I.e.,
. . we don't have to design the functions to do it).
I responded:
. Well, it isn't hard to design such functions using the current
. script and locale features.
Well, of course design and implementation are not necessarily the same
thing. I'm getting lots of core dumps [running J 7 on a Solaris
machine], and I don't really have a lot of use for load/save
emulation, so I'm just going to post what I've got so far...
It's incomplete, but maybe someone can get it working on some other
kind of machine. Hopefully, what I'm trying to do is clear enough
that any of my coding errors can be isolated.
Cautions: (1) This code may have errors.
(2) J has errors.
(3) the results of some of my analog functions aren't quite
what they should be for true emulation. I wasn't
planning on addressing this until I got the code
working.
(4) the analog functions are only designed to work in the
__ locale.
Good luck,
Raul D. Miller
<rockw...@nova.umd.edu>
NB. conjunctions
NB. bind -- f bind y is f@(y&[)@]
NB. adverbs
NB. emptily -- emptily result
NB. ing -- gerund form
NB. in_main -- action will be in locale __
NB. in_t -- action will be in locale _t_
NB. privately -- action will be in emptily locale _t_
NB. savews -- afterwords, save current locale in designated "ws"
NB. verbs
NB. allnames -- the name of every object in the current locale
NB. eraseall -- erase any kind of name
NB. from_t -- copy objects in locale _t_ to locale __
NB. makes -- build a script to define current locale
NB. nc -- name class in current locale
NB. nl -- name list in current locale
NB. prot_main -- remove from name list all names defined in locale __
NB. prot_t -- remove from name list all names defined in locale _t_
NB. sscript -- silent script in current locale
NB. to_t -- copy objects in locale __ to locale _t_
NB. write -- write to file
NB. wsnc -- analog to 2!:0
NB. wsnl -- analog to 2!:1
NB. wssave -- analog to 2!:2
NB. wspsave -- analog to 2!:3
NB. wscopy -- analog to 2!:4
NB. wspcopy -- analog to 2!:5
NB. wserase -- analog to 2!:55
NB. wsconvert -- convert old workspace format to new "script based" format
bind =:[. @ (&[) (@])
emptily =: ].(] (i.0 0)&[)
ing =: '{.x.`[':1
in_main =: f. ing (&('':(0 :4))) (&,) (&<)
$.=.1,(2+#y.),4
t__=:x.\ ([ 4!:55@((<'t')&[)) NB. 1
r=.t__>{.y. NB. 2 monadic fn
r=.(>{.y.)t__>{:y. NB. dyadic fn
r NB. 3 result
)
in_t =: f. ing (&('':(0 :4))) (&,) (&<)
$.=.1,(2+#y.),4
t_t_=:x.\ ([ 4!:55@((<'t')&[)) NB. 1
r=.t_t_>{.y. NB. 2 monadic fn
r=.(>{.y.)t_t_>{:y. NB. dyadic fn
r NB. 3 result
)
privately =: f. ing (&('':(0 :4))) (&,) (&<)
$.=.1 2 3,(4+#y.),1 2 6
t_t_=:(4!:55 +. 4!:56)@(4!:1) NB. 1
t_t_>:i.6 NB. 2 clear locale _t_
t_t_=:x.\ ([ 4!:55@((<'t')&[)) NB. 3
r=.t_t_>{.y. NB. 4 monadic fn
r=.(>{.y.)t_t_>{:y. NB. dyadic fn
r NB. 6 result
)
savews =:(`((makes write ])`])) \
allnames =:nl bind (>:i.6)
eraseall =:4!:55 +. 4!:56
from_t =:[ ".@(, '__=:'"_ , '_t_'"_)@>
makes =:;@:(((10{a.)"_ , ] , '=:'"_ , 5!:5@<)&.>)@allnames
nc =:4!:0
nl =:4!:1
prot_main =:-. (allnames in_main)
prot_t =:-. (allnames in_t)
sscript =:[ 0!:3
to_t =:[ ".@(, '_t_=:'"_ , '__'"_)@>
write =:1!:2
wsnc =:'':(nc@sscript privately)
wsnl =:(allnames@sscript privately) :(nl@sscript privately)
wssave =:((makes write ])in_main) :(to_t@sscript savews privately)
wspsave =:(allnames in_main$:]) :(to_t@prot_t@sscript savews emptily privately)
wscopy =:(0!:3 in_main) :(to_main@sscript emptily privately)
wspcopy =:(allnames in_main$:]) :(to_main@prot_main@sscript emptily privately)
wserase =:'':(eraseall@sscript savews privately)
wsconvert =:2!:4 savews emptily privately