I am more thinking of systems written over time by many people writing
different parts and they may have written different operations using the
same names for different purposes.

When you compare the utilities and addons you will see such things it may
obviously happen to your own code over time too.

2011/10/3 Dan Bron <[email protected]>

> My J development pattern is very REPL-heavy, and so it's more common for me
> to forget to persist a definition to a script in the first place, rather
> than persisting it in a temp script and then overwriting that file without
> retaining the definition.
>
> That said, I think we could still leverage 4!:4 to assist with the latter
> oversight.  In broad strokes:
>
>        1.  Find all scripts with 'temp' in the name (you could have finer
> controls around this)
>        2.  Find all names defined by such scripts
>        3.  Read each script and report any names that 4!:4 says it defines,
> but it doesn't (textually).
>
> Here's a quick & dirty proof of concept:
>
>   temps =: I. 'temp' (+./@:E.)S:0 ] allScripts =: 4!:3''  NB.  Find scripts
> in 'temp' dir (coarsely)
>   allNames =: findNames ''  NB.  DJB util to list all names in all locales,
> fully qualified
>   tempNames =: allNames #~ mask =: temps e.~ scripts =: 4!:4 :: _2: "0
> allNames NB.  Find names defined in 'temp' scripts
>   baseTempNames =: '(.+)_[^_]+_' (rxmatches {:@:,@:rxfrom ]) S:0  tempNames
> NB.  Fully qualified name -> base name
>   assignmentPatterns =: '\s*=:',L:0~ baseTempNames ,L:0"0/
> '_[^_]*_';'__[a-zA-Z][a-zA-Z0-9]*'  NB.  Coverage of potential definition
> patterns
>   'Can''t find assignments for: ' , ;:^:_1: tempNames #~ assignmentPatterns
> (0 = [: +/ (#@rxmatches fread)&>)"1 0 (4!:3'') {~ mask # scripts
>
> You could extend this by also printing the definitions of the undefined
> names.  There are all sorts of edge cases, of course (name_locale_ =. ...
> or
> 'name' =:  ...  or  ". 'name =: ...' etc) .
>
> -Dan
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> On Behalf Of Raul Miller
> Sent: Monday, October 03, 2011 11:27 AM
> To: General forum
> Subject: Re: [Jgeneral] Neophyte puzzled with boxing/unboxing
>
> On Mon, Oct 3, 2011 at 11:11 AM, Dan Bron <[email protected]> wrote:
> > On my to-do (and never-will) list for a number of years is a utility to
> detected un-persisted names (_1 = 4!:4), then scan through the session log
> for the lines that define them and their recursive dependencies, and output
> this to a script file, automatically.
>
> When I run into the sort of problem that I think this might solve, the
> variables were usually defined in previous instances of a tmp file.
>
> But 4!:4 does not deal with this issue.
>
> --
> 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
>



-- 
Björn Helgason, Verkfræðingur
Fornustekkum II
781 Hornafirði,
t-póst: [email protected]
gsm: +3546985532
twitter: @flugfiskur
http://groups.google.com/group/J-Programming


Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans

góður kennari getur stigið á tær án þess að glansinn fari af skónum
          /|_      .-----------------------------------.
         ,'  .\  /  | Með léttri lund verður        |
     ,--'    _,'   | Dagurinn í dag                     |
    /       /       | Enn betri en gærdagurinn  |
   (   -.  |        `-----------------------------------'
   |     ) |         (\_ _/)
  (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
   `. )----'        (")_(") ☃☠
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to