1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Issues/iss311_w.htm

151 lines
9.7 KiB
HTML
Raw Permalink Normal View History

2024-04-01 10:24:07 +02:00
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Issue SETF-OF-VALUES Writeup</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="../Issues/iss310_w.htm">
<LINK REL=UP HREF="../Issues/iss311.htm">
<LINK REL=NEXT HREF="../Issues/iss312_w.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="../Issues/iss310_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss311.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss312_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue SETF-OF-VALUES Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss311.htm">SETF-OF-VALUES</A><P>
<B>References:</B> <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A>, GET-SETF-METHOD-MULTIPLE-VALUE<P>
Related issues: <A HREF="iss309.htm">SETF-MULTIPLE-STORE-VARIABLES</A><P>
<A HREF="iss214.htm">LISP-SYMBOL-REDEFINITION</A><P>
<A HREF="iss252.htm">PACKAGE-CLUTTER</A><P>
<A HREF="iss245.htm">MULTIPLE-VALUE-SETQ-ORDER</A><P>
<B>Category:</B> ADDITION, CHANGE<P>
<B>Edit history:</B> v1, 12 Feb 1991, Sandra Loosemore<P>
<P>
<B>Problem description:<P>
</B><P>
The writeup for issue <A HREF="iss309.htm">SETF-MULTIPLE-STORE-VARIABLES</A> indicates that<P>
adding support for multiple store variables makes it easy to write<P>
a <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> <A REL=DEFINITION HREF="../Body/t_method.htm#method"><B>method</B></A> for the <A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>VALUES</B></A> function, yielding a powerful<P>
MULTIPLE-VALUE-SETF-like form. The proposal didn't actually<P>
define <A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>VALUES</B></A> as a <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> place on the rationale that this could be<P>
easily done by users in a portable fashion; however, issue<P>
issue <A HREF="iss214.htm">LISP-SYMBOL-REDEFINITION</A> prohibits users from defining a <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> <P>
<A REL=DEFINITION HREF="../Body/t_method.htm#method"><B>method</B></A> for <A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>VALUES</B></A> or any other symbol that is exported from the<P>
COMMON-LISP package. (Issue <A HREF="iss252.htm">PACKAGE-CLUTTER</A> does not prohibit<P>
implementations from defining <A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>VALUES</B></A> as a <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> place as an extension,<P>
though.)<P>
<P>
There are two proposals, ADD and REMOVE-PROHIBITION. The two proposals<P>
are not mutually exclusive.<P>
<P>
<P>
<B>Proposal (SETF-OF-VALUES:ADD):<P>
</B> <P>
Define <A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>VALUES</B></A> as a <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> place in the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A>.<P>
<P>
For a form such as<P>
<P>
(<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> (<A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>values</B></A> &lt;place1&gt; .... &lt;placen&gt;) &lt;value-producing-form&gt;)<P>
<P>
the <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> methods for each of the nested &lt;placei&gt; are obtained as if by<P>
GET-SETF-METHOD-MULTIPLE-VALUE. The order of evaluation is as follows:<P>
<P>
(1) subforms of the nested &lt;placei&gt; are evaluated in left-to-right order.<P>
(2) The &lt;value-producing-form&gt; is evaluated, and the first store variable<P>
from each &lt;placei&gt; bound to the values as by <A REL=DEFINITION HREF="../Body/m_multip.htm#multiple-value-bind"><B>MULTIPLE-VALUE-BIND</B></A>.<P>
If the <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> <A REL=DEFINITION HREF="../Body/t_method.htm#method"><B>method</B></A> for a nested &lt;placei&gt; involves more than one store<P>
variable, then the additional store variables are bound to <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>.<P>
(3) Finally the storing forms for the nested &lt;placei&gt; are evaluated in<P>
left-to-right order.<P>
<P>
Note that (as required by CLtL), the storing form for <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> of <A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>VALUES</B></A><P>
returns the values of the store variables as its values. (This might<P>
be more or fewer values than what the &lt;value-producing-form&gt; returns.)<P>
<P>
Rationale for proposal ADD:<P>
<P>
<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> of <A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>VALUES</B></A> is a powerful feature. Even if it were made possible to<P>
define it portably, it is useful enough to warrant being included as<P>
a <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A>, built-in part of the language. Standardizing this feature<P>
will prevent problems with a proliferation of similar features that all<P>
have slightly different names or semantics.<P>
<P>
<P>
<B>Proposal (SETF-OF-VALUES:REMOVE-PROHIBITION):<P>
</B><P>
Permit users to define <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> methods and/or <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> functions for places <P>
whose names are external symbols in the COMMON-LISP package, provided <P>
that the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> does not already define the symbol as a name of a <P>
<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> place.<P>
<P>
Rationale for proposal REMOVE-PROHIBITION:<P>
<P>
There are other potential <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> places besides <A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>VALUES</B></A> that a user might<P>
conceivably wish to define <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> methods for, that are named by external<P>
symbols in the COMMON-LISP package. The writeup for issue <P>
SETF-MULTIPLE-STORE-VALUES suggested <A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> and <A REL=DEFINITION HREF="../Body/a_vector.htm#vector"><B>VECTOR</B></A>, for example.<P>
<P>
<P>
<B>Examples:<P>
</B><P>
<B>Current Practice:<P>
</B><P>
Chestnut's Lisp-to-C translator implements proposal ADD.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
For proposal ADD, the <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> <A REL=DEFINITION HREF="../Body/t_method.htm#method"><B>method</B></A> for <A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>VALUES</B></A> will need to be written.<P>
<P>
For proposal REMOVE-PROHIBITION, implementors will have to be careful<P>
about defining additional <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> places on symbols exported from the<P>
COMMON-LISP package, since those definitions might be overridden by<P>
user-supplied definitions.<P>
<P>
<B>Cost to Users:<P>
</B><P>
None. This is an upward-compatible extension.<P>
<P>
<B>Cost of non-adoption:<P>
</B><P>
Users are prohibited from doing something useful for no good reason.<P>
<P>
<B>Performance impact:<P>
</B><P>
Probably none.<P>
<P>
<B>Benefits:<P>
</B><P>
The costs of non-adoption are avoided.<P>
<P>
<B>Esthetics:<P>
</B><P>
It looks OK to me.<P>
<P>
<B>Discussion:<P>
</B><P>
CLtL-II notes that a proposal to add <A REL=DEFINITION HREF="../Body/a_values.htm#values"><B>VALUES</B></A> as a <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> place was <P>
submitted in September 89, but I can find no record of it in the<P>
minutes from either the November 89 or June 90 meetings.<P>
<P>
I have no idea what the semantics of a <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> <A REL=DEFINITION HREF="../Body/t_method.htm#method"><B>method</B></A> on <A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> or <A REL=DEFINITION HREF="../Body/a_vector.htm#vector"><B>VECTOR</B></A><P>
might be.<P>
<P>
-------<P>
</PRE>
<HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>