picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

refE.html (19216B)


      1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
      2 <html lang="en">
      3 <head>
      4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      5 <title>E</title>
      6 <link rel="stylesheet" href="doc.css" type="text/css">
      7 </head>
      8 <body>
      9 
     10 <h1>E</h1>
     11 
     12 <dl>
     13 
     14 <dt><a name="*Err"><code>*Err</code></a>
     15 <dd>A global variable holding a (possibly empty) <code>prg</code> body, which
     16 will be executed during error processing. See also <code><a
     17 href="ref.html#errors">Error Handling</a></code>, <code><a
     18 href="refM.html#*Msg">*Msg</a></code> and <code><a
     19 href="ref_.html#^">^</a></code>.
     20 
     21 <pre><code>
     22 : (de *Err (prinl "Fatal error!"))
     23 -> ((prinl "Fatal error!"))
     24 : (/ 3 0)
     25 !? (/ 3 0)
     26 Div/0
     27 Fatal error!
     28 $
     29 </code></pre>
     30 
     31 <dt><a name="*Ext"><code>*Ext</code></a>
     32 <dd>A global variable holding a sorted list of cons pairs. The CAR of each pair
     33 specifies an external symbol offset (suitable for <code><a
     34 href="refE.html#ext">ext</a></code>), and the CDR should be a function taking a
     35 single external symbol as an argument. This function should return a list, with
     36 the value for that symbol in its CAR, and the property list (in the format used
     37 by <code><a href="refG.html#getl">getl</a></code> and <code><a
     38 href="refP.html#putl">putl</a></code>) in its CDR. The symbol will be set to
     39 this value and property list upon access. Typically this function will access
     40 the corresponding symbol in a remote database process. See also <code><a
     41 href="refQ.html#qsym">qsym</a></code> and <code><a
     42 href="ref.html#external">external symbols</a></code>.
     43 
     44 <pre><code>
     45 ### On the local machine ###
     46 : (setq *Ext  # Define extension functions
     47    (mapcar
     48       '((@Host @Ext)
     49          (cons @Ext
     50             (curry (@Host @Ext (Sock)) (Obj)
     51                (when (or Sock (setq Sock (connect @Host 4040)))
     52                   (ext @Ext
     53                      (out Sock (pr (cons 'qsym Obj)))
     54                      (prog1 (in Sock (rd))
     55                         (unless @
     56                            (close Sock)
     57                            (off Sock) ) ) ) ) ) ) )
     58       '("10.10.12.1" "10.10.12.2" "10.10.12.3" "10.10.12.4")
     59       (20 40 60 80) ) )
     60 
     61 ### On the remote machines ###
     62 (de go ()
     63    ...
     64    (task (port 4040)                      # Set up background query server
     65       (let? Sock (accept @)               # Accept a connection
     66          (unless (fork)                   # In child process
     67             (in Sock
     68                (while (rd)                # Handle requests
     69                   (sync)
     70                   (out Sock
     71                      (pr (eval @)) ) ) )
     72             (bye) )                       # Exit child process
     73          (close Sock) ) )
     74    (forked)                               # Close task in children
     75    ...
     76 
     77 </code></pre>
     78 
     79 <dt><a name="+Entity"><code>+Entity</code></a>
     80 <dd>Base class of all database objects. See also <code><a
     81 href="refR.html#+relation">+relation</a></code> and <a
     82 href="ref.html#dbase">Database</a>.
     83 
     84 <p><a name="entityMesssages">Messages</a> to entity objects include
     85 
     86 <pre><code>
     87 zap> ()              # Clean up relational structures, for removal from the DB
     88 url> (Tab)           # Call the GUI on that object (in optional Tab)
     89 upd> (X Old)         # Callback method when object is created/modified/deleted
     90 has> (Var Val)       # Check if value is present
     91 put> (Var Val)       # Put a new value
     92 put!> (Var Val)      # Put a new value, single transaction
     93 del> (Var Val)       # Delete value (also partial)
     94 del!> (Var Val)      # Delete value (also partial), single transaction
     95 inc> (Var Val)       # Increment numeric value
     96 inc!> (Var Val)      # Increment numeric value, single transaction
     97 dec> (Var Val)       # Decrement numeric value
     98 dec!> (Var Val)      # Decrement numeric value, single transaction
     99 mis> (Var Val)       # Return error message if value or type mismatch
    100 lose1> (Var)         # Delete relational structures for a single attribute
    101 lose> (Lst)          # Delete relational structures (excluding 'Lst')
    102 lose!> ()            # Delete relational structures, single transaction
    103 keep1> (Var)         # Restore relational structures for single attribute
    104 keep> (Lst)          # Restore relational structures (excluding 'Lst')
    105 keep?> (Lst)         # Test for restauration (excluding 'Lst')
    106 keep!> ()            # Restore relational structures, single transaction
    107 set> (Val)           # Set the value (type, i.e. class list)
    108 set!> (Val)          # Set the value, single transaction
    109 clone> ()            # Object copy
    110 clone!> ()           # Object copy, single transaction
    111 </code></pre>
    112 
    113 <dt><a name="e"><code>(e . prg) -> any</code></a>
    114 <dd>Used in a breakpoint. Evaluates <code>prg</code> in the execution
    115 environment, or the currently executed expression if <code>prg</code> is not
    116 given. See also <code><a href="refD.html#debug">debug</a></code>, <code><a
    117 href="ref_.html#!">!</a></code>, <code><a href="ref_.html#^">^</a></code> and
    118 <code><a href="refD.html#*Dbg">*Dbg</a></code>.
    119 
    120 <pre><code>
    121 : (! + 3 4)
    122 (+ 3 4)
    123 ! (e)
    124 -> 7
    125 </code></pre>
    126 
    127 <dt><a name="echo"><code>(echo ['cnt ['cnt]] | ['sym ..]) -> sym</code></a>
    128 <dd>Reads the current input channel, and writes to the current output channel.
    129 If <code>cnt</code> is given, only that many bytes are actually echoed. In case
    130 of two <code>cnt</code> arguments, the first one specifies the number of bytes
    131 to skip in the input stream. Otherwise, if one or more <code>sym</code>
    132 arguments are given, the echo process stops as soon as one of the symbol's names
    133 is encountered in the input stream. In this case the name will be read and
    134 returned, but not written. Returns non-<code>NIL</code> if the operation was
    135 successfully completed. See also <code><a href="refF.html#from">from</a></code>.
    136 
    137 <pre><code>
    138 : (in "x.l" (echo))  # Display file on console
    139  ..
    140 
    141 : (out "x2.l" (in "x.l" (echo)))  # Copy file "x.l" to "x2.l"
    142 </code></pre>
    143 
    144 <dt><a name="edit"><code>(edit 'sym ..) -> NIL</code></a>
    145 <dd>(Debug mode only) Edits the value and property list of the argument
    146 symbol(s) by calling the <code>vim</code> editor on a temporary file with these
    147 data. When closing the editor, the modified data are read and stored into the
    148 symbol(s). During the edit session, individual symbols are separated by the
    149 pattern <code>(********)</code>. These separators should not be modified. When
    150 moving the cursor to the beginning of a symbol (no matter if internal, transient
    151 or external), and hitting '<code>K</code>', that symbol is added to the
    152 currently edited symbols. Hitting '<code>Q</code>' will go back one step and
    153 return to the previously edited list of symbols.
    154 
    155 <p><code>edit</code> is especially useful for browsing through the database
    156 (with '<code>K</code>' and '<code>Q</code>'), inspecting external symbols, but
    157 care must be taken when modifying any data as then the <a
    158 href="ref.html#er">entity/relation</a> mechanisms are circumvented, and
    159 <code><a href="refC.html#commit">commit</a></code> has to be called manually if
    160 the changes should be persistent.
    161 
    162 <p>Another typical use case is inserting or removing <code><a
    163 href="ref_.html#!">!</a></code> breakpoints at arbitrary code locations, or
    164 doing other temporary changes to the code for debugging purposes.
    165 
    166 <p>See also <code><a href="refU.html#update">update</a></code>, <code><a
    167 href="refS.html#show">show</a></code>, <code><a
    168 href="refV.html#vi">vi</a></code> and <code><a
    169 href="refE.html#em">em</a></code>.
    170 
    171 <pre><code>
    172 : (edit (db 'nr '+Item 1))  # Edit a database symbol
    173 ### 'vim' shows this ###
    174 {3-1} (+Item)
    175    nr 1
    176    inv 100
    177    pr 29900
    178    sup {2-1}  # (+CuSu)
    179    nm "Main Part"
    180 
    181 (********)
    182 ### Hitting 'K' on the '{' of '{2-1} ###
    183 {2-1} (+CuSu)
    184    nr 1
    185    plz "3425"
    186    mob "37 176 86303"
    187    tel "37 4967 6846-0"
    188    fax "37 4967 68462"
    189    nm "Active Parts Inc."
    190    nm2 "East Division"
    191    ort "Freetown"
    192    str "Wildcat Lane"
    193    em "info@api.tld"
    194 
    195 (********)
    196 
    197 {3-1} (+Item)
    198    nr 1
    199    inv 100
    200    pr 29900
    201    sup {2-1}  # (+CuSu)
    202    nm "Main Part"
    203 
    204 (********)
    205 ### Entering ':q' in vim ###
    206 -> NIL
    207 </code></pre>
    208 
    209 <dt><a name="em"><code>(em 'sym) -> sym</code></a>
    210 <dt><code>(em 'sym 'cls) -> sym</code>
    211 <dt><code>(em '(sym . cls)) -> sym</code>
    212 <dt><code>(em) -> NIL</code>
    213 <dd>(Debug mode only) Opens the "emacs" editor on the function or method
    214 definition of <code>sym</code>. A call to <code><a
    215 href="refL.html#ld">ld</a></code> thereafter will <code><a
    216 href="refL.html#load">load</a></code> the modified file. A call without
    217 arguments permanently switches the REPL line editor and the <code><a
    218 href="refE.html#edit">edit</a></code> function to "emacs" mode. See also
    219 <code><a href="refD.html#doc">doc</a></code>, <code><a
    220 href="refE.html#edit">edit</a></code>, <code><a
    221 href="refV.html#vi">vi</a></code>, <code><a
    222 href="refD.html#*Dbg">*Dbg</a></code>, <code><a
    223 href="refD.html#debug">debug</a></code> and <code><a
    224 href="refP.html#pp">pp</a></code>.
    225 
    226 <pre><code>
    227 : (em 'url> '+CuSu)  # Edit the method's source code, then exit from 'emacs'
    228 -> T
    229 </code></pre>
    230 
    231 <dt><a name="env"><code>(env ['lst] | ['sym 'val] ..) -> lst</code></a>
    232 <dd>Return a list of symbol-value pairs of all dynamically bound symbols if
    233 called without arguments, or of the symbols or symbol-value pairs in
    234 <code>lst</code>, or the explicitly given <code>sym</code>-<code>val</code>
    235 arguments. See also <code><a href="refB.html#bind">bind</a></code>, <code><a
    236 href="refJ.html#job">job</a></code>, <code><a
    237 href="refT.html#trail">trail</a></code> and <code><a
    238 href="refU.html#up">up</a></code>.
    239 
    240 <pre><code>
    241 : (env)
    242 -> NIL
    243 : (let (A 1 B 2) (env))
    244 -> ((A . 1) (B . 2))
    245 : (let (A 1 B 2) (env '(A B)))
    246 -> ((B . 2) (A . 1))
    247 : (let (A 1 B 2) (env 'X 7 '(A B (C . 3)) 'Y 8))
    248 -> ((Y . 8) (C . 3) (B . 2) (A . 1) (X . 7))
    249 </code></pre>
    250 
    251 <dt><a name="eof"><code>(eof ['flg]) -> flg</code></a>
    252 <dd>Returns the end-of-file status of the current input channel. If
    253 <code>flg</code> is non-<code>NIL</code>, the channel's status is forced to
    254 end-of-file, so that the next call to <code>eof</code> will return
    255 <code>T</code>, and calls to <code><a href="refC.html#char">char</a></code>,
    256 <code><a href="refP.html#peek">peek</a></code>, <code><a
    257 href="refL.html#line">line</a></code>, <code><a
    258 href="refF.html#from">from</a></code>, <code><a
    259 href="refT.html#till">till</a></code>, <code><a
    260 href="refR.html#read">read</a></code> or <code><a
    261 href="refS.html#skip">skip</a></code> will return <code>NIL</code>. Note that
    262 <code>eof</code> cannot be used with the binary <code><a
    263 href="refR.html#rd">rd</a></code> function. See also <code><a
    264 href="refE.html#eol">eol</a></code>.
    265 
    266 <pre><code>
    267 : (in "file" (until (eof) (println (line T))))
    268 ...
    269 </code></pre>
    270 
    271 <dt><a name="eol"><code>(eol) -> flg</code></a>
    272 <dd>Returns the end-of-line status of the current input channel.
    273 See also <code><a href="refE.html#eof">eof</a></code>.
    274 
    275 <pre><code>
    276 : (make (until (prog (link (read)) (eol))))  # Read line into a list
    277 a b c (d e f) 123
    278 -> (a b c (d e f) 123)
    279 </code></pre>
    280 
    281 <dt><a name="equal/2"><code>equal/2</code></a>
    282 <dd><a href="ref.html#pilog">Pilog</a> predicate that succeeds if the two
    283 arguments are equal. See also <code><a href="ref_.html#=">=</a></code>, <code><a
    284 href="refD.html#different/2">different/2</a></code> and <code><a
    285 href="refM.html#member/2">member/2</a></code>.
    286 
    287 <pre><code>
    288 : (? (equal 3 4))
    289 -> NIL
    290 : (? (equal @N 7))
    291  @N=7
    292 -> NIL
    293 </code></pre>
    294 
    295 <dt><a name="err"><code>(err 'sym . prg) -> any</code></a>
    296 <dd>Redirects the standard error stream to <code>sym</code> during the execution
    297 of <code>prg</code>. The current standard error stream will be saved and
    298 restored appropriately. If the argument is <code>NIL</code>, the current output
    299 stream will be used. Otherwise, <code>sym</code> is taken as a file name (opened
    300 in "append" mode if the first character is "+"), where standard error is to be
    301 written to. See also <code><a href="refI.html#in">in</a></code>, <code><a
    302 href="refO.html#out">out</a></code> and <code><a
    303 href="refC.html#ctl">ctl</a></code>.
    304 
    305 <pre><code>
    306 : (err "/dev/null"             # Suppress error messages
    307    (call 'ls 'noSuchFile) )
    308 -> NIL
    309 </code></pre>
    310 
    311 <dt><a name="errno"><code>(errno) -> cnt</code></a>
    312 <dd>(64-bit version only) Returns the value of the standard I/O 'errno'
    313 variable. See also <code><a href="refN.html#native">native</a></code>.
    314 
    315 <pre><code>
    316 : (in "foo")                           # Produce an error
    317 !? (in "foo")
    318 "foo" -- Open error: No such file or directory
    319 ? (errno)
    320 -> 2                                   # Returned 'ENOENT'
    321 </code></pre>
    322 
    323 <dt><a name="eval"><code>(eval 'any ['cnt ['lst]]) -> any</code></a>
    324 <dd>Evaluates <code>any</code>. Note that because of the standard argument
    325 evaluation, <code>any</code> is actually evaluated twice. If a binding
    326 environment offset <code>cnt</code> is given, the second evaluation takes place
    327 in the corresponding environment, and an optional <code>lst</code> of excluded
    328 symbols can be supplied. See also <code><a href="refR.html#run">run</a></code>
    329 and <code><a href="refU.html#up">up</a></code>.
    330 
    331 <pre><code>
    332 : (eval (list '+ 1 2 3))
    333 -> 6
    334 : (setq X 'Y  Y 7)
    335 -> 7
    336 : X
    337 -> Y
    338 : Y
    339 -> 7
    340 : (eval X)
    341 -> 7
    342 </code></pre>
    343 
    344 <dt><a name="expDat"><code>(expDat 'sym) -> dat</code></a>
    345 <dd>Expands a <code><a href="refD.html#date">date</a></code> string according to
    346 the current <code><a href="refL.html#locale">locale</a></code> (delimiter, and
    347 order of year, month and day). Accepts abbreviated input, without delimiter and
    348 with only the day, or the day and month, or the day, month and year of current
    349 century. See also <code><a href="refD.html#datStr">datStr</a></code>, <code><a
    350 href="refD.html#day">day</a></code>, <code><a
    351 href="refE.html#expTel">expTel</a></code>.
    352 
    353 <pre><code>
    354 : (date)
    355 -> 733133
    356 : (date (date))
    357 -> (2007 5 31)
    358 : (expDat "31")
    359 -> 733133
    360 : (expDat "315")
    361 -> 733133
    362 : (expDat "3105")
    363 -> 733133
    364 : (expDat "31057")
    365 -> 733133
    366 : (expDat "310507")
    367 -> 733133
    368 : (expDat "2007-05-31")
    369 -> 733133
    370 : (expDat "7-5-31")
    371 -> 733133
    372 
    373 : (locale "DE" "de")
    374 -> NIL
    375 : (expDat "31.5")
    376 -> 733133
    377 : (expDat "31.5.7")
    378 -> 733133
    379 </code></pre>
    380 
    381 <dt><a name="expTel"><code>(expTel 'sym) -> sym</code></a>
    382 <dd>Expands a telephone number string. Multiple spaces or hyphens are coalesced.
    383 A leading <code>+</code> or <code>00</code> is removed, a leading <code>0</code>
    384 is replaced with the current country code. Otherwise, <code>NIL</code> is
    385 returned. See also <code><a href="refT.html#telStr">telStr</a></code>, <code><a
    386 href="refE.html#expDat">expDat</a></code> and <code><a
    387 href="refL.html#locale">locale</a></code>.
    388 
    389 <pre><code>
    390 : (expTel "+49 1234 5678-0")
    391 -> "49 1234 5678-0"
    392 : (expTel "0049 1234 5678-0")
    393 -> "49 1234 5678-0"
    394 : (expTel "01234 5678-0")
    395 -> NIL
    396 : (locale "DE" "de")
    397 -> NIL
    398 : (expTel "01234 5678-0")
    399 -> "49 1234 5678-0"
    400 </code></pre>
    401 
    402 <dt><a name="expr"><code>(expr 'sym) -> fun</code></a>
    403 <dd>Converts a C-function ("subr") to a Lisp-function. Useful only for normal
    404 functions (i.e. functions that evaluate all arguments). See also <code><a
    405 href="refS.html#subr">subr</a></code>.
    406 
    407 <pre><code>
    408 : car
    409 -> 67313448
    410 : (expr 'car)
    411 -> (@ (pass $385260187))
    412 : (car (1 2 3))
    413 -> 1
    414 </code></pre>
    415 
    416 <dt><a name="ext"><code>(ext 'cnt . prg) -> any</code></a>
    417 <dd>During the execution of <code>prg</code>, all <code><a
    418 href="ref.html#external">external symbols</a></code> processed by <code><a
    419 href="refR.html#rd">rd</a></code>, <code><a href="refP.html#pr">pr</a></code> or
    420 <code><a href="refU.html#udp">udp</a></code> are modified by an offset
    421 <code>cnt</code> suitable for mapping via the <code><a
    422 href="refE.html#*Ext">*Ext</a></code> mechanism. All external symbol's file
    423 numbers are decremented by <code>cnt</code> during output, and incremented by
    424 <code>cnt</code> during input.
    425 
    426 <pre><code>
    427 : (out 'a (ext 5 (pr '({6-2} ({8-9} . a) ({7-7} . b)))))
    428 -> ({6-2} ({8-9} . a) ({7-7} . b))
    429 
    430 : (in 'a (rd))
    431 -> ({2} ({3-9} . a) ({2-7} . b))
    432 
    433 : (in 'a (ext 5 (rd)))
    434 -> ({6-2} ({8-9} . a) ({7-7} . b))
    435 </code></pre>
    436 
    437 <dt><a name="ext?"><code>(ext? 'any) -> sym | NIL</code></a>
    438 <dd>Returns the argument <code>any</code> when it is an existing external
    439 symbol, otherwise <code>NIL</code>. See also <code><a
    440 href="refS.html#sym?">sym?</a></code>, <code><a
    441 href="refB.html#box?">box?</a></code>, <code><a
    442 href="refS.html#str?">str?</a></code>, <code><a
    443 href="refE.html#extern">extern</a></code> and <code><a
    444 href="refL.html#lieu">lieu</a></code>.
    445 
    446 <pre><code>
    447 : (ext? *DB)
    448 -> {1}
    449 : (ext? 'abc)
    450 -> NIL
    451 : (ext? "abc")
    452 -> NIL
    453 : (ext? 123)
    454 -> NIL
    455 </code></pre>
    456 
    457 <dt><a name="extend"><code>(extend cls) -> cls</code></a>
    458 <dd>Extends the class <code>cls</code>, by storing it in the global variable
    459 <code><a href="refC.html#*Class">*Class</a></code>. As a consequence, all
    460 following method, relation and class variable definitions are applied to that
    461 class. See also <a href="ref.html#oop">OO Concepts</a>, <code><a
    462 href="refC.html#class">class</a></code>, <code><a
    463 href="refD.html#dm">dm</a></code>, <code><a href="refV.html#var">var</a></code>,
    464 <code><a href="refR.html#rel">rel</a></code>, <code><a
    465 href="refT.html#type">type</a></code> and <code><a
    466 href="refI.html#isa">isa</a></code>.
    467 
    468 <pre><code>
    469 </code></pre>
    470 
    471 <dt><a name="extern"><code>(extern 'sym) -> sym | NIL</code></a>
    472 <dd>Creates or finds an external symbol. If a symbol with the name
    473 <code>sym</code> is already extern, it is returned. Otherwise, a new external
    474 symbol is returned. <code>NIL</code> is returned if <code>sym</code> does not
    475 exist in the database. See also <code><a
    476 href="refI.html#intern">intern</a></code> and <code><a
    477 href="refE.html#ext?">ext?</a></code>.
    478 
    479 <pre><code>
    480 : (extern "A1b")
    481 -> {A1b}
    482 : (extern "{A1b}")
    483 -> {A1b}
    484 </code></pre>
    485 
    486 <dt><a name="extra"><code>(extra ['any ..]) -> any</code></a>
    487 <dd>Can only be used inside methods. Sends the current message to the current
    488 object <code>This</code>, this time starting the search for a method at the
    489 remaining branches of the inheritance tree of the class where the current method
    490 was found. See also <a href="ref.html#oop">OO Concepts</a>, <code><a
    491 href="refS.html#super">super</a></code>, <code><a
    492 href="refM.html#method">method</a></code>, <code><a
    493 href="refM.html#meth">meth</a></code>, <code><a
    494 href="refS.html#send">send</a></code> and <code><a
    495 href="refT.html#try">try</a></code>.
    496 
    497 <pre><code>
    498 (dm key> (C)            # 'key>' method of the '+Uppc' class
    499    (uppc (extra C)) )   # Convert 'key>' of extra classes to upper case
    500 </code></pre>
    501 
    502 <dt><a name="extract"><code>(extract 'fun 'lst ..) -> lst</code></a>
    503 <dd>Applies <code>fun</code> to each element of <code>lst</code>. When
    504 additional <code>lst</code> arguments are given, their elements are also passed
    505 to <code>fun</code>. Returns a list of all non-<code>NIL</code> values returned
    506 by <code>fun</code>. <code>(extract 'fun 'lst)</code> is equivalent to
    507 <code>(mapcar 'fun (filter 'fun 'lst))</code> or, for non-NIL results, to
    508 <code>(mapcan '((X) (and (fun X) (cons @))) 'lst)</code>. See also <code><a
    509 href="refF.html#filter">filter</a></code>, <code><a
    510 href="refF.html#find">find</a></code>, <code><a
    511 href="refP.html#pick">pick</a></code> and <code><a
    512 href="refM.html#mapcan">mapcan</a></code>.
    513 
    514 <pre><code>
    515 : (setq A NIL  B 1  C NIL  D 2  E NIL  F 3)
    516 -> 3
    517 : (filter val '(A B C D E F))
    518 -> (B D F)
    519 : (extract val '(A B C D E F))
    520 -> (1 2 3)
    521 </code></pre>
    522 
    523 </dl>
    524 
    525 </body>
    526 </html>