Tracy asked:
>  What do you do when you write a tacit verb and 
>  you wish to assure that it isn't accidentally 
>  invoked dyadically?

I guess a shorter way of answering this would have been:  

        I try to make that situation impossible, similar to the 
        way J does with its primitive verbs.  Note that almost 
        all primitive verbs are ambivalent.*
  
-Dan

*  The rare exceptions (e.g. ~. and {:) are permitted because primitive
"real estate" is limited, and if there are no obvious candidates, it would
be imprudent assign both valences at the cost of limiting future extensions
and flexibility.

(For example, if the dyad {. were implemented, and followed the pattern of
{. and }., it would simply be redundant with the capabilities of those
dyads, and a waste of a primitive which could be used for something else in
the future.)


-----Original Message-----
From: Dan Bron [mailto:j...@bron.us] 
Sent: Tuesday, July 24, 2012 3:59 PM
To: 'programm...@jsoftware.com'
Subject: RE: [Jprogramming] cap

Raul wrote:
>  This kind of reasoning -- that a language primitive should 
>  not be treated as having utility explicitly stated in the 
>  documentation of that primitive, and obviously present in 
>  the implementations -- does not make sense to me.

Maybe an analogy would help:  using [: for its (empty) domain is kind of
like entering a building through the fire escape.  It's in the documentation
(blueprints, official building records, etc), and clearly the implementation
permits it (there's no such thing as stairs that only go down), but it
ignores the intent and evades the spirit.

I wrote:
>  I think we can agree that one of the guiding principles in the 
>  design of J is "graceful degradation"; witness, e.g., %. which 
>  has rank 2 but works "as expected" on vector and scalar 
>  arguments.  

Raul responded:
>  But those are not cases where either the implementation or 
>  the dictionary state that there should be an error.  So 
>  I am not sure how this observation is relevant in this context.

That the Dictionary (& implementation) do not define this to be an error was
the very point of the observation.  It would be reasonable for %. ("matrix
inverse") to reject vectors and scalars ("buddy, that's not a matrix").  But
it doesn't. Instead, it does something useful, and related.  That's the
philosophy I was advocating, with my comment.

Tracy asked:
>  What do you do when you write a tacit verb and 
>  you wish to assure that it isn't accidentally 
>  invoked dyadically?

Same thing I do to assure that my tacit verbs aren't applied to strings when
they're intended for numbers, or at rank zero when they're designed for rank
2.  .... I document them. :)

Kidding aside, I rarely if ever assign a "unused" valence to a verb.  When
writing "public" code, I put in effort to make my verbs ambivalent, where
ancillary valences are meaningful and related to the primary valence (common
patterns include  monad@:]  for naturally monadic verbs, and  default&$: :
dyad  for naturally dyadic verbs).

Where this is not possible or I can't afford the time or effort, I leave the
valence unassigned.  If the verb is later invoked with the wrong number of
arguments, something will happen, and that something will likely either be a
natural error or a nonsensical result, either of which would be a strong
hint to the user that something is amiss and he might want to revisit his
invocation or my documentation.

-Dan

PS:  All that said, I publish and maintain very little "public" code, and my
primary user is myself.  So my views might be parochial.




-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Tracy Harms
Sent: Tuesday, July 24, 2012 11:05 AM
To: programm...@jsoftware.co    m
Subject: Re: [Jprogramming] cap

Hi, Dan,

What do you do when you write a tacit verb and you wish to assure that it
isn't accidentally invoked dyadically?

--Tracy
----------------------------------------------------------------------
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