4 ms·
>> Which of the other 24 special forms is suitable? > LAMBDA. I am nitpicking, but LAMBDA is not a special form, FUNCTION/FLET/LABELS are: http://www.lispwork
by junke 11y ago
>> Which of the other 24 special forms is suitable?
> LAMBDA.
I am nitpicking, but LAMBDA is not a special form, FUNCTION/FLET/LABELS are:
http://www.lispworks.com/documentation/HyperSpec/Body/03_ababa.htm#clspecialops http://www.lispworks.com/documentation/HyperSpec/Body/03_aba...
> It's a pretty elementary exercise to fix ->altboolean so that this invariant is maintained.
And how do you map generalized booleans to your functions?
Right now, I can think of two possible ways. You can map NIL to #'_false in a hash-table, and use (gethash nil table #'_true) to provide a default value.
Or you can also write a generic function:
(defgeneric ->altboolean (x)
(:method ((x null)) #'_false)
(:method (x) #'_true))
There could be other ways, but as far as I know, none of them are portable, because even though it is allowed for all defined CL operators to be implemented as built-ins, you generally cannot expect or assume that it is done so (see gethash in CCL and SBCL). As far as you know, and even though it would be terribly inefficient, they could all be implemented only by combining special forms.
If you discard IF, can you perform the elementary exercise using only special forms? I cannot imagine how, but I honestly would like to be shown a working approach.
- lisper 11y ago> I am nitpicking You certainly are. > can you perform the elementary exercise using only special forms? I don't even need any special forms. All I need to do is use the default argument to GET.