>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  J for C Programmers

                                                                                                                    46. Error Messages

When J encounters an error executing a sentence it stops and displays the sentence.  The interpreter removes any excess spaces from the sentence and then adds three spaces before the word whose execution triggered the error.  For example:

   2 3 + 0 1 2 * 3 4 5

|length error

|   2 3    +0 1 2*3 4 5

The error occurred during the execution of the + verb.

The errors you are most likely to encounter are:

control error  If the error is detected when a script is loaded, you have an incomplete control structure, for example an if. without matching do./else./elseif. and end. or, notoriously, the sequence if./elseif./else., which is not allowed (use elseif. instead of that last else.).  If the error is detected when a script is executed, you have an if. block whose last line does not produce a noun result, like if. undefname do. .

domain error  An operand has a value that is not allowed, for example a string operand to an arithmetic operation, or an out-of-range numeric left operand to dyad o. .  One common source of domain error is trying to execute a verb when no definition exists for the valence (monadic or dyadic) that you are trying to execute.

      Errors encountered during execution of wd are reported as domain errors.

      Assignment to a global name, when the same name is defined locally, is considered a domain error.

file name error  You specified a file name that is invalid, or attempted to read a nonexistent file.

file number error  You specified a number that is not the number of an open file.

ill-formed name  You used an illegal name, such as name_1ff_ (illegal because 1ff is not a valid locale name)

ill-formed number  You used an illegal number such as 14h .  A word that starts with a numeric character must be a valid number, and vice versa.

index error  You attempted to access an element outside the bounds of an array.

length error  You used a dyadic verb with operands that did not agree (i. e. one frame was not a prefix of the other).  Or, a verb expected an operand of a certain length and you gave an incorrect length (for example 1 2 3 {. 5 5)

limit error  You exceeded one of J's limits, for example by specifying a comparison tolerance greater than 2^_34 .

NaN error  You performed an operation whose result is indeterminate, such as _ % _, _ - _, or 0 ^. 0 .  This is akin to a domain error.

nonce error  You tried to do something reasonable, but the system doesn't support it yet.  So, for the nonce, find another way to do it.

open quote  Your sentence contains an unmatched single-quote.

out of memory  The interpreter asked the operating system for enough memory to fulfill your request, but the operating system refused.  You need to use smaller nouns, or have a bigger virtual-memory swap file, or close other programs that are competing for virtual memory space.

rank error  You specified an operand with an invalid rank.

spelling error  You typed an erroneous . or : to produce a meaningless word like +.. or fred. .

stack error  J's execution stack was exhausted, probably because of an infinite recursion.

syntax error  Your sentence contains an invalid sequence of parts of speech, as in 5 + .  Or, you have an explicitly-defined verb whose last-executed sentence gives a result that is not a noun: that would make the verb have a non-noun result, which is intolerable.

value error  You have asked the interpreter to evaluate a name that has not been defined.  There is more to this definition than meets the eye.  A noun, adverb, or conjunction is evaluated when it is encountered during the right-to-left execution of a sentence.  A verb is evaluated when (a) it is executed with its noun operand(s) or (b) when the name of the verb is typed as the only word in a sentence, at which time the verb is evaluated for display purposes.  For example, the sentence


will result in a value error, because you are asking the interpreter to display the value of the undefined name.  However, the sentence

   name =: undefname

will not fail, because name is defined to be a reference to undefname, and undefname does not have to be evaluated (the undefined name is assumed to refer to a verb of infinite rank that will be defined later).  Subsequently,



name is defined, but if we force the interpreter to use it:

   name 5

|value error: undefname

|       name 5

the underlying undefined name is exposed.

An important case is:

   undefname1 undefname2

undefname1 undefname2

Note that this did not result in a value error.  Recall that undefined names are assumed to be verbs; we defined a hook from the two presumed verbs and then asked the interpreter to display the hook.  The interpreter was able to do that without evaluating either name.  Either name by itself would produce a value error.



>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  J for C Programmers