Re: optional parameters (Mark Tillotson)
Thu, 10 Aug 1995 19:13:46 GMT

          From comp.compilers

Related articles
optional parameters (Stefan Monnier) (1995-08-06)
Re: optional parameters (1995-08-10)
Re: optional parameters (1995-08-15)
Re: optional parameters (1995-08-20)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Mark Tillotson)
Keywords: C, Lisp
Organization: Harlequin Limited, Cambridge, England
References: 95-08-064
Date: Thu, 10 Aug 1995 19:13:46 GMT

> How are optional parameters implemented ? I'm sure the technique is
> not the same for C++ than for CommonLisp (and, for CommonLisp
> &optional are probably not handled the same as &key and as &rest).
> Is some special calling-convention used (with an arg count, for
> instance) or are the missing optional parameters added by the
> compiler thanks to prototype declarations ? How does it all fit with
> the usual calling conventions ?

In Common Lisp, an arg-count is required because unsupplied arguments
have to trigger evaluation of default expressions. The caller thus
doesn't have to know how many arguments the callee is expecting (and
in general can't know(*)). All the handling of &optional/&key/&rest
arguments is the resposibility of the callee (in the absence of any
global program optimization, of course). In Common Lisp this _is_ the
`usual calling conventions'. Note that the same goes for the returned
values---a count is needed.

* The caller may be compiled before the callee is even written!

Can't speak for C++, but I can guess ;-)


[ | | +44 1223 873829 ]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.