[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

multiple-value return



    Date: 13-Nov-82 21:33:35-PST (Sat)
    From: Kim.fateman@Berkeley

    It seems to me that the costs associated with doing this right can be
    absorbed as Moon suggests, in microcode, but I am not convinced that the
    costs can be easily borne in conventional machines.  Ordinarily a receiver
    of a value will not know whether it must extract the first item in a multiple
    value, or just use the non-multiple-value as given, unless some check
    is performed.

Too bad you didn't read my message, which said not that costs can be absorbed
in microcode, but that there is absolutely nothing about the Lisp machine
implementation of multiple values that is dependent on having microcode
(unlike other Lisp machine features, invisible pointers for instance).

    I believe that if conses/gc were really cheap,
    there would be much less benefit to m-v-r.
    e.g. divide could just return (quotient . remainder), other objects could
    be cons'd up  (or put in vectors ...)

You certainly provided a fine argument for having multiple values here.  Compare
the last sentence in your first paragraph.  If divide returns two values, and you
only want one, you don't have to extract the first item in a multiple value, you
simply accept the first value and ignore the rest.  But if divide returns a cons
of the quotient and the remainder, and you only want the quotient you do have to
pay the overhead of extracting the quotient from that cons.  Not only is there
run-time overhead, there is conceptual overhead since now the packaging of the
multiple values is visible to the user.

Of course divide isn't a good example, because it surely open-codes and hence
generates different code depending on the number of values you ask for.

    The constant overhead looking
    for m-v-r in, for example, macsyma, which does not, at the moment, 
    use m-v-r even once, would be distasteful. 

The constant overhead is zero in any reasonable implementation of multiple
values.