Passing A Function to a Function

E

Edward

Guest
(defun ekdToggle (f @optional (valuesPair (list t nil)))
"When you want the OTHER value a function returns."
(car (remove (f) valuesPair)))

(ekdToggle 'leIsInstSelectable)
*Error* eval: undefined function - f

Hey! What gives?
 
(defun ekdToggle (f @optional (valuesPair (list t nil)))
"When you want the OTHER value a function returns."
(car (remove (f) valuesPair)))

(ekdToggle 'leIsInstSelectable)

*Error* eval: undefined function - f

Hey! What gives?
The value of f is a symbol. The symbol's function slots contains the actual address of the function
to be called.

When you do (f) you are accessing the function slot of the symbol f, which is not what you intend to do.

What you should do is use funcall(f) or apply(f args).

Note that, when valuePair is '(t nil), it's equivalent to a not(), just a little overkill.

Cheers,
Stéphane
 
If you write this in SKILL++ it will work as long as you omit the
quote.

(defun ekdToggle (f @optional (valuesPair (list t nil)))
(car (remove (f) valuesPair)))

(ekdToggle leIsInstSelectable) ;; no quote before function name.



Just but the code in a file with .ils extension or surround the
code with (inScheme ...)

In many was the SKILL++ dialect of SKILL is sort of what you
intuitively expect. I'm not sure why it is not used more often.
 

Welcome to EDABoard.com

Sponsor

Back
Top