Note that the special forms for fork involves the left tine of the
fork.  Hooks do not have the corresponding element.

And v n already has a definition.  For example:  -3

And, the special form involving nouns treats the noun as a verb with a
constant result.  If this pattern were followed for an n v hook, you
would achieve a constant hook, and there are already other ways of
implementing constants.

Also, it's probably good to have some illegal syntax in the language.
People make mistakes and if we have an easy way of letting them know
that they made a mistake that can help focus their attention on the
region of code where they wrote something different from what they
were thinking.

Finally, the special forms for fork appeared years after the first
implementations of J -- maybe as much as a decade later.  (Also, I
remember seeing a comment from Roger Hui, that he considers "Hook" to
be a mistake -- but for backwards compatibility reasons he does not
want to eliminate it from the language.)

-- 
Raul

On Thu, Mar 22, 2012 at 4:11 AM, Alexander Epifanov <[email protected]> wrote:
> Q100: Why there is special form for fork (n v v) (3=#), but no special
> form for hook (n v) or (v n) (3+)?
>
> Sorry, I cannot find "_ in dictionaty.
>
> Why do we need @ at all, if it possible to emulate it with [: and trains?
>
> Regards,
>
> On Thu, Mar 22, 2012 at 12:03 PM, Alexander Epifanov <[email protected]> 
> wrote:
>> Just some notes for me after first mail:
>>
>> [: - cool thing, but I do not understand if it is possible to
>> implement such function in haskell. Is it special form?
>>
>> n v v - special form, that is why 3=# works :)
>>
>> I wrote "find 3 unique digit numbers" with [:
>> (]#~([:(3=#*.[:*./~:)":)"0) ns
>>
>> Looks good, and it is easier than @, because there are much less brackets.
>> but if I understand correct where no different between @ and fork with [: .
>> That is why there are two ways to write the same things, hard to
>> decide which is better?
>>
>> If I understand correct, it is possible to write in explicit style
>> with 3 : '' only, which inverynot easy, something like 3 :'3 :''3
>> :'''y'''": y''"0 y' ns. That is why most of the time it is not correct
>> style for J.
>>
>> Regards,
>
>
>
> --
> Regards,
>   Alexander.
> ----------------------------------------------------------------------
> 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