> This all means that I should probably implement a serializer in J source. > Maybe 5!:7? (In my "copious free time...").
@Raul If you do find time to implement a serializer you may (/ may not?) find it helpful to glance at the code in lobrow.ijs (the newer one) at: http://www.jsoftware.com/jwiki/IanClark/LoBrow. Particularly the verb: namepick2ijs -which I use routinely to dump the contents of an arbitrary locale to a j-script. Conversely, if you know how to defeat namepick2ijs then of course I'd like to know. Admittedly it outputs j-words for re-input by (0!:*) not (".). And it's cleverer at nouns than at non-nouns, aiming to produce a readable script. Thus it outputs L, originated as: L=: 'able',LF,'baker' as: L=: }: 0 : 0 able baker ) rather than: 5!:5 <'L' 97 98 108 101 10 98 97 107 101 114{a. I hope it saves you time and doesn't set you back. It's served me well this past year or so. (But maybe the code I encounter isn't all that challenging...?) On Sun, Feb 19, 2012 at 4:20 PM, Raul Miller <rauldmil...@gmail.com> wrote: > The undocumented behavior of 5!:5 is: that I have assumed that linear > representation of nouns is a serialized representation. > > In other words, if I create a multi-paragraph 0 :0 noun, the dictionary > does not guarantee that it will give me an executable representation of > that noun -- hypothetically speaking, the interpeter could use the same > kind of representation technique that it uses for large multi-line explicit > verbs. > > This all means that I should probably implement a serializer in J source. > Maybe 5!:7? (In my "copious free time..."). > > FYI, > > -- > Raul > > On Sat, Feb 18, 2012 at 4:09 PM, Dan Bron <j...@bron.us> wrote: > >> Neat application! >> >> What behavior of 5!:5 do you use here, that is undocumented? The question >> of whether the behavior you observed in `:6 here, hinges on the definition >> of "gerund", and the fact that you can do just this is one reason why I >> defined it as I did. Moreover, this behavior is consistent, as you replace >> `:6 with (e.g.) @.0 in your utility, with the same results. >> >> -Dan >> >> -----Original Message----- >> From: programming-boun...@jsoftware.com [mailto: >> programming-boun...@jsoftware.com] On Behalf Of Raul Miller >> Sent: Saturday, February 18, 2012 3:10 PM >> To: Programming forum >> Subject: [Jprogramming] serialization, in J >> >> In another thread, I was struggling to discuss issues which conflicted >> with the topic. >> >> So... I am making a new topic: �Given a nameable entity, in J, >> construct a list of characters that can be used in ". to recreate that >> nameable entity. � (A nameable entity, in J, is something that can be >> enclosed in parenthesis and still be syntactically valid.) >> >> This mechanism is very like the "serialization" that I use in other >> languages, so I will call it "serialization". >> >> Serialization is very like J's linear representation, but not quite. >> The problem with linear representation, is that it's not always valid >> for ". >> >> Here's an example of the reason we cannot use linear representation >> (5!:5) for serialization: >> >> � ".'copyoflist=.',5!:5<'list_z_' >> |spelling error >> >> Or, more formally: >> � ".'copyoflist=.(',(5!:5<'list_z_'),')' >> |spelling error >> >> 5!:5 does not always generate a character sequence which is valid >> between parenthesis, when it is presented with a name which is not a >> noun. �Apparently, though, when given a noun, it always serializes the >> noun. �[I do not have handy any written guarantees of this, but I also >> have not been able to construct any counter examples.) >> >> So, that suggests a serialization mechanism like this: >> >> serializeNamedEntity=: 3 :0 >> �select. nc <y >> � �case.0 do. 5!:5 <y >> � �case. �do. '(',')`:6',~5!:5 <'m' [ m=. 5!:1 <y >> �end. >> ) >> >> And, as a test: >> >> �".'example1=:',serializeNamedEntity 'serializeNamedEntity' >> >> �'example1' (-:&(5!:1)&<) 'serializeNamedEntity' >> 1 >> �". ']&example3=:',serializeNamedEntity 'example2'[ example2=: a. >> >> �'example3' (-:&(5!:1)&<) 'example2' >> 1 >> >> It's probably also good for adverbs and conjunctions (which is why I >> had the entity specified by name, rather than by value). >> >> This depends on undocumented behavior of 5!:5 and of `:6, but it seems >> reasonably robust. >> >> It might be worthwhile using 5!:5 directly, and testing its result and >> falling back to the longer mechanism only when necessary. >> >> -- >> Raul >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm