File: INTERN.html

package info (click to toggle)
acl2 3.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 36,712 kB
  • ctags: 38,396
  • sloc: lisp: 464,023; makefile: 5,470; sh: 86; csh: 47; cpp: 25; ansic: 22
file content (46 lines) | stat: -rw-r--r-- 2,357 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
<html>
<head><title>INTERN.html  --  ACL2 Version 3.1</title></head>
<body text=#000000 bgcolor="#FFFFFF">
<h2>INTERN</h2>create a new symbol in a given package
<pre>Major Section:  <a href="PROGRAMMING.html">PROGRAMMING</a>
</pre><p>

<code>(intern symbol-name symbol-package-name)</code> returns a symbol with
the given <code><a href="SYMBOL-NAME.html">symbol-name</a></code> and the given <code><a href="SYMBOL-PACKAGE-NAME.html">symbol-package-name</a></code>.  We
restrict Common Lisp's <code>intern</code> so that the second argument is
either the symbol *main-lisp-package-name*, the value of that
constant, or is one of "ACL2", "ACL2-INPUT-CHANNEL",
"ACL2-OUTPUT-CHANNEL", or "KEYWORD".  To avoid that restriction,
see <a href="INTERN$.html">intern$</a>.
<p>
In ACL2 <code>intern</code> is actually implemented as a macro that expands to
a call of a similar function whose second argument is a symbol.
Invoke <code>:pe intern</code> to see the definition, or
see <a href="INTERN-IN-PACKAGE-OF-SYMBOL.html">intern-in-package-of-symbol</a>.<p>

To see why is <code>intern</code> so restricted consider
<code>(intern "X" "P")</code>.  In particular, is it a symbol and if so,
what is its <code><a href="SYMBOL-PACKAGE-NAME.html">symbol-package-name</a></code>?  One is tempted to say ``yes, it
is a symbol in the package <code>"P"</code>.''  But if package <code>"P"</code> has
not yet been defined, that would be premature because the imports to
the package are unknown.  For example, if <code>"P"</code> were introduced
with

<pre>
(defpkg "P" '(LISP::X)) 
</pre>

then in Common Lisp <code>(symbol-package-name (intern "X" "P"))</code> returns
<code>"LISP"</code>.<p>

The obvious restriction on <code>intern</code> is that its second argument be
the name of a package known to ACL2.  We cannot express such a
restriction (except, for example, by limiting it to those packages
known at some fixed time, as we do).  Instead, we provide
<code><a href="INTERN-IN-PACKAGE-OF-SYMBOL.html">intern-in-package-of-symbol</a></code> which requires a ``witness symbol''
for the package instead of the package.  The witness symbol is any
symbol (expressible in ACL2) and uniquely specifies a package
necessarily known to ACL2.
<br><br><br><a href="acl2-doc.html"><img src="llogo.gif"></a> <a href="acl2-doc-index.html"><img src="index.gif"></a>
</body>
</html>