optional arguments in CLush functions?
Ralf Juengling <[email protected]>
| Newsgroups | gmane.lisp.lush.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
When I write C functions where the arguments are objects
(pointers) and want to make some of the arguments optional,
an easy way to do so is by the convention that NULL pointers
indicate absent arguments.
I'd like to do something similar with CLush. For the sake
of an example, say I might want to write my own vector copying
routine and if three args are provided, then the last arg is
taken to be the storage for the result.
(defun my-plus (a b c)
((-idx1- (-double-)) a b c)
(if (= (to-gptr c) ())
(let ((c (clone-array a)))
;; do stuff
c)
;; do other stuff and use input c
c))
With two args the invocation would look like
(my-plus u v NULL) ;; NULL some new symbol
with three args it would look like
(my-plus u v w)
Of course, it doesn't work currently--at least not the
way I tried. There are a number of questions here:
1. Is there any way, currently, to do what I want to do?
2. When you try to create a NULL ptr (a gptr object with
value NULL) in lush, the result is nil. When the CLush
compiler encounters a nil, it considers it a boolean
value rather than a NULL pointer.
Maybe we need to add a new symbol for this purpose to
lush/CLush, |NULL| say?
3. Would it be possible to change the CLush compiler to
make it accept a NULL ptr as arguments where the
corresponding formal parameter is an object?
Any comments appreciated.
Thanks,
Ralf
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click