Bug in gerund form of ^: with infinity (or u ^: _:) -- J9.6 & J9.7-beta

51 views
Skip to first unread message

Cameron Chandoke

unread,
May 27, 2025, 12:02:22 PM5/27/25
to forum
I'm not surprised that ^:_ might only be recognized as a special form. Having said that, using conceptually equivalent ways of supplying _ as an operand to (^:) --- through a gerund operand or the constant verb (_:) --- gives a buggy result:

   2 -^:_]1           NB. (2-...-2-2-1) = 1
1
   2 -^:(]`1:) _      NB. gerund equivalent

   # 2 -^:(]`1:) _    NB. ??? no count

   10+ 2 -^:(]`1:) _

   a=: 2 -^:(]`1:) _  NB. error on assignment
|domain error
|   a=:2    -^:(]`1:)_


Similar results here:
   +/@]^:_] i.4 5
190 
   _ +/@]^:([`]) i.4 5

   # _ +/@]^:([`[`]) i.4 5

   a=:$_ +/@]^:([`[`]) i.4 5
|domain error
|   a=:$_    +/@]^:([`[`])i.4 5


Some cases instead error on execution of the 'u' operand:
   2 ^^:_]1                    NB. as expected...
_
   2 ^^:(]`1:) _               NB. error from ^ rather than from ^: 
|domain error, executing dyad ^
|   2    ^^:(]`1:)_
   echo@'hi'^:1:^:_.] 0        NB. echo 'hi' forever
hi
hi
hi
...
   _. echo@'hi'^:1:^:([`]) 0   NB. a gerund equivalent; error from 'u'
|domain error, executing monad 1!:2&2
|   _.     echo@'hi'^:1:^:([`])0


If _: were explicitly disallowed as the 'n' operand, I'd expect an error from either the (^:) conjunction itself, or from the derived verb, as in the following cases:
   3:^:_.]0        NB. attempt to use f^:_. outside of u^:v^:_. structure
|domain error, executing conj ^:
|   3:    ^:_.]0
   2 ^^:(]`1:) _.  NB. attempt to use f^:_. outside of u^:v^:_. structure
|domain error, executing dyad ^^:(;:']1:')
|   2    ^^:(]`1:)_.
   3:^:__: 0       NB. [negative infinity] constant verb
|domain error, executing monad 3:^:__
|       3:^:__:0


The main idea here, besides the apparent bug, is that I'd expect all cases where we pass _ or _. through a gerund operand to behave the same way as typing 'u^:_' (or similarly, 'u^:v^:_.')  directly. I realize this is sort of a corner case, but thought it was worth mentioning for consistency's sake.

   JVERSION
Engine: j9.6.2/j64/linux
Build: commercial/2025-03-07T01:30:44/clang-11-0-0/SLEEF=1
Library: 9.6.14
Platform: Linux 64
Installer: j9.6 install
InstallPath: /home/cam/Programs/j/j9.6
Contact: www.jsoftware.com

   JVERSION
Engine: j9.7.0-beta3/j64avx2/linux
Build: commercial/2025-04-03T02:23:47/clang-14-0-0/SLEEF=1
Library: 9.7.1
Platform: Linux 64
Installer: j9.7 install
InstallPath: /home/cam/Programs/j/j9.7
Contact: www.jsoftware.com


Thanks,

Cameron

Henry Rich

unread,
May 28, 2025, 8:09:08 AM5/28/25
to fo...@jsoftware.com
Fixed for next beta.  The result of the gerund was checked to see if it was 0 or 1 (the fast case), which in the case of _ value produced a domain error which was ignored.  Ignored but not cleared, and it eventually surfaced in the various ways you noticed.

Thanks much for pointing out the bug.

The gerund forms should allow all the values allowed as nouns.

Henry Rich
To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.

Cameron Chandoke

unread,
May 28, 2025, 1:35:58 PM5/28/25
to forum, Henry Rich
Awesome. Thanks for all your work, Henry!
Reply all
Reply to author
Forward
0 new messages