Ewart Shaw wrote:
> You can write a monadic function  fun  say that ignores its argument,
> and call it in J with
>    fun''
> 
> I mainly use niladic functions to return globals, for example
>    setpc=: 3 : 'PENCOL=: y'   NB. usually more complex than this!
>    getpc=: 3 : 'PENCOL'   NB. again may be more complex
>                           NB. e.g. return  0 0 0  if  PENCOL undefined
>       ...
>    p=. getpc''   NB. pen colour

If there will not be any side effects for setpc and getpc, then using global
PENCOL itself directly is no difference from that of setpc/getpc, although some
oop fans prefer setpc/getpc

> ========== (further response) ==========
> 
> Someone (Markus Triska) then replied saying that
> "Passing PENCOL to all functions using it is even less error-prone"
> 
> ========== (end of extracts) ==========
> 
> 
> My experience has been different from Markus's: I know if a
> particular function needs access to PENCOL, but keeping track of
> "all functions using it" would be a nightmare, particularly in the
> development stage (& I expect the development stage to last forever).
> I've also found my approach useful whether or not I'm using J's
> object-oriented features.
> 

Markus's comment is sometimes correct and especially for distributed
applications, otherwise keeping persistent and synchronous globals across
boundaries is difficult.  There are always conflicts and you need to compromise
according to your own needs.

> Has anyone any comments?  How do other people avoid being strangled
> by spaghetti code? (I'm talking several hundred k of .ijs scripts)
> 

IMO you can't avoid spaghetti code. The well organized, modularized, top-down
codes are not original, they are refactorized from spaghetti codes written
earlier.  Just my two cents.

-- 
regards,
bill
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to