Browse Prior Art Database

Method for Returning Multiple Values in Common Lisp Programs

IP.com Disclosure Number: IPCOM000100259D
Original Publication Date: 1990-Mar-01
Included in the Prior Art Database: 2005-Mar-15
Document File: 3 page(s) / 98K

Publishing Venue

IBM

Related People

Alberga, CN: AUTHOR [+2]

Abstract

The Common Lisp programming language (1) allows multiple-valued functions to be defined. (Image Omitted) The language also defines statements for receiving multiple values in programs that call these functions. This article describes a technique for transmitting multiple values from a producing function to a receiving statement with no run-time overhead when multiple values are not transmitted.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 52% of the total text.

Method for Returning Multiple Values in Common Lisp Programs

       The Common Lisp programming language (1) allows
multiple-valued functions to be defined.

                            (Image Omitted)

 The language also defines
statements for receiving multiple values in programs that call these
functions.  This article describes a technique for transmitting
multiple values from a producing function to a receiving statement
with no run-time overhead when multiple values are not transmitted.

      The method is described in terms of a new (internal) special
form of LET called MV-LET.  This new form creates a contour with
variables in predetermined stack locations.
           (mv-let ((flag n) w1 w2 ... wn) body-form ...)
           (mv-let ((flag :LIST) w1 w2) body-form ...)

      The Lisp compiler generates a run-time table that describes the
multiple-value behavior of each function call site.  This information
is statically determined by the definition of Common Lisp:
           Multiple values cannot propagate past this call.
           Multiple values must propagate past this call.
           The function call is textually present within a MV-LET
expression.

      When the VALUES function is called during the execution of
body- form ..., each call site in the call chain is examined in turn:
If the call is directly within an MV-LET expression, then the
corresponding flag variable is examined:
                If the value of the flag variable is n, then the
first n of the multiple values is stored in variables w1 ... wn.
Additional values are discarded.
                If the value of the flag variable is :LIST, then the
first of the multiple values is stored in w1 and a list of all the
values is stored in w2.
           In all cases the value of the flag variable is set to NIL,
and the scan stops.
           If the call must propagate multiple values, or if the end
of the call chain is reached, the scan stops, and VALUES returns the
first argument as an ordinary value.

      V_LET can be combined with or...