# E

`*Err`
  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)
      Div/0
      Fatal error!
      ?

`*Ext`
  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
         (mapcar
            '((@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)))
                           (prog1
                              (in Sock (rd))
                              (unless @
                                 (close Sock)
                                 (off Sock) ) ) ) ) ) ) )
            '("10.10.12.1" "10.10.12.2" "10.10.12.3" "10.10.12.4")
            (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
                        (sync)
                        (tell)
                        (out Sock
                           (pr (eval @)) ) ) )
                  (bye) )                       # Exit child process
               (close Sock) ) )
         ...

`+Entity`
  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"

`(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)

`equal/2`
  Pilog predicate that succeeds if the two arguments are equal. See also `=`, `different/2` and `member/2`.

      : (? (equal 3 4))
      -> NIL
      : (? (equal @N 7))
       @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`
  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]) -> any`
  Evaluates `any`. Note that because of the standard argument evaluation, `any` is actually evaluated twice. If an offset `cnt` is given, the value of `@` in the `cnt`'th call environment is used during the second evaluation. `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)
         (list
            (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)

`(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
            "10.11.12.13" 443
            "app/!replica" "key/app" "fifo/app" "db/app/blob/" 20 ) )

`(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

`(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"

`(export ['sym]) sym|lst`
  Intern symbols explicitly in the second namespace in the current search order, or in the given namespace if `sym` is given. `(export)` expects a single symbol or a list of symbols immediately following in the current input stream. See also `pico`, `symbols`, `private`, `local`, `import` and `intern`.

      : (symbols 'myLib 'pico)
      -> (pico)
      myLib: (export) (foo bar)  # Intern 'foo' and 'bar' in 'pico'

`(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`, `plio`, `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 '({A2} ({C4} . a) ({B7} . b)))))
      -> ({A2} ({C4} . a) ({B7} . b))

      : (in 'a (rd))
      -> ({OOOL2} ({OOON4} . a) ({OOOM7} . b))

      : (in 'a (ext 5 (rd)))
      -> ({A2} ({C4} . a) ({B7} . 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)