129 lines
7.3 KiB
HTML
129 lines
7.3 KiB
HTML
<!-- 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 FUNCTION-COMPOSITION 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/iss171_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss172.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss173_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/iss171_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss172.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss173_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue FUNCTION-COMPOSITION Writeup</H2>
|
|
|
|
<PRE><B>Status:</B> Passed (as amended) Jan 89 X3J13<P>
|
|
(And reaffirmed Jun 89 X3J13 that this was <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>the</B></A> version wanted)<P>
|
|
<P>
|
|
<B>Forum:</B> Cleanup<P>
|
|
<B>Issue:</B> <A HREF="iss172.htm">FUNCTION-COMPOSITION</A><P>
|
|
<B>References:</B> None<P>
|
|
<B>Category:</B> ADDITION<P>
|
|
<B>Edit history:</B> 21-Jun-88, Version 1 by Pitman<P>
|
|
05-Oct-88, Version 2 by Pitman<P>
|
|
7-Dec-88, Version 3 by Masinter<P>
|
|
12-Dec-88, Version 4 by Masinter (additional comments)<P>
|
|
10-Feb-89, Version 5 (as amended by X3J13 Jan 89)<P>
|
|
Related-Issues: <A HREF="iss345.htm">TEST-NOT-IF-NOT</A><P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
A number of useful functions on functions are conspicuously<P>
|
|
absent from Common Lisp's basic set. Among them are functions<P>
|
|
which return constant T, constant <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>, and functions which<P>
|
|
combine functions in common, interesting ways.<P>
|
|
<P>
|
|
<B>Proposal (FUNCTION-COMPOSITION:JAN89-X3J13):<P>
|
|
</B><P>
|
|
Add the following functions:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/f_comple.htm#complement"><B>COMPLEMENT</B></A> function [Function]<P>
|
|
<P>
|
|
Returns a function whose value is the same as the <A REL=DEFINITION HREF="../Body/a_not.htm#not"><B>NOT</B></A> of the<P>
|
|
given function applied to the same arguments.<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/f_cons_1.htm#constantly"><B>CONSTANTLY</B></A> value [Function]<P>
|
|
<P>
|
|
Returns a function whose value is always VALUE.<P>
|
|
<P>
|
|
<B>Examples:<P>
|
|
</B><P>
|
|
(<A REL=DEFINITION HREF="../Body/f_mapc_.htm#mapcar"><B>MAPCAR</B></A> #'(<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>LAMBDA</B></A> (X) (<A REL=DEFINITION HREF="../Body/s_declar.htm#declare"><B>DECLARE</B></A> (<A REL=DEFINITION HREF="../Body/d_ignore.htm#ignore"><B>IGNORE</B></A> X)) T) '(3 A 4.3))<P>
|
|
==<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_mapc_.htm#mapcar"><B>MAPCAR</B></A> (<A REL=DEFINITION HREF="../Body/f_cons_1.htm#constantly"><B>CONSTANTLY</B></A> T) '(3 A 4.3))<P>
|
|
=> (T T T)<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_find_.htm#find-if-not"><B>FIND-IF-NOT</B></A> #'<A REL=DEFINITION HREF="../Body/f_zerop.htm#zerop"><B>ZEROP</B></A> '(0 0 3))<P>
|
|
==<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_find_.htm#find-if"><B>FIND-IF</B></A> (<A REL=DEFINITION HREF="../Body/f_comple.htm#complement"><B>COMPLEMENT</B></A> #'<A REL=DEFINITION HREF="../Body/f_zerop.htm#zerop"><B>ZEROP</B></A>) '(0 0 3))<P>
|
|
=> 3<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
The presence of these functions will contribute to syntactic<P>
|
|
conciseness in some cases. <P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
No Common Lisp implementations <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> these functions,<P>
|
|
but they do exist in the T language.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
A straightforward implementation is simple to cook up. The definitions<P>
|
|
given here would suffice. Typically some additional work might be<P>
|
|
desirable to make these open code in interesting ways.<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> <A REL=DEFINITION HREF="../Body/f_comple.htm#complement"><B>COMPLEMENT</B></A> (<A REL=DEFINITION HREF="../Body/a_fn.htm#function"><B>FUNCTION</B></A>)<P>
|
|
#'(<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>LAMBDA</B></A> (<A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&REST</B></A> ARGUMENTS)<P>
|
|
(<A REL=DEFINITION HREF="../Body/a_not.htm#not"><B>NOT</B></A> (<A REL=DEFINITION HREF="../Body/f_apply.htm#apply"><B>APPLY</B></A> <A REL=DEFINITION HREF="../Body/a_fn.htm#function"><B>FUNCTION</B></A> ARGUMENTS))))<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> <A REL=DEFINITION HREF="../Body/f_cons_1.htm#constantly"><B>CONSTANTLY</B></A> (VALUE)<P>
|
|
#'(<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>LAMBDA</B></A> (<A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&REST</B></A> ARGUMENTS) <P>
|
|
(<A REL=DEFINITION HREF="../Body/s_declar.htm#declare"><B>DECLARE</B></A> (<A REL=DEFINITION HREF="../Body/d_ignore.htm#ignore"><B>IGNORE</B></A> ARGUMENTS))<P>
|
|
VALUE))<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
None. This change is upward compatible.<P>
|
|
<P>
|
|
<B>Cost of Non-Adoption:<P>
|
|
</B><P>
|
|
(<A REL=DEFINITION HREF="../Body/f_comple.htm#complement"><B>COMPLEMENT</B></A> BENEFITS)<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Some code would be more clear. <P>
|
|
Some compilers might be able to produce better code.<P>
|
|
<P>
|
|
Takes a step toward being able to flush the -IF-NOT functions<P>
|
|
and the :TEST-NOT keywords, both of which are high on the list<P>
|
|
of what people are referring to when they say Common Lisp is<P>
|
|
bloated by too much garbage.<P>
|
|
<P>
|
|
<B>Aesthetics:<P>
|
|
</B><P>
|
|
In situations where these could be used straightforwardly, the<P>
|
|
alternatives are far less perspicuous.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Several additional functions (COMPOSE, CONJOIN) were<P>
|
|
considered and rejected at the Jan 89 X3J13 meeting.<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>
|