From J Wiki
Jump to: navigation, search

Back to: Vocabulary

Obsolete Syntax

As J has developed, language features have been added and discarded. Older reference works may have example code that ran on earlier J versions but not on the latest releases. This page will help you to translate Old J to Modern J.

Deleted Primitives

Old J had primitives that have been deleted from Modern J:

  • Even and Odd (.. and .:
  • Support for calculus (d. D. D:) - the functions of these primitives are provided by the math/calculus addon
  • Support for Maclaurin series (t. t: T.)

x. y. u. v. m. n.

In early J, the arguments x y etc. were treated as control words, ending with a period. To conform to modern J usage, remove the trailing period.

Modifier trains

One of Ken Iverson's many brilliancies was to recognize that normally meaningless sequences of words could be given a syntax. Three examples of this survive to modern J:

  • the fork
  • the hook
  • the adverb train (adverb0 adverb1), which produces an adverb such that noun/verb (A0 A1) is equivalent to ((noun/verb A0) A1)

In early J many such trains were defined. Few understood them and fewer used them, and they have gone the way of Old English's instrumental case. They all produced adverbs or conjunctions, and they are replaced in modern J by explicit definitions.

For example, in old J you could write

V =: / @ ,:

to create an adverb such that (+ V) was (+/ @ ,:). This is adverbial tacit programming, where the train knows where to insert the verb operand. In Modern J, you would write

V =: {{ u/ @ ,: }}

to create the same effect.

Support for these modifier trains has been re-introduced as of J903 beta-r. However, many J prior implementations did not support this syntax.

Decorated constants

In Old J, any constant was automatically demoted to the smallest type that accurately contained the value. Thus, 0, 00, and 0. all represented the same value, the boolean 0. In Modern J these constants have different precisions.

Direct Definitions {{ }}

In Old J the only way to create an explicit definition was with the : conjunction, in the forms 3 : 0 or n : 'definition' or the equivalent verb define. In Modern J {{ }} can be used to create definitions, largely superseding the older method.