Skip to main content

Names and help

Inspect, list and erase names, and read help

Names

]help •nc

•nc — Name class

•nc names gives the class of each name: ¯1 invalid, 0 undefined, 2 value, 3 function, 4 operator. A function glyph or a system name, such as + or •json, has class 3. A character vector is one name. Introspection has examples.

v←1 2 3 ◇ mean←+/÷≢
•nc "v"
•nc "mean" "absent"
2ₓ
[3 0]ₓ
]help •nl

•nl — Name list

prefix •nl classes lists the visible user names in classes that begin with prefix, as a sorted vector of strings. •nl classes lists them all. Introspection has examples.

Errors: DOMAIN for unsupported classes; RANK for a class matrix.

Shadowed names appear once. Implicit argument and operand names are left out:

mean←+/÷≢
"me" •nl 3
"absent" •nl 2 3 4
["mean"]
0ρ⊂""
]help •src

•src — Source

•src name returns the definition text of a function or operator, including comments. Introspection has examples.

Errors: VALUE for an undefined name; DOMAIN for an argument that isn’t a name.

For a primitive or derived function, the BPL representation is returned:

f←{≥ω} ◇ add←+
•src "f"
•src "add"
"{≥ω}"
"+"
]help •ex

•ex — Erase

•ex names erases the nearest binding of each name. An outer binding can then become visible. It returns 1 for each name that it erased or that had no binding, and 0 for an invalid or protected name. Introspection has examples.

A function that another name or an array still holds stays usable after its name is erased. 1 is also returned when the name is already absent:

v←1
•ex "v"
•ex "v"
•ex "$a"
1ₓ
1ₓ
0ₓ

Interactive help

]help name shows help in the REPL and in notebooks. A leading ⍝ comment block inside a definition supplies its help text:

mean←{⍝ Mean of a vector
    +/ω ÷ ≢ω}

]help mean shows the comment:

]help mean

Calls: f Y or X f Y

Mean of a vector

Pass -source to show the definition:

]help mean -source
{⍝ Mean of a vector
    +/ω ÷ ≢ω}

]help also accepts a glyph and shows the help from its glyph page:

]help ?

? — Predicate

Syntax. Hanzi: 若

In a dfn, C? ends a predicate. When C is true, the rest of the body runs. When C is false, the next body, after ;, runs.

{ω<0?-ω;ω}¯3      ⍝ 3
{ω<0?-ω;ω}4       ⍝ 4

Statements before a predicate run first. After it, a body can run several statements, or hold more predicates.

{ω<0?a←-ω ◇ a×2;ω}¯3   ⍝ 6
{ω>0?ω<10?ω;0}15       ⍝ 0

C must be one truth value ($t, $f, 1 or 0), or an array holding one. A body that ends after its predicate returns no result. If every predicate fails, the call raises DOMAIN. See Dfns.

In the BPL kernel, press Shift-Tab to inspect the name or glyph at the cursor. Press Tab to complete user names, system names and glyph names typed after a backtick, such as `iota.

]help and Shift-Tab read definitions without executing them. For a dfn, the help shows both call forms, f Y and X f Y, whether or not the dfn takes a left argument.

Python covers help and completion for Python Function objects in IPython.