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: [email protected]
[mailto:[email protected]] On Behalf Of Tracy Harms
Sent: Tuesday, July 24, 2012 11:05 AM
To: [email protected] 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