[Jprogramming] invoking object verbs without polluting global namespace
bill lam
bbill.lam at gmail.com
Mon Nov 9 15:31:34 UTC 2015
Actaully it switches back if the verb is named (not necessarily
explicit). eg. define a script (say a1.ijs) with 3 lines
cocurrent 'a1'
smoutput coname''
''
and try the followings.
0!:0 <'a1.ijs'
coname ''
and start a new session
lod=: 0!:0
lod <'a1.ijs'
coname ''
incidentally, load any scripts with the utility verb load
will not switch the current locale. Not sure where this is
documented.
Пн, 09 ноя 2015, Joe Bogner написал(а):
> On Mon, Nov 9, 2015 at 9:34 AM, Raul Miller <rauldmiller at gmail.com> wrote:
> > On Mon, Nov 9, 2015 at 8:22 AM, Joe Bogner <joebogner at gmail.com> wrote:
> >> Thank you. I had this thought as well but couldn't get it to work. I
> >> may not have a full grasp on how cocurrent works
> >>
> >> I define st as 'switch to table locale' and sb as 'switch to base locale'
> >>
> >> I defined them explicitly
> >>
> >> My first attempt:
> > ...
> >> sb=: 3 : 0
> >> cocurrent 'base'
> >> y
> >> )
> >
> > http://www.jsoftware.com/help/dictionary/dx018.htm
> >
> > "
> > 18!:4 y
> > Switch Current. Switch the current locale to y at the end of the
> > currently executing named verb. Initially the current locale is base .
> > "
>
> Thanks, I read that initially but still don't understand it,
> specifically 'the end of the currently executing named verb'.
>
> cocurrent
> 18!:4 at boxxopen
>
> If I type cocurrent 'base' , I would assume cocurrent is the
> currently executing named verb and it switched to base after the end
> of cocurrent
>
> Given that understanding, why would it switch back at the end of the
> explicit definition? Is that behavior documented somewhere?
>
>
> >
> > You either need to use ([ cocurrent bind 'base') instead of sb, or use
> > 18!:4 in sb .
> >
>
> I had forgotten about bind
>
> ([ cocurrent@('base'"_1)) 2
>
>
> http://code.jsoftware.com/wiki/Vocabulary/quotem
>
> I typically use & to bind parameters. & cannot be used on cocurrent
> because it's monadic, is that the correct interpretation?
>
> NB. basic monadic verb
> add1 =: 3 : 'y+1'
>
> NB. no & allowed
> (add1&3) 0
> |domain error: add1
>
> NB. bind works
> (add1 bind 3) 100
> 4
>
> NB. & works fine when defined dyadic
> add1d =: 4 : 'y+1'
> (add1 & 3) 1
> 4
>
> NB. no bind on dyadic
> (add1d bind 3) 1
> |domain error: add1d
> | (add1d bind 3)1
>
>
> Is there a way to determine the valence of a tacit verb?
>
> My first thought was ar, but that didn't seem to help:
>
> 5!:1 (<'cocurrent')
> ┌──────────────────────────────────┐
> │┌─┬──────────────────────────────┐│
> ││@│┌───────────────────┬────────┐││
> ││ ││┌──┬──────────────┐│boxxopen│││
> ││ │││!:│┌──────┬─────┐││ │││
> ││ │││ ││┌─┬──┐│┌─┬─┐│││ │││
> ││ │││ │││0│18│││0│4││││ │││
> ││ │││ ││└─┴──┘│└─┴─┘│││ │││
> ││ │││ │└──────┴─────┘││ │││
> ││ ││└──┴──────────────┘│ │││
> ││ │└───────────────────┴────────┘││
> │└─┴──────────────────────────────┘│
> └──────────────────────────────────┘
>
>
> > locale handling has to do with name resolution - not just in terms of
> > what gets resolved, but also in terms of context.
> >
> > Thanks,
> >
> > --
> > 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
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
More information about the Programming
mailing list