Subject: A checklist of J concepts
From: richard.levine@canrem.com (Richard Levine)
Date: Tue, 11 Jul 95 12:40:00 -0500
Organization: CRS Online  (Toronto, Ontario)

I wrote the following "essay" as an exercise in learning J, and it was
suggested to me that it might be of interest to people learning J or
interested in J.  It is conceptual in nature, and rather long for a
message on comp.lang.apl (about 250 lines), but such messages have been
posted on comp.lang.apl of this length, and this is at least as
comprehensible!  (:>)

It was reviewed by one other person, but any errors of fact are my own
responsibility.  If anyone finds any significant errors, please let me
know and I will correct and file for reference.  The final document can
be made available in FAQ form for future reference in any APL document
archive that exists today.

--regards
Richard L.

--------------------------------------------------------------

Checklist of J Concepts

Introduction
        This is a checklist of concepts of the J language
and system.
        This may be taken to be a "gloss" or "commentary"
on the Dictionary.   It was developed by the author as
an exercise in understanding J and in developing a
"schema" for learning the language.
        How do you rate yourself on the concepts you are
familiar with?

The Choice of J Concepts
        J is a very consisent language, in the sense that
a set of concepts is rigourously and consistently
applied.
         All concepts are described in some manner in the
Dictionary.  Some, however, such as "permissive
assembly", are not labelled as such, but are described
in the Dictionary (cf. Section II).  Some terms, such
as "implicit definition", are not found in the
Dictionary, but are used here for explanatory
purposes.
        Each concept is a separate topic.  Of course, the
description of some concepts, such as "trains" and
"rank", can be considerably elaborated, with many
examples, ramifications and uses.   Some, such as
"interactivity", are commonly known and even taken for
granted.  Some, such as "error messages", are not even
noticed!
        Note that the list of concepts is not intended to
suggest an order of teaching, or even that J should be
taught concept by concept.  However, the list is
useful as a checklist for review, or to ensure that
any complete course or book on J includes these
concepts.

English Grammar and Terminology
Terminology and concepts from English grammar are used
to describe J.
Note: nouns, verbs, adverbs, conjunctions, gerunds
(pro-nouns, pro-verbs)
Nouns are atoms, lists, tables, reports, etc.
Sets of terms such as "inverse", "obverse", "adverse"
suggest linked ideas.
Terms such as "train", "hook", "fork", "atop", "ace",
etc. are used for their picturesque qualities.

ASCII Alphabet
The ASCII alphabet is used.

Form of Primitives
Most primitives are symbols, or letters, followed
optionally by a period ( . ) or colon ( : ).
Note that the primitive symbols are chosen with ease
of memorization in mind (this concept is termed
"mnemonic significance").
The specific memory aids may be listed and studied.
Ease of memorization is important because J has more
than 200 primitive nouns, verbs, and operators.

Names
There are the "usual" rules for valid names.

Assignment
Any noun, verb, adverb, or conjunction (and by
implication, an expression resulting in a noun, verb,
etc.) can be assigned a name.
Names are local or global
Assignment is local or global.
Local names are used only within an explicit
definition.
Global names are accessible by any definition.

Nouns
Nouns are "data".
There are regular arrays, numeric or literal arrays,
boxed arrays.
Parts of an array can be referenced by coordinate
position (called "indexing" in some languages but not
in J).

System Constants
System constants are nouns supplied by J.
These may be viewd as "primitive nouns".
These include Pi, Euler's Constant, the Alphabet ( a.
), etc.

Verbs
Verbs are "functions".
A verb always takes one or two arguments (nouns), and
returns one result (a noun).
A monadic verb takes one argument on the right.
A dyadic verb takes an argument on the left and right.
The same primitive symbol can be used monadically or
dyadically, often with unrelated meanings.

Agreement of Verb Arguments
"Agreement" is a set of rules for the permitted shapes
of the two arguments of a dyadic verb, relative to one
another.
The nouns are not required to be the same shape, but
at least the frame of one noun must be a prefix of the
frame of the other noun.
"Agreement" applies to all verbs.

"Permissive Assembly" of Verb Results
The result of a verb may be "massaged" (or arranged)
to fit into an regular array.

Rank
Nouns may be viewed as sets of cells.
Cells have rank and verbs (primitive or defined) have
(intrinsic) rank.
The rank of a cell cannot be changed.  The rank of a
verb can be changed by using the "rank" conjunction.
Every verb is applied to specified cells of its
arguments.  The rank of the verb determines the rank
of the cells to which it applies.  The cell may be the
entire noun.

Inverses and Obverses
A function is associated with its "inverse" function.
J supplies inverse for many primitive verbs.
An inverse may be defined.

Identity Elements
An identity element is an "identity" with respect to a
specific function or mathematical operation.
J supplies identities for many primitive verbs.

Adverbs
Adverbs are in the class of "operators".
Adverbs are "function modifiers".
An adverb always takes one argument on its left
(usually a verb, sometimes a noun), and returns one
result (a verb).

Conjunctions
Conjunctions are in the class of "operators".
Conjunctions are used to modify functions, create new
functions, combine functions ("function composition"),
etc.
A conjunction always takes two arguments and returns
one result (a noun, verb, adverb, or conjunction).

Gerunds
A gerund is a form of a verb ("function") that may be
manipulated as a noun.
There is also a set of primitives taking gerund
arguments.

Parsing
Parsing involves the rules for evaluating expressions.
(An expression is simply more than one "operation"
specified in a line)..
Always do what is within parentheses first.  This
simple rule explains "mysteries" such as why 2 (+ % -)
10 is evaluated as a "fork"; and why ('ab';'de') =. 1
2 is evaluated as "indirect assignment".
If some of an expression is unparenthesized, apply the
rules for order of execution within unparenthesized
expressions.
Operators - Adverbs and conjunctions take precedence
over verbs.
Operators - The left argument is the longest operator
sequence.  The right argument is the noun or verb to
the right.
Verbs - No hierarchy of precedence among verbs.
Verbs - The left argument is the noun immediately to
the left, the right argument is the noun (or
expression resulting in a noun) to the right.  This is
done after all operators have been evaluated.

Explicit Definition
This is a definition of a verb or operator using a
"program" with "explicit parameters".  (A "program" is
a set of expressions typically executed one "line" at
a time, in order, unless specified otherwise.)
There is a set of control structures.
Execution-time errors may be "trapped".

Error Messages
Error messages are terse and precise.
Watch the spacing, it gives an indication where the
error occurred!

Suspended Mode
"Suspended mode" (when an error occurs at execution
time) may be controlled.

Trains ("Tacit" Definition)
A train is a parenthesized or named sequence of verbs
and operators.  (No nouns!)
Trains are defined as verbs, adverbs, or conjunctions.
Common verb trains are a sequence of two verbs and a
sequence of three verbs (given the picturesque terms
of "hook" and "fork", respectively, presumably so
you'll never forget them!).
A train may be viewed as an "implicit definition"
(parameters are implicitly represented) to compare and
contrast with "explicit definition".  A train can
always be rewritten as an equivalent one-line explicit
definition (though it may be preferable ultimately to
use the implicit form).

Array Thinking
Array capabilities of J lead to a large class of
"array-oriented" algorithms.  As a simple example,
remove "redundant" blanks in text by applying a
computed boolean list, rather than inspecting the text
one character at a time in a "while" loop.

Interactivity
Enter one expression, press "return", and J computes a
result.
All primitives may be executed
interactively.
This is done in the "execution window".

"Script File"
A "script" is a sequence of J expressions.  A script
may be automatically executed one line at a time as if
the lines were entered one by one in an execution
window.
A "script file" is a text file containing text
intended to be used as a J script.
A "script file" may be viewed as a generalization of a
"source file".

Tolerant Comparison
"Tolerant comparison" is comparison such that the
value x is considered equal to y if their difference
falls relatively close to zero.
Tolerant comparison applies to several primitives.
The "comparison tolerance" may be specified.

Recursion
J supports definitions using recursive (self-
reference) techniques.
Note (self-reference) primitive.

Locales
A "locale" is the "name space" feature for J.

Files
J supports access to files of various kinds, including
files on the host system.

Communication with Other Systems
Features for communicating with other programming
systems and other software, including C, spreadsheets,
data bases, Windows, etc.
Special concepts for accessing windowing capabilities
of MS Windows.  (Need to know Windows concepts.)

Administrative Functions
J supports administrative functions such as reporting
time, date, performance, lists of objects, and many
more.

----- end of document
