|
|
|
|
|
by mtreis86
1740 days ago
|
|
There are a couple ways to approach it in Common Lisp, probably a few more than I have here. One, optional and keyword arguments can have defaults. (defun calc-formula (ia ib &optional (gain t))
...)
Two, you could use a dynamic variable and a closure. Outside the body of the let the gain var returns t, within the body of the let it returns nil. (defvar *gain-enabled* t)
(defun calc-with-gain (ia ib)
...)
(let ((*gain-enabled* nil))
(defun calc-without-gain (ia ib)
...))
|
|
The function inside a LET with a dynamic variable does not create a closure. If one calls CALC-WITHOUT-GAIN later, there is no binding - unless there is another dynamic binding of that variable by a different LET active.