File: refO.html

package info (click to toggle)
picolisp 25.12-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,388 kB
  • sloc: ansic: 3,092; javascript: 1,004; makefile: 107; sh: 2
file content (341 lines) | stat: -rw-r--r-- 11,297 bytes parent folder | download | duplicates (3)
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
<!--
# VIP @lib/vip/html.l
# 26oct23 Software Lab. Alexander Burger
-->

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>O</title>
<link rel="stylesheet" href="doc.css" type="text/css">
</head>
<body>

<h1>O</h1>

<dl>

<dt><a id="*ObjIdx"><code>*ObjIdx</code></a></dt>
<dd>Holds an <code><a href="refI.html#idx">idx</a></code> tree of objects
created by <code><a href="refO.html#obj">obj</a></code>.

<pre>
</pre></dd>

<dt><a id="*Once"><code>*Once</code></a></dt>
<dd>Holds an <code><a href="refI.html#idx">idx</a></code> tree of already
<code><a href="refL.html#load">load</a></code>ed source locations (as returned
by <code><a href="refF.html#file">file</a></code>) See also <code><a
href="refO.html#once">once</a></code>.

<pre>
: *Once
-> (("lib/" "misc.l" . 11) (("lib/" "http.l" . 9) (("lib/" "form.l" . 11))))
</pre></dd>

<dt><a id="*OS"><code>*OS</code></a></dt>
<dd>A global constant holding the name of the operating system. Possible values
include <code>"Linux"</code>, <code>"Android"</code>, <code>"FreeBSD"</code>,
<code>"OpenBSD"</code>, <code>"SunOS"</code>, <code>"Darwin"</code> or
<code>"Cygwin"</code>. See also <code><a href="refC.html#*CPU">*CPU</a></code>
and <code><a href="refV.html#version">version</a></code>.

<pre>
: *OS
-> "Linux"
</pre></dd>

<dt><a id="obj"><code>(obj (typ sym [hook] val ..) [var1 val1 ..]) -> obj</code></a></dt>
<dt><code>(obj typ any [var1 val1 ..]) -> obj</code></dt>
<dd>Finds or creates a database object, and initializes additional properties
using the <code>varN</code> and <code>valN</code> arguments. In the first form,
a <code><a href="refR.html#request">request</a></code> for <code>(typ sym [hook]
val ..)</code> is called, while the second form uses <code><a
href="refC.html#cache">cache</a></code> to maintain objects without unique
<code><a href="refK.html#+Key">+Key</a></code>s by indexing <code><a
href="refO.html#*ObjIdx">*ObjIdx</a></code> with the <code>any</code> argument.

<pre>
: (obj ((+Item) nr 2) nm "Spare Part" sup `(db 'nr '+CuSu 2) inv 100 pr 1250)
-> {B2}
</pre></dd>

<dt><a id="object"><code>(object 'sym 'any ['sym2 'any2 ..]) -> obj</code></a></dt>
<dd>Defines <code>sym</code> to be an object with the value (or type)
<code>any</code>. The property list is initialized with all optionally supplied
key-value pairs. See also <a href="ref.html#oop">OO Concepts</a>, <code><a
href="refN.html#new">new</a></code>, <code><a
href="refT.html#type">type</a></code> and <code><a
href="refI.html#isa">isa</a></code>.

<pre>
: (object 'Obj '(+A +B +C) 'a 1 'b 2 'c 3)
-> Obj
: (show 'Obj)
Obj (+A +B +C)
   c 3
   b 2
   a 1
-> Obj
</pre></dd>

<dt><a id="oct"><code>(oct 'num ['num]) -> sym</code></a></dt>
<dt><code>(oct 'sym) -> num</code></dt>
<dd>Converts a number <code>num</code> to an octal string, or an octal string
<code>sym</code> to a number. In the first case, if the second argument is
given, the result is separated by spaces into groups of such many digits. See
also <code><a href="refB.html#bin">bin</a></code>, <code><a
href="refH.html#hex">hex</a></code>, <code><a
href="refH.html#hax">hax</a></code> and <code><a
href="refF.html#format">format</a></code>.

<pre>
: (oct 73)
-> "111"
: (oct "111")
-> 73
: (oct 1234567 3)
-> "4 553 207"
</pre></dd>

<dt><a id="off"><code>(off var ..) -> NIL</code></a></dt>
<dd>Stores <code>NIL</code> in all <code>var</code> arguments. See also <code><a
href="refO.html#on">on</a></code>, <code><a
href="refO.html#onOff">onOff</a></code>, <code><a
href="refZ.html#zero">zero</a></code> and <code><a
href="refO.html#one">one</a></code>.

<pre>
: (off A B)
-> NIL
: A
-> NIL
: B
-> NIL
</pre></dd>

<dt><a id="offset"><code>(offset 'lst1 'lst2) -> cnt | NIL</code></a></dt>
<dd>Returns the <code>cnt</code> position of the tail list <code>lst1</code> in
<code>lst2</code>, or <code>NIL</code> if it is not found. See also <code><a
href="refI.html#index">index</a></code>, <code><a
href="refS.html#sub?">sub?</a></code> and <code><a
href="refT.html#tail">tail</a></code>.

<pre>
: (offset '(c d e f) '(a b c d e f))
-> 3
: (offset '(c d e) '(a b c d e f))
-> NIL
</pre></dd>

<dt><a id="on"><code>(on var ..) -> T</code></a></dt>
<dd>Stores <code>T</code> in all <code>var</code> arguments. See also <code><a
href="refO.html#off">off</a></code>, <code><a
href="refO.html#onOff">onOff</a></code>, <code><a
href="refZ.html#zero">zero</a></code> and <code><a
href="refO.html#one">one</a></code>.

<pre>
: (on A B)
-> T
: A
-> T
: B
-> T
</pre></dd>

<dt><a id="once"><code>(once . prg) -> any</code></a></dt>
<dd>Executes <code>prg</code> once, when the current file is <code><a
href="refL.html#load">load</a></code>ed the first time. Subsequent loads at a
later time will not execute <code>prg</code>, and <code>once</code> returns
<code>NIL</code>. See also <code><a href="refO.html#*Once">*Once</a></code> and
<code><a href="refF.html#finish">finish</a></code>.

<pre>
(once
   (zero *Cnt1 *Cnt2)  # Init counters
   (load "file1.l" "file2.l") )  # Load other files

`(once T)  # Ignore next time the rest of this file
</pre></dd>

<dt><a id="one"><code>(one var ..) -> 1</code></a></dt>
<dd>Stores <code>1</code> in all <code>var</code> arguments. See also <code><a
href="refZ.html#zero">zero</a></code>, <code><a
href="refO.html#on">on</a></code>, <code><a href="refO.html#off">off</a></code>
and <code><a href="refO.html#onOff">onOff</a></code>.

<pre>
: (one A B)
-> 1
: A
-> 1
: B
-> 1
</pre></dd>

<dt><a id="onOff"><code>(onOff var ..) -> flg</code></a></dt>
<dd>Logically negates the values of all <code>var</code> arguments. Returns the
new value of the last symbol. See also <code><a
href="refO.html#on">on</a></code>, <code><a href="refO.html#off">off</a></code>,
<code><a href="refZ.html#zero">zero</a></code> and <code><a
href="refO.html#one">one</a></code>.

<pre>
: (onOff A B)
-> T
: A
-> T
: B
-> T
: (onOff A B)
-> NIL
: A
-> NIL
: B
-> NIL
</pre></dd>

<dt><a id="open"><code>(open 'any ['flg]) -> cnt | NIL</code></a></dt>
<dd>Opens the file with the name <code>any</code> in read/write mode (or
read-only if <code>flg</code> is non-<code>NIL</code>), and returns a file
descriptor <code>cnt</code> (or <code>NIL</code> on error). A leading
"<code>@</code>" character in <code>any</code> is substituted with the
<u>PicoLisp Home Directory</u>, as it was remembered during interpreter startup.
If <code>flg</code> is <code>NIL</code> and the file does not exist, it is
created. The file descriptor can be used in subsequent calls to <code><a
href="refI.html#in">in</a></code> and <code><a
href="refO.html#out">out</a></code>. See also <code><a
href="refC.html#close">close</a></code> and <code><a
href="refP.html#poll">poll</a></code>.

<pre>
: (open "x")
-> 3
</pre></dd>

<dt><a id="opid"><code>(opid) -> pid | NIL</code></a></dt>
<dd>Returns the corresponding process ID when the current output channel is
writing to a pipe, otherwise <code>NIL</code>. See also <code><a
href="refI.html#ipid">ipid</a></code> and <code><a
href="refO.html#out">out</a></code>.

<pre>
: (out '(cat) (call 'ps "-p" (opid)))
  PID TTY          TIME CMD
 7127 pts/3    00:00:00 cat
-> T
</pre></dd>

<dt><a id="opt"><code>(opt) -> sym</code></a></dt>
<dd>Return the next command line argument ("option", as would be processed by
<code><a href="refL.html#load">load</a></code>) as a string, and remove it from
the remaining command line arguments. See also <a
href="ref.html#invoc">Invocation</a> and <code><a
href="refA.html#argv">argv</a></code>.

<pre>
$ pil  -"de f () (println 'opt (opt))"  -f abc  -bye
opt "abc"
</pre></dd>

<dt><a id="or"><code>(or 'any ..) -> any</code></a></dt>
<dd>Logical OR. The expressions <code>any</code> are evaluated from left to
right. If a non-<code>NIL</code> value is encountered, it is returned
immediately. Else the result of the last expression is returned. See also
<code><a href="refN.html#nor">nor</a></code>, <code><a
href="refA.html#and">and</a></code> and <code><a
href="refU.html#unless">unless</a></code>.

<pre>
: (or (= 3 3) (read))
-> T
: (or (= 3 4) (read))
abc
-> abc
</pre></dd>

<dt><a id="or/2"><code>or/2</code></a></dt>
<dd><a href="ref.html#pilog">Pilog</a> predicate that takes an arbitrary number
of clauses, and succeeds if one of them can be proven. See also <code><a
href="refN.html#not/1">not/1</a></code>.

<pre>
: (?
   (or
      ((equal 3 @X) (equal @X 4))
      ((equal 7 @X) (equal @X 7)) ) )
 @X=7
-> NIL
</pre></dd>

<dt><a id="out"><code>(out 'any . prg) -> any</code></a></dt>
<dd>Opens <code>any</code> as output channel during the execution of
<code>prg</code>. The current output channel will be saved and restored
appropriately. If the argument is <code>NIL</code>, standard output is used. If
the argument is a symbol, it is used as a file name (opened in read/write-append
mode if the first character is "<code>+</code>"). If it is a positive number, it
is used as the descriptor of an open file. If it is a negative number, the saved
output channel such many levels above the current one is used. Otherwise (if it
is a list), it is taken as a command with arguments, and a pipe is opened for
output. The (system dependent) exit status code of the child process is stored
in the global variable <code><a href="ref_.html#@@">@@</a></code>. In all cases,
<code><a href="refF.html#flush">flush</a></code> is called when <code>prg</code>
is done. See also <code><a href="refI.html#in">in</a></code>, <code> <a
href="refE.html#err">err</a></code>, <code> <a
href="refF.html#fd">fd</a></code>, <code><a
href="refO.html#opid">opid</a></code>, <code> <a
href="refC.html#call">call</a></code>, <code><a
href="refC.html#ctl">ctl</a></code>, <code><a
href="refP.html#pipe">pipe</a></code>, <code> <a
href="refP.html#poll">poll</a></code>, <code> <a
href="refC.html#close">close</a></code> and <code><a
href="refL.html#load">load</a></code>.

<pre>
: (out "a" (println 123 '(a b c) 'def))  # Write one line to file "a"
-> def
: (out '(lpr) (prinl "Hello"))  # Send line to line printer
-> "Hello"
</pre></dd>

<dt><a id="output"><code>(output exe . prg) -> any</code></a></dt>
<dd>Establishes an output stream, by redirecting the current output channel
during the execution of <code>prg</code>. The current output channel will be
saved and restored appropriately. <code>exe</code> is executed (in the context
of the original output channel) whenever a character needs to be output by print
calls in <code>prg</code>. That character is passed in the global variable
<code><a href="ref_.html#@@">@@</a></code>, and the following character in the
stream in <code><a href="ref_.html#@@@">@@@</a></code> (single-character
look-ahead). See also <code><a href="refI.html#input">input</a></code>, <code><a
href="refO.html#out">out</a></code> and <code><a
href="refP.html#pipe">pipe</a></code>.

<pre>
: (output (prin (uppc @@)) (prinl "abc"))
ABC
-> "abc"
: (output (println @@ @@@) (prin "abc"))
"a" "b"
"b" "c"
"c" NIL
-> "abc"
: (pack
   (make
      (output (link @@)
         (print '(+ 2 (* 3 4))) ) ) )
-> "(+ 2 (* 3 4))"
: (pack
   (make
      (let L (1 2 3 4 5 6 7)
         (output (link @@)
            (while L
               (ext:Base64 (++ L) (++ L) (++ L)) ) ) ) ) )
-> "AQIDBAUGBw=="
</pre></dd>

</dl>

</body>
</html>