A global variable holding a (possibly empty) prg body, which will be executed during error processing. See also Error Handling, *Msg and ^.

: (de *Err (prinl "Fatal error!"))
-> *Err
: (/ 3 0)
!? (/ 3 0)
Fatal error!
A global variable holding a sorted list of cons pairs. The CAR of each pair specifies an external symbol offset (suitable for ext), and the CDR should be a function taking a single external symbol as an argument. This function should return a list, with the value for that symbol in its CAR, and the property list (in the format used by getl and putl) in its CDR. The symbol will be set to this value and property list upon access. Typically this function will access the corresponding symbol in a remote database process. See also qsym and external symbols.

### On the local machine ###
: (setq *Ext  # Define extension functions
      '((@Host @Ext)
         (cons @Ext
            (curry (@Host @Ext (Sock)) (Obj)
               (when (or Sock (setq Sock (connect @Host 4040)))
                  (ext @Ext
                     (out Sock (pr (cons 'qsym Obj)))
                        (in Sock (rd))
                        (unless @
                           (close Sock)
                           (off Sock) ) ) ) ) ) ) )
      '("" "" "" "")
      (20 40 60 80) ) )

### On the remote machines ###
(de go ()
   (task (port 4040)                      # Set up background query server
      (let? Sock (accept @)               # Accept a connection
         (unless (fork)                   # In child process
            (in Sock
               (while (rd)                # Handle requests
                  (out Sock
                     (pr (eval @)) ) ) )
            (bye) )                       # Exit child process
         (close Sock) ) )
   (forked)                               # Close task in children

Base class of all database objects. See also +relation and Database.

Messages to entity objects include

zap> ()              # Clean up relational structures, for removal from the DB
url> (Tab)           # Call the GUI on that object (in optional Tab)
gui> ()              # Generate object-specific GUI fragment
upd> (X Old)         # Callback method when object is created/modified/deleted
has> (Var Val)       # Check if value is present
rel?> (Var Val)      # Check if relations for value are correctly maintained
put> (Var Val)       # Put a new value
put!> (Var Val)      # Put a new value, single transaction
del> (Var Val)       # Delete value (also partial)
del!> (Var Val)      # Delete value (also partial), single transaction
inc> (Var Val)       # Increment numeric value
inc!> (Var Val)      # Increment numeric value, single transaction
dec> (Var Val)       # Decrement numeric value
dec!> (Var Val)      # Decrement numeric value, single transaction
mis> (Var Val)       # Return error message if value or type mismatch
lose1> (Var)         # Delete relational structures for a single attribute
lose> (Lst)          # Delete relational structures (excluding 'Lst')
lose!> ()            # Delete relational structures, single transaction
keep1> (Var)         # Restore relational structures for single attribute
keep> (Lst)          # Restore relational structures (excluding 'Lst')
keep?> (Lst)         # Test for restauration (excluding 'Lst')
keep!> ()            # Restore relational structures, single transaction
set> (Val)           # Set the value (type, i.e. class list)
set!> (Val)          # Set the value, single transaction
clone> ()            # Object copy
clone!> ()           # Object copy, single transaction
(e . prg) -> any
Used in a breakpoint. Evaluates prg in the execution environment, or the currently executed expression if prg is not given. See also debug, !, ^ and *Dbg.

: (! + 3 4)
(+ 3 4)
! (e)
-> 7
(echo ['cnt ['cnt]] | ['sym ..]) -> sym
Reads the current input channel, and writes to the current output channel. If cnt is given, only that many bytes are actually echoed. In case of two cnt arguments, the first one specifies the number of bytes to skip in the input stream. Otherwise, if one or more sym arguments are given, the echo process stops as soon as one of the symbol's names is encountered in the input stream. In this case the name will be read and returned, but not written. Returns non-NIL if the operation was successfully completed. See also from.

: (in "x.l" (echo))  # Display file on console

: (out "x2.l" (in "x.l" (echo)))  # Copy file "x.l" to "x2.l"
(edit 'sym ..) -> NIL
(Debug mode only) Edits the value and property list of the argument symbol(s) by calling the vim editor on a temporary file with these data. When closing the editor, the modified data are read and stored into the symbol(s). During the edit session, individual symbols are separated by the pattern (=======). These separators should not be modified. When moving the cursor to the beginning of a symbol (no matter if internal, transient or external), and hitting 'K', that symbol is added to the currently edited symbols. Hitting 'Q' will go back one step and return to the previously edited list of symbols.

edit is especially useful for browsing through the database (with 'K' and 'Q'), inspecting external symbols, but care must be taken when modifying any data as then the entity/relation mechanisms are circumvented, and commit has to be called manually if the changes should be persistent.

Another typical use case is inserting or removing ! breakpoints at arbitrary code locations, or doing other temporary changes to the code for debugging purposes.

See also update, show, vi and em.

: (edit (db 'nr '+Item 1))  # Edit a database symbol
### 'vim' shows this ###
{3-1} (+Item)
   nr 1
   inv 100
   pr 29900
   sup {2-1}  # (+CuSu)
   nm "Main Part"

### Hitting 'K' on the '{' of '{2-1} ###
{2-1} (+CuSu)
   nr 1
   plz "3425"
   mob "37 176 86303"
   tel "37 4967 6846-0"
   fax "37 4967 68462"
   nm "Active Parts Inc."
   nm2 "East Division"
   ort "Freetown"
   str "Wildcat Lane"
   em "info@api.tld"


{3-1} (+Item)
   nr 1
   inv 100
   pr 29900
   sup {2-1}  # (+CuSu)
   nm "Main Part"

### Entering ':q' in vim ###
-> NIL
(em 'sym) -> sym
(em 'sym 'cls) -> sym
(em '(sym . cls)) -> sym
(em) -> NIL
(Debug mode only) Opens the "emacs" editor on the function or method definition of sym. A call to ld thereafter will load the modified file. A call without arguments permanently switches the REPL line editor and the edit function to "emacs" mode. See also doc, edit, vi, *Dbg, debug and pp.

: (em 'url> '+CuSu)  # Edit the method's source code, then exit from 'emacs'
-> T
(env ['lst] | ['sym 'val] ..) -> lst
Return a list of symbol-value pairs of all dynamically bound symbols if called without arguments, or of the symbols or symbol-value pairs in lst, or the explicitly given sym-val arguments. See also bind, job, trail and up.

: (env)
-> NIL
: (let (A 1 B 2) (env))
-> ((A . 1) (B . 2))
: (let (A 1 B 2) (env '(A B)))
-> ((B . 2) (A . 1))
: (let (A 1 B 2) (env 'X 7 '(A B (C . 3)) 'Y 8))
-> ((Y . 8) (C . 3) (B . 2) (A . 1) (X . 7))
(eof ['flg]) -> flg
Returns the end-of-file status of the current input channel. If flg is non-NIL, the channel's status is forced to end-of-file, so that the next call to eof will return T, and calls to char, peek, line, from, till, read or skip will return NIL. Note that eof cannot be used with the binary rd function. See also eol.

: (in "file" (until (eof) (println (line T))))
(eol) -> flg
Returns the end-of-line status of the current input channel. See also eof.

: (make (until (prog (link (read)) (eol))))  # Read line into a list
a b c (d e f) 123
-> (a b c (d e f) 123)
Pilog predicate that succeeds if the two arguments are equal. See also =, different/2 and member/2.

: (? (equal 3 4))
-> NIL
: (? (equal @N 7))
-> NIL
(err 'sym . prg) -> any
Redirects the standard error stream to sym during the execution of prg. The current standard error stream will be saved and restored appropriately. If the argument is NIL, the current output stream will be used. Otherwise, sym is taken as a file name (opened in "append" mode if the first character is "+"), where standard error is to be written to. See also in, out and ctl.

: (err "/dev/null"             # Suppress error messages
   (call 'ls 'noSuchFile) )
-> NIL
(errno) -> cnt
(64-bit version only) Returns the value of the standard I/O 'errno' variable. See also native.

: (in "foo")                           # Produce an error
!? (in "foo")
"foo" -- Open error: No such file or directory
? (errno)
-> 2                                   # Returned 'ENOENT'
(eval 'any ['cnt ['lst]]) -> any
Evaluates any. Note that because of the standard argument evaluation, any is actually evaluated twice. If a lambda-binding environment offset cnt is given, the second evaluation takes place in the corresponding environment, and an optional lst of excluded symbols can be supplied. cnt should be greater than zero. See also run and up.

: (eval (list '+ 1 2 3))
-> 6
: (setq X 'Y  Y 7)
-> 7
: X
-> Y
: Y
-> 7
: (eval X)
-> 7

: (de f (A)
      (eval 'A)
      (eval 'A 1)
      (eval 'A 2) ) )
-> f
: (de g (A)
   (f (inc A)) )
-> g
: (one A)
-> 1
: (g (inc A))
-> (3 2 1)
(expDat 'sym) -> dat
Expands a date string according to the current locale (delimiter, and order of year, month and day). Accepts abbreviated input, without delimiter and with only the day, or the day and month, or the day, month and year of current century. A single dot "." expands to "today", and a signed number to a date such many days in the past or future. See also datStr, day, expTel.

: (date)
-> 733133
: (date (date))
-> (2007 5 31)
: (expDat "31")
-> 733133
: (expDat "315")
-> 733133
: (expDat "3105")
-> 733133
: (expDat "31057")
-> 733133
: (expDat "310507")
-> 733133
: (expDat "2007-05-31")
-> 733133
: (expDat "7-5-31")
-> 733133

: (locale "DE" "de")
-> NIL
: (expDat "31.5")
-> 733133
: (expDat "31.5.7")
-> 733133
(exec 'any ..)
Executes an external system command. The any arguments specify the command and its arguments. Does not return to the caller; the current process is replaced with a new process image. See also fork and call.

: (pipe (exec 'echo 123 "abc")
   (list (read) (read)) )
-> (123 abc)

(unless (fork)
   (exec "@bin/ssl"  # Start replication process
      "" 443
      "app/!replica" "key/app" "fifo/app" "db/app/blob/" 20 ) )
(expTel 'sym) -> sym
Expands a telephone number string. Multiple spaces or hyphens are coalesced. A leading + or 00 is removed, a leading national trunk prefix is replaced with the current country code. Otherwise, NIL is returned. See also telStr, expDat and locale.

: (expTel "+49 1234 5678-0")
-> "49 1234 5678-0"
: (expTel "0049 1234 5678-0")
-> "49 1234 5678-0"
: (expTel "01234 5678-0")
-> NIL
: (locale "DE" "de")
-> NIL
: (expTel "01234 5678-0")
-> "49 1234 5678-0"
(expr 'sym) -> fun
Converts a built-in function (SUBR) to a Lisp-function. Useful only for normal functions (i.e. functions that evaluate all arguments). See also subr.

: car
-> 67313448
: (expr 'car)
-> (@ (pass $385260187))
: (car (1 2 3))
-> 1
(ext 'cnt . prg) -> any
During the execution of prg, all external symbols processed by rd, pr, blk or udp are modified by an offset cnt suitable for mapping via the *Ext mechanism. All external symbol's file numbers are decremented by cnt during output, and incremented by cnt during input.

: (out 'a (ext 5 (pr '({6-2} ({8-9} . a) ({7-7} . b)))))
-> ({6-2} ({8-9} . a) ({7-7} . b))

: (in 'a (rd))
-> ({2} ({3-9} . a) ({2-7} . b))

: (in 'a (ext 5 (rd)))
-> ({6-2} ({8-9} . a) ({7-7} . b))
(ext? 'any) -> sym | NIL
Returns the argument any when it is an existing external symbol, otherwise NIL. See also sym?, box?, str?, extern and lieu.

: (ext? *DB)
-> {1}
: (ext? 'abc)
-> NIL
: (ext? "abc")
-> NIL
: (ext? 123)
-> NIL
(extend cls) -> cls
Extends the class cls, by storing it in the global variable *Class. As a consequence, all following method, relation and class variable definitions are applied to that class. See also OO Concepts, class, dm, var, rel, type and isa.

(extern 'sym) -> sym | NIL
Creates or finds an external symbol. If a symbol with the name sym is already extern, it is returned. Otherwise, a new external symbol is returned. NIL is returned if sym does not exist in the database. See also intern and ext?.

: (extern "A1b")
-> {A1b}
: (extern "{A1b}")
-> {A1b}
(extra ['any ..]) -> any
Can only be used inside methods. Sends the current message to the current object This, this time starting the search for a method at the remaining branches of the inheritance tree of the class where the current method was found. See also OO Concepts, super, method, meth, send and try.

(dm key> (C)            # 'key>' method of the '+Uppc' class
   (uppc (extra C)) )   # Convert 'key>' of extra classes to upper case
(extract 'fun 'lst ..) -> lst
Applies fun to each element of lst. When additional lst arguments are given, their elements are also passed to fun. Returns a list of all non-NIL values returned by fun. (extract 'fun 'lst) is equivalent to (mapcar 'fun (filter 'fun 'lst)) or, for non-NIL results, to (mapcan '((X) (and (fun X) (cons @))) 'lst). See also filter, find, pick and mapcan.

: (setq A NIL  B 1  C NIL  D 2  E NIL  F 3)
-> 3
: (filter val '(A B C D E F))
-> (B D F)
: (extract val '(A B C D E F))
-> (1 2 3)