From J Wiki
Jump to: navigation, search

>> <<   Back to: Vocabulary Thru to: Dictionary

m !: n Foreign Conjunction

Generates a collection of verbs (the so-called Foreigns) to perform such tasks as:

  • interfacing with platform-dependent operating system services outside J's area of responsibility

e.g. system clock, file read/write and user interfaces

  • reading and setting global options for J's responses

e.g. for outputting boxes or displaying the definitions of verbs and modifiers

  • managing locales and reporting on their status.

Operands m (section number) and n (function within section m) are always integers from a set of of pre-determined values.

Important.png For a detailed catalog of m and n in table form, see Vocabulary/Foreigns.

To execute any verb at all in J, you need to call it with a y-argument (and an x-argument too, if it is dyad-only). Foreigns are no different in this respect.

  • By convention choose y to be '' unless a given function needs actual data

(e.g. item names, file names, noun phrases to be analysed).

  • Some Foreigns need an x-argument too (but rarely). Otherwise call the Foreign monadically, i.e. omit x .

Common uses

1. Return the time-of-day (optionally in a specified format)

See: 6!: Time

   6!:0 ''
2007 10 30 13 10 45.312

   6!:0 'hh:mm:ss MM/DD/YY'
13:10:48 10/30/07

2. Execute a named J script (silently)

See: 0!: Scripts

   0!:0 <jpath '~temp/949.ijs'

3. Signal your own invented error message with any choice of error number (1 to 255)

See: 13!: Debug

   'my error message' (13!:8) 255
|my error message
|   'my error message'    (13!:8)255

Use These Combinations

Combinations using x !: y that have exceptionally good performance include:

What it does Type;


Syntax Variants;



Bug Warnings

CRC calculation x&(128!:3) Calculates the CRC lookup table when verb is created

whereas  x 128!:3 y computes it every time phrase is executed