I'm not sure what you're trying to do, but reassigning a name within a line -- 
particularly to a different nameclass -- is asking for trouble. I would 
hesitant to label any behavior a bug in this sentence until I'd worked 
completely through the parsing and precedence, comparing the rules in $II.E 
with the observed behavior (perhaps using load 'trace').

That said, there are known bugs in this area, which can cause the interpreter 
to crash (especially when running in debug mode). So I might recommend avoiding 
it altogether. 

So, let's return to what you're tying to do: why do you want the name 'a' to 
sometimes refer to a noun, and other times a verb? How do you intend to use 'a' 
later, after this sentence? [It's obvious, but perhaps still worth pointing 
out, that if you don't need to use it later, you can just skip the 
assignment(s).]

If you actually want 'a' to always be a noun, and just want to default its 
value in case of an error, you could just write: 

  a =: 2 +: :: 3: 0

Which will give a the value 3 (noun, not verb) if +: raises an error, or 2 +: 3 
otherwise (also in theory a noun, but in practice a domain error).

If you want to be super-duper-paranoic-secure, you could write:  

a =: 2 +: :: 3: a =: 0

Which, while superfluous, is at least less brittle and indirect than the 
original.

But, as I said, it all depends on your goals. I apologize if you've described 
them before;  I haven't been following the thread(s) leading up to this 
message. I just saw the line below and responded.

-Dan

PS: However, I think I did see someone voice the desire to express an arbitrary 
J script on a single line, for situations where space is limited. I wrote a 
utility for this purpose a few years ago for use with Ambrus' jeval IRC bots. 
I'm on the road now (going to see if I can leave to play golf [don't hold your 
breath]), but I can post it later if there's interest. Or maybe a quick search 
on the J Wiki (under Community/IRC) will turn up something.


Please excuse typos; composed on a handheld device.

On Sep 14, 2013, at 12:51 PM, Pascal Jasmin <[email protected]> wrote:

>   1+:2
> |domain error
> |   1    +:2
>    1(+:   :: (a=:3:)) a=:0
> 0
> 
>    (+:   :: (a=:3:)) a=:0
> 0
>    a
> 3:
> 
> still a bug with that one... but the good news:
> 
>    2 +:  ( :: ('a' assign 3: [ ])) a=: 0
> 3
>    a
> 3
>    +:  ( :: ('a' assign 3: [ ])) a=: 0
> 0
>    a
> 0
> 
> works as hoped... and if it doesn't raise an error then the normal code that 
> would assign the flag runs normally.
> A useful feature suggestion though would be a try. finally. form to make 
> semaphores/mutexes easier/possible.
> 
> 
> 
> It turns out though, that I don't know how to make the above return (or just 
> smoutput/print) any error.  One of my tries:
> 
>     +:  ( :: (('a' assign 3:) ] 13!:12 ('' [ ]))) a=: 0
> 0
>    2 +:  ( :: (('a' assign 3:) ] 13!:12 ('' [ ]))) a=: 0
> |domain error
> |   2    +:( ::(('a'assign 3:)]13!:12(''[])))a=:0
>    a
> 0
> 
> 
> 
> 
> 
> 
> 
> 
> ----- Original Message -----
> From: Henry Rich <[email protected]>
> To: [email protected]
> Cc: 
> Sent: Saturday, September 14, 2013 12:19:58 PM
> Subject: Re: [Jgeneral] :: (adverse) weirdness -- was Bug in adverb define
> 
>      '' +  ( :: ('a' assign 3: [ ])) a=: 0
> 
> You are executing the verb against a cell of fills.  When the execution 
> of a verb on a fill-cell fails, the error is quietly ignored, and a 
> result of scalar 0 is used to give the shape/type of the result.  Here, 
> the error in u causes v not to be executed.
> 
> Offhand, this seems questionable: if u fails when u :: v is executed, it 
> seems hasty to assume a default shape without executing v.  But that 
> apparently is what happens.
> 
>      ' ' +  ( :: ('a' assign 3: [ ])) a=: 0
> 3
>    a
> 3
> 
> Here you are executing on a real domain error, and the error path is 
> executed.
> 
> Henry Rich
> 
> On 9/14/2013 11:50 AM, Pascal Jasmin wrote:
>>    '' +  ( :: ('a' assign 3: [ ])) a
> ----------------------------------------------------------------------
> 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