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

Reply via email to