From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.news.rcn.net!rcn!dca6-feed2.news.digex.net!intermedia!newsfeed1.cidera.com!Cidera!news100.world-online.no!news100.world-online.no!news01.chello.no!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: newbie: does lisp copy all arguments? References: Mail-Copies-To: never From: Erik Naggum Message-ID: <3222349504568437@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 49 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 10 Feb 2002 17:05:03 GMT X-Complaints-To: abuse@chello.no X-Trace: news01.chello.no 1013360703 212.186.234.171 (Sun, 10 Feb 2002 18:05:03 MET) NNTP-Posting-Date: Sun, 10 Feb 2002 18:05:03 MET Xref: archiver1.google.com comp.lang.lisp:26147 * Christopher Browne | By and large, Lisp does "call by reference," which means that what | would be passed to the function is a _reference_ to the board. This is slightly misleading. The usual terminology is "call by value", "call by name", and "call by reference", which refer to how the arguments in the function call are passed to the function. 1 A call by value means that the value yielded by the argument is passed to the function. This means that the expression is fully computed and only the value is passed along to the function with no trace of its origins. 2 A call by name means that the expression in the function call is passed to the function, such that the called function evaluates it itself. 3 A call by reference means that a place that holds the value of the argument is passed to the function. Typically, the variable that holds the value is passed to the function so the function can write back into the variable. All Lisps are strict call-by-value languages. Macros are in a sense call-by-name "functions". But in no sense does Lisp offer a call by reference concept. Other languages have different semantics. E.g., Ada has the very elegant in/out parameter specification: in parameters are call-by-value, out are _effectively_, but need not actually be, call-by-name or -reference. Fortran is generally call-by-reference. C++ is usually call-by-value, but you may request call-by-reference. Whether you pass a pointer to an object or the object itself is entirely orthogonal to the call-by-value or call-by-reference issue. Common Lisp offers object identity as one of its basic features as well as the ability to store any kind of object in a Lisp "storage cell" location, meaning a variable, structure or class slot, array cell, the car and cdr of a cons, etc, etc. This naturally means that Lisp must pass around some kind of references to objects, as no other mechanism can store any kind of value in equal amounts of space. However, this does not mean that Common Lisp provides the kind of pointers that C/C++ offers, although some Lisps have provided "locatives" which refer to sub-elements of structured objects, like an individual array cell, class or structure slot, and the like. They would still be passed by value, however. /// -- In a fight against something, the fight has value, victory has none. In a fight for something, the fight is a loss, victory merely relief.