|optional parameters firstname.lastname@example.org (Stefan Monnier) (1995-08-06)|
|Re: optional parameters email@example.com (1995-08-10)|
|Re: optional parameters firstname.lastname@example.org (1995-08-15)|
|Re: optional parameters email@example.com (1995-08-20)|
|From:||firstname.lastname@example.org (Mark Tillotson)|
|Organization:||Harlequin Limited, Cambridge, England|
|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 ;-)
[ email@example.com | http://www.harlequin.co.uk/ | +44 1223 873829 ]
Return to the
Search the comp.compilers archives again.