emacs.d/clones/lisp/www.cliki.net/Issue APPLY-EXAMPLE-WRONG.html
2022-10-07 15:47:14 +02:00

63 lines
No EOL
3.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CLiki: Issue APPLY-EXAMPLE-WRONG</title>
<link rel="alternate" type="application/atom+xml" title="ATOM feed of edits to current article"
href="https://www.cliki.net/site/feed/article.atom?title=Issue%20APPLY-EXAMPLE-WRONG">
<link rel="stylesheet" href="static/css/style.css">
<link rel="stylesheet" href="static/css/colorize.css">
</head>
<body>
<span class="hidden">CLiki - Issue APPLY-EXAMPLE-WRONG</span>
<div id="content"><div id="content-area"><div id="article-title">Issue APPLY-EXAMPLE-WRONG</div><div id="article">This example for <a href="https://www.cliki.net/site/HyperSpec/Body/fun_apply.html" class="hyperspec">APPLY</a> is wrong, because it assumes particular behavior of <a href="https://www.cliki.net/site/HyperSpec/Body/fun_type-of.html" class="hyperspec">TYPE-OF</a>:
<pre>
(defun foo (size &amp;rest keys &amp;key double &amp;allow-other-keys)
(let ((v (apply #&#039;make-array size :allow-other-keys t keys)))
(if double (concatenate (type-of v) v v) v)))
(foo 4 :initial-contents &#039;(a b c d) :double t)
=&gt; #(A B C D A B C D)
</pre>
The call to FOO will signal an error if TYPE-OF returns a type containing the length (4). This causes a type conflict in CONCATENATE, because the new sequence length should be 8. If TYPE-OF returns a type without the length, then FOO will behave as shown above.<p>To get the intended effect, it could do something like one of these:<p><pre>
(concatenate `(vector ,(array-element-type v) *) v v)
(concatenate `(vector ,(array-element-type v) ,(* 2 size)) v v)
</pre><p><hr>
<a href="Issue.html" class="category">Issue</a></div></div>
<div id="footer" class="buttonbar"><ul><li><a href="Issue&#32;APPLY-EXAMPLE-WRONG.html">Current version</a></li>
<li><a href="https://www.cliki.net/site/history?article=Issue%20APPLY-EXAMPLE-WRONG">History</a></li>
<li><a href="https://www.cliki.net/site/backlinks?article=Issue%20APPLY-EXAMPLE-WRONG">Backlinks</a></li><li><a href="https://www.cliki.net/site/edit-article?title=Issue%20APPLY-EXAMPLE-WRONG&amp;from-revision=3770932949">Edit</a></li><li><a href="https://www.cliki.net/site/edit-article?create=t">Create</a></li></ul></div>
</div>
<div id="header-buttons" class="buttonbar">
<ul>
<li><a href="https://www.cliki.net/">Home</a></li>
<li><a href="https://www.cliki.net/site/recent-changes">Recent Changes</a></li>
<li><a href="CLiki.html">About</a></li>
<li><a href="Text&#32;Formatting.html">Text Formatting</a></li>
<li><a href="https://www.cliki.net/site/tools">Tools</a></li>
</ul>
<div id="search">
<form action="https://www.cliki.net/site/search">
<label for="search_query" class="hidden">Search CLiki</label>
<input type="text" name="query" id="search_query" value="" />
<input type="submit" value="search" />
</form>
</div>
</div>
<div id="pageheader">
<div id="header">
<span id="logo">CLiki</span>
<span id="slogan">the common lisp wiki</span>
<div id="login"><form method="post" action="https://www.cliki.net/site/login">
<label for="login_name" class="hidden">Account name</label>
<input type="text" name="name" id="login_name" class="login_input" />
<label for= "login_password" class="hidden">Password</label>
<input type="password" name="password" id="login_password" class="login_input" />
<input type="submit" name="login" value="login" id="login_submit" /><br />
<div id="register"><a href="https://www.cliki.net/site/register">register</a></div>
<input type="submit" name="reset-pw" value="reset password" id="reset_pw" />
</form>
</div>
</div>
</div>
</body></html>