[cells-devel] Constructor syntax

Thomas F. Burdick tfb at OCF.Berkeley.EDU
Sat May 8 18:29:26 UTC 2004


Kenny Tilton <ktilton at nyc.rr.com> writes:

> nikodemus at random-state.net wrote:
> 
> > This is quite off-topic for the thread, but I for one always cringe when I
> > see Cells code due to C? and friends. 
> > 
> > If the syntax were:
> > 
> >  RULE-LAMBDA (binding) form*
> > 
> >   or
> > 
> >  RULE-LAMBDA binding form*
> 
> Garnet's KR had (I forget)-formula. But when one is /really/ using 
> Cells, one is spraying CVs and C?s around all the time, and this is more 
> a candidate for something like collapsing QUOTE into ' or FUNCTION into 
> #' then it is expansion into big-huge-name useful at the application 
> level where, as we all know, excessive abbreviation saves so very little 
> and detracts so much from readability.
> 
> That said, if some contributor wanted to create c-formula and c-variable 
> macros and add them to Cells I would not mind.

Okay, how are these for a start?

  (defmacro cv (&optional (value +unbound+))
    `(cells::make-c-variable :value ,value))
  
  (defmacro c-formula ((&rest keys &key lazy cyclic-p cyclic-value) &body forms)
    (declare (ignore lazy cyclic-p cyclic-value))
    `(cells::make-c-dependent :code ',forms :rule (c-lambda , at forms)
                              , at keys))
  
  (defmacro c-variable ((&rest keys &key cyclic-p) &optional (value nil valuep))
    (declare (ignore cyclic-p))
    `(cells::make-c-variable :value ,(if valuep value '+unbound+) , at keys))

They don't capture all the options (yet), but syntactically I think I
like it.  I agree that cv and c? are so common they should have their
own short abbreviations.  However, c?_8... seems like maybe not the
best road syntactically.  This syntax has the advantage of not needing
to export a new macro if more options are added later (not that I can
think of any types of cells still missing, of the top of my head).

Actually, I just changed my code to use c-formula instead of c?_, and
I like it.  It even saves me two columns of horizontal space.  I have
no desire to change my c? forms, but it's not like my lazy formulas
were one-liners anyway.





More information about the cells-devel mailing list