DB=me, RM=Raul Miller

DB>  To my mind, the  5!:5  representation of a complex J structure has
DB>  no advantages over the  3!:1  representation.

RM>  How would you write a verb which, given a locale name, 
RM>  returns a script which would redefine the current content 
RM>  of that locale, using  3!:1  ?

That begs the question.  I originally wrote:

DB>  That leaves you two options:  ASCII script files, and 
DB>  binary jfiles.

The question is which is representation is superior for a complex J data 
structure:  the ASCII script produced by  5!:5  or the binary jfile produced by 
 3!:1  .  

That is to say:  I would not produce a "script" with  3!:1  , I would produce a 
jfile.  So:

           NB.  This is your 'nams'
           nams   =:  3 :'(nl__y$0),&.>(''_'',''_'',~])&.>~y=.boxopen y'

           NB.  Keyfiles uses jfiles
           require'keyfiles'

           NB.  And jfiles uses  3!:1  
           j_rep_jfiles_
        3!:1


           save   =:  ([ keycreate)@:<@:] (5!:1@:] keywrite ,)"0 nams@:[
           rest   =:  < (] 4 : ('(x) =: y 5!:0';'1') :: 0:"0   keyread"1@:,.) 
keydir


Example use:
           
           NB.  Existing definition
           nams  
        3 : '(nl__y$0),&.>(''_'',''_'',~])&.>~y=.boxopen y'


           NB.  Save binary jfile
           'base' save jpath '~temp\base.jkf'

           NB.  Overwrite definition       
           nams =: 'banana'

           NB.  Confirm
           nams
        banana

           NB.  Restore previous definitions       
           rest jpath '~temp\base.jkf'
        1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

           NB.  Confirm 
           nams
        3 : '(nl__y$0),&.>(''_'',''_'',~])&.>~y=.boxopen y'
           
           
So we see that anything  5!:5  can do,  3!:1  can do.  

If you're chaffing at the use of  5!:1  in addition to 3!:1  , note that it is 
only necessary because you changed the specification from "save a noun" to 
"save an arbitrary part of speech".

But you can think of the  5!:1  representation of a J name as a "complex J data 
structure", which I asserted (and maintain) is suitably serialized by  3!:1   .

-Dan

PS:  See also the thread:

        http://www.jsoftware.com/pipermail/general/2007-January/028717.html

     but note that my definitions there themselves used  3!:1  , 
     which is redundant and inefficient given the later invocation
     of  j_rep_jfiles_  . 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to