Subject: Re: quest for pass-by-reference semantics in CL
From: Erik Naggum <erik@naggum.net>
Date: Sun, 05 May 2002 13:43:32 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3229595011915709@naggum.net>

* Duane Rettig <duane@franz.com>
| The problem with the terms call-by-value/pass-by-value is not that
| they are not well-defined.  The problem is that these terms are
| confusing because people don't understand what a "value" is.

  I believe it is entirely clear in the context of all three conventions.

  I also think there is a difference between call _by_ value/reference and
  call _with_ value/reference that is somehow conflated here.  That is,
  somehow, people confuse what the argument _is_ and _how_ it is passed.

| Values are different things in different languages.  In C, a struct is a
| value but an array is not.  In Lisp, neither structs nor arrays are
| values.  Because of these different definitions of "value", confusion
| creeps in.

  This is a classic case of equivocation.  Just because there are different
  kinds of values and references in the language, does not mean that the
  _same_ meaning of "value" and "reference" exists in a technical term that
  relates to the relationship between actual and formal parameter in a call.

| If such a description does exist, then it would be useful for a Lisp FAQ
| entry such as "Is Lisp pass-by-value, pass-by-reference, or
| pass-by-name?" could be answered, (e.g. "pass-by-value, with appropriate
| understanding of what a value is") along with that appropriate definition
| of what a Lisp Value is.

  I answered Frode with what I think is a fresh start.  Let me repeat it
  here in case it got lost:

    Argument passing in Common Lisp is conceptually equivalent to building
    a list of the results of evaluating each of the argument forms to the
    function and passing that list to the function, which conceptually
    unpacks it into the formal parameters.  All knowledge of the source of
    the values is lost by that time.

  The conceptual equivalence to a list is used to lay the ground for apply,
  &rest, &key, etc, and also neatly captures the order of evaluation so an
  explanation of this rule will fall out naturally from the description.

| Also, a link could be made to the C definitions for Value, for contrast.

  But it has nothing to do with what a _value_ is.  This has to do with
  whether you pass whatever-a-value-is or wherever-whatever-is-a-value-is
  whenever you pass an argument to a function.  (Call it the Shakira
  theory. :)
-- 
  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.

  70 percent of American adults do not understand the scientific process.