File: refE.html

package info (click to toggle)
picolisp 3.1.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,100 kB
  • sloc: ansic: 14,205; lisp: 795; makefile: 290; sh: 13
file content (501 lines) | stat: -rw-r--r-- 18,148 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>E</title>
<link rel="stylesheet" href="doc.css" type="text/css">
</head>
<body>

<h1>E</h1>

<dl>

<dt><a name="*Err"><code>*Err</code></a>
<dd>A global variable holding a (possibly empty) <code>prg</code> body, which
will be executed during error processing. See also <code><a
href="ref.html#errors">Error Handling</a></code>, <code><a
href="refM.html#*Msg">*Msg</a></code> and <code><a
href="ref_.html#^">^</a></code>.

<pre><code>
: (de *Err (prinl "Fatal error!"))
-> ((prinl "Fatal error!"))
: (/ 3 0)
!? (/ 3 0)
Div/0
Fatal error!
$
</code></pre>

<dt><a name="*Ext"><code>*Ext</code></a>
<dd>A global variable holding a sorted list of cons pairs. The CAR of each pair
specifies an external symbol offset (suitable for <code><a
href="refE.html#ext">ext</a></code>), 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 <code><a href="refG.html#getl">getl</a></code> and <code><a
href="refP.html#putl">putl</a></code>) 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 <code><a
href="refQ.html#qsym">qsym</a></code> and <code><a
href="ref.html#external">external symbols</a></code>.

<pre><code>
### 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)
                  (out Sock
                     (pr (eval @)) ) ) )
            (bye) )                       # Exit child process
         (close Sock) ) )
   (forked)                               # Close task in children
   ...

</code></pre>

<dt><a name="+Entity"><code>+Entity</code></a>
<dd>Base class of all database objects. See also <code><a
href="refR.html#+relation">+relation</a></code> and <code><a
href="ref.html#dbase">Database</a></code>.

<p><a name="entityMesssages">Messages</a> to entity objects include

<pre><code>
zap> ()              # Clean up relational structures, for removal from the DB
url> (Tab)           # Call the GUI on that object (in optional Tab)
upd> (X Old)         # Callback method when object is created/modified/deleted
has> (Var Val)       # Check if value is present
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
</code></pre>

<dt><a name="e"><code>(e . prg) -> any</code></a>
<dd>Used in a breakpoint. Evaluates <code>prg</code> in the execution
environment, or the currently executed expression if <code>prg</code> is not
given. See also <code><a href="refD.html#debug">debug</a></code>, <code><a
href="ref_.html#!">!</a></code>, <code><a href="ref_.html#^">^</a></code> and
<code><a href="refD.html#*Dbg">*Dbg</a></code>.

<pre><code>
: (! + 3 4)
(+ 3 4)
! (e)
-> 7
</code></pre>

<dt><a name="echo"><code>(echo ['cnt ['cnt]] | ['sym ..]) -> sym</code></a>
<dd>Reads the current input channel, and writes to the current output channel.
If <code>cnt</code> is given, only that many bytes are actually echoed. In case
of two <code>cnt</code> arguments, the first one specifies the number of bytes
to skip in the input stream. Otherwise, if one or more <code>sym</code>
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-<code>NIL</code> if the operation was
successfully completed. See also <code><a href="refF.html#from">from</a></code>.

<pre><code>
: (in "x.l" (echo))  # Display file on console
 ..

: (out "x2.l" (in "x.l" (echo)))  # Copy file "x.l" to "x2.l"
</code></pre>

<dt><a name="edit"><code>(edit 'sym ..) -> NIL</code></a>
<dd>Edits the value and property list of the argument symbol(s) by calling the
<code>vim</code> 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
<code>(********)</code>. 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 '<code>K</code>', that symbol is added to the currently
edited symbols. Hitting '<code>Q</code>' will go back one step and return to the
previously edited list of symbols.

<p><code>edit</code> is especially useful for browsing through the database
(with '<code>K</code>' and '<code>Q</code>'), inspecting external symbols, but
care must be taken when modifying any data as then the <a
href="ref.html#er">entity/relation</a> mechanisms are circumvented, and
<code><a href="refC.html#commit">commit</a></code> has to be called manually if
the changes should be persistent.

<p>Another typical use case is inserting or removing <code><a
href="ref_.html#!">!</a></code> breakpoints at arbitrary code locations, or
doing other temporary changes to the code for debugging purposes.

<p>See also <code><a href="refU.html#update">update</a></code>, <code><a
href="refS.html#show">show</a></code> and <code><a
href="refV.html#vi">vi</a></code>.

<pre><code>
: (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
</code></pre>

<dt><a name="env"><code>(env ['lst] | ['sym 'val] ..) -> lst</code></a>
<dd>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
<code>lst</code>, or the explicitly given <code>sym</code>-<code>val</code>
arguments. See also <code><a href="refB.html#bind">bind</a></code> and <code><a
href="refJ.html#job">job</a></code>.

<pre><code>
: (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))
</code></pre>

<dt><a name="eof"><code>(eof ['flg]) -> flg</code></a>
<dd>Returns the end-of-file status of the current input channel. If
<code>flg</code> is non-<code>NIL</code>, the channel's status is forced to
end-of-file, so that the next call to <code>eof</code> will return
<code>T</code>, and calls to <code><a href="refC.html#char">char</a></code>,
<code><a href="refP.html#peek">peek</a></code>, <code><a
href="refL.html#line">line</a></code>, <code><a
href="refF.html#from">from</a></code>, <code><a
href="refT.html#till">till</a></code>, <code><a
href="refR.html#read">read</a></code> or <code><a
href="refS.html#skip">skip</a></code> will return <code>NIL</code>. Note that
<code>eof</code> cannot be used with the binary <code><a
href="refR.html#rd">rd</a></code> function. See also <code><a
href="refE.html#eol">eol</a></code>.

<pre><code>
: (in "file" (until (eof) (println (line T))))
...
</code></pre>

<dt><a name="eol"><code>(eol) -> flg</code></a>
<dd>Returns the end-of-line status of the current input channel.
See also <code><a href="refE.html#eof">eof</a></code>.

<pre><code>
: (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)
</code></pre>

<dt><a name="equal/2"><code>equal/2</code></a>
<dd><a href="ref.html#pilog">Pilog</a> predicate that succeeds if the two
arguments are equal. See also <code><a href="ref_.html#=">=</a></code>, <code><a
href="refD.html#different/2">different/2</a></code> and <code><a
href="refM.html#member/2">member/2</a></code>.

<pre><code>
: (? (equal 3 4))
-> NIL
: (? (equal @N 7))
 @N=7
-> NIL
</code></pre>

<dt><a name="err"><code>(err 'sym . prg) -> any</code></a>
<dd>Redirects the standard error stream to <code>sym</code> during the execution
of <code>prg</code>. The current standard error stream will be saved and
restored appropriately. If the argument is <code>NIL</code>, the current output
stream will be used. Otherwise, <code>sym</code> 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 <code><a href="refI.html#in">in</a></code>, <code><a
href="refO.html#out">out</a></code> and <code><a
href="refC.html#ctl">ctl</a></code>.

<pre><code>
: (err "/dev/null"             # Suppress error messages
   (call 'ls 'noSuchFile) )
-> NIL
</code></pre>

<dt><a name="errno"><code>(errno) -> cnt</code></a>
<dd>(64-bit version only) Returns the value of the standard I/O 'errno'
variable. See also <code><a href="refN.html#native">native</a></code>.

<pre><code>
: (in "foo")                           # Produce an error
!? (in "foo")
"foo" -- Open error: No such file or directory
? (errno)
-> 2                                   # Returned 'ENOENT'
</code></pre>

<dt><a name="eval"><code>(eval 'any ['cnt ['lst]]) -> any</code></a>
<dd>Evaluates <code>any</code>. Note that because of the standard argument
evaluation, <code>any</code> is actually evaluated twice. If a binding
environment offset <code>cnt</code> is given, the second evaluation takes place
in the corresponding environment, and an optional <code>lst</code> of excluded
symbols can be supplied. See also <code><a href="refR.html#run">run</a></code>
and <code><a href="refU.html#up">up</a></code>.

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

<dt><a name="expDat"><code>(expDat 'sym) -> dat</code></a>
<dd>Expands a <code><a href="refD.html#date">date</a></code> string according to
the current <code><a href="refL.html#locale">locale</a></code> (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. See also <code><a href="refD.html#datStr">datStr</a></code>, <code><a
href="refD.html#day">day</a></code>, <code><a
href="refE.html#expTel">expTel</a></code>.

<pre><code>
: (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
</code></pre>

<dt><a name="expTel"><code>(expTel 'sym) -> sym</code></a>
<dd>Expands a telephone number string. Multiple spaces or hyphens are coalesced.
A leading <code>+</code> or <code>00</code> is removed, a leading <code>0</code>
is replaced with the current country code. Otherwise, <code>NIL</code> is
returned. See also <code><a href="refT.html#telStr">telStr</a></code>, <code><a
href="refE.html#expDat">expDat</a></code> and <code><a
href="refL.html#locale">locale</a></code>.

<pre><code>
: (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"
</code></pre>

<dt><a name="expr"><code>(expr 'sym) -> fun</code></a>
<dd>Converts a C-function ("subr") to a Lisp-function. Useful only for normal
functions (i.e. functions that evaluate all arguments). See also <code><a
href="refS.html#subr">subr</a></code>.

<pre><code>
: car
-> 67313448
: (expr 'car)
-> (@ (pass $385260187))
: (car (1 2 3))
-> 1
</code></pre>

<dt><a name="ext"><code>(ext 'cnt . prg) -> any</code></a>
<dd>During the execution of <code>prg</code>, all <code><a
href="ref.html#external">external symbols</a></code> processed by <code><a
href="refR.html#rd">rd</a></code>, <code><a href="refP.html#pr">pr</a></code> or
<code><a href="refU.html#udp">udp</a></code> are modified by an offset
<code>cnt</code> suitable for mapping via the <code><a
href="refE.html#*Ext">*Ext</a></code> mechanism. All external symbol's file
numbers are decremented by <code>cnt</code> during output, and incremented by
<code>cnt</code> during input.

<pre><code>
: (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))
</code></pre>

<dt><a name="ext?"><code>(ext? 'any) -> sym | NIL</code></a>
<dd>Returns the argument <code>any</code> when it is an existing external
symbol, otherwise <code>NIL</code>. See also <code><a
href="refS.html#sym?">sym?</a></code>, <code><a
href="refB.html#box?">box?</a></code>, <code><a
href="refS.html#str?">str?</a></code>, <code><a
href="refE.html#extern">extern</a></code> and <code><a
href="refL.html#lieu">lieu</a></code>.

<pre><code>
: (ext? *DB)
-> {1}
: (ext? 'abc)
-> NIL
: (ext? "abc")
-> NIL
: (ext? 123)
-> NIL
</code></pre>

<dt><a name="extend"><code>(extend cls) -> cls</code></a>
<dd>Extends the class <code>cls</code>, by storing it in the global variable
<code><a href="refC.html#*Class">*Class</a></code>. As a consequence, all
following method, relation and class variable definitions are applied to that
class. See also <code><a href="ref.html#oop">OO Concepts</a></code>, <code><a
href="refC.html#class">class</a></code>, <code><a
href="refD.html#dm">dm</a></code>, <code><a href="refV.html#var">var</a></code>,
<code><a href="refR.html#rel">rel</a></code>, <code><a
href="refT.html#type">type</a></code> and <code><a
href="refI.html#isa">isa</a></code>.

<pre><code>
</code></pre>

<dt><a name="extern"><code>(extern 'sym) -> sym | NIL</code></a>
<dd>Creates or finds an external symbol. If a symbol with the name
<code>sym</code> is already extern, it is returned. Otherwise, a new external
symbol is returned. <code>NIL</code> is returned if <code>sym</code> does not
exist in the database. See also <code><a
href="refI.html#intern">intern</a></code> and <code><a
href="refE.html#ext?">ext?</a></code>.

<pre><code>
: (extern "A1b")
-> {A1b}
: (extern "{A1b}")
-> {A1b}
</code></pre>

<dt><a name="extra"><code>(extra ['any ..]) -> any</code></a>
<dd>Can only be used inside methods. Sends the current message to the current
object <code>This</code>, 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 <code><a href="ref.html#oop">OO Concepts</a></code>,
<code><a href="refS.html#super">super</a></code>, <code><a
href="refM.html#method">method</a></code>, <code><a
href="refM.html#meth">meth</a></code>, <code><a
href="refS.html#send">send</a></code> and <code><a
href="refT.html#try">try</a></code>.

<pre><code>
(dm key> (C)            # 'key>' method of the '+Uppc' class
   (uppc (extra C)) )   # Convert 'key>' of extra classes to upper case
</code></pre>

<dt><a name="extract"><code>(extract 'fun 'lst ..) -> lst</code></a>
<dd>Applies <code>fun</code> to each element of <code>lst</code>. When
additional <code>lst</code> arguments are given, their elements are also passed
to <code>fun</code>. Returns a list of all non-<code>NIL</code> values returned
by <code>fun</code>. <code>(extract 'fun 'lst)</code> is equivalent to
<code>(mapcar 'fun (filter 'fun 'lst))</code> or, for non-NIL results, to
<code>(mapcan '((X) (and (fun X) (cons @))) 'lst)</code>. See also <code><a
href="refF.html#filter">filter</a></code>, <code><a
href="refF.html#find">find</a></code>, <code><a
href="refP.html#pick">pick</a></code> and <code><a
href="refM.html#mapcan">mapcan</a></code>.

<pre><code>
: (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)
</code></pre>

</dl>

</body>
</html>