[cells-devel] mk-row / mk-stack

Andy Chambers achambers.home at googlemail.com
Sat Oct 24 13:27:39 UTC 2009


Plaese find below an alternative version of def-mk-inline which means
that if the
"title" of a row or stack is nil, an unlabelled frame will be created.

I modified this because I kept feeling like I was repeating myself
with code like
this.....

(bif (title (maybe-get-title))
  (mk-row (title)
     ....)
  (mk-row ()
     ....))

With the definition below, I don't have to repeat myself.

(mk-row ((maybe-get-title))
    ...)

What do you guys think?

(defmacro def-mk-inline (name (unlabelled labelled))
  `(defmacro ,name ((&rest initargs) &rest kids)
    (cond
      ((evenp (length initargs))
       `(make-instance ',',unlabelled
	 :fm-parent *parent*
	 , at initargs
	 :kids (c? (the-kids , at kids))))
      ((null (car initargs))
       `(make-instance ',',unlabelled
	 :fm-parent *parent*
	 ,@(cdr initargs)
	 :kids (c? (the-kids , at kids))))
      (t `(make-instance ',',labelled
	   :fm-parent *parent*
	   :text ,(car initargs)
	   ,@(cdr initargs)
	   :kids (c? (the-kids , at kids)))))))


-- 
----
Andy Chambers
Formedix Ltd




More information about the cells-devel mailing list