I was wondering if it is possible to set default values for parameters in lisp (specifically scheme) like you can in C++.
Or is it best to just create a second procedure that passes in, for example, the first two parameters and a default value into my original procedure?
I hope that made sense.
Before someone suggests I read SICP, I am halfway through the chapter on Data Abstraction.
Name:
Anonymous2008-09-17 19:42
>>1
I think it's not in R5RS, but you can do it in some Schemes as an extension. Or you can just use define-syntax and syntax-rules to create a define* macro.
Basically there are lots of libraries and implementation extensions to do it in Scheme, and Common Lisp includes one in the standard (in fact it might be where everyone stole it from).
Name:
Anonymous2008-09-17 20:26
>>1
You can just override the method name and create a second method with extra parameters. Then make the second method call the first one and pass in the default value for the extra parameters.