[pro] [Q] naming convention

Pascal Costanza pc at p-cos.net
Thu Apr 5 05:45:24 UTC 2012


Hi,

Here is another example. When I present macros to non-Lispers, the while loop macro seems to work best. I first introduce a functional version:

(defun while (predicate body)
   (when (funcall predicate)
      (funcall body)
      (while predicate body)))

...and then I show the macro that expands into this:

(defmacro while* (predicate &rest body)
  '(while (lambda () ,predicate)
      (lambda () , at body)))

...except I would like to use the name 'while for the macro, and some other name for the function (while/f, or so). Any suggestions? Everything I can come up with is kind of ugly...

Pascal

Sent from my iPad

On 5 Apr 2012, at 02:15, "Pascal J. Bourguignon" <pjb at informatimago.com> wrote:

> Didier Verna <didier at lrde.epita.fr> writes:
> 
>> I have a FROB functionality that I would like to make available both at
>> run-time via a function and at compile-time via a macro (which in turn
>> will call the function).
>> 
>> Are there any general conventions (apart from DEFINE- / MAKE-) for this
>> kind of thing ? I'm having a hard time finding nice names for FROB the
>> function and FROB the macro...
> 
> DEF or DEFINE- and MAKE- are used in CL (eg. DEFPACKAGE and
> MAKE-PACKAGE).
> 
> 
> 
> If the macros are just a wrapping of the functions for compilation-time
> invocation, their names may vary only by one *.
> 
> For example in my HTML generator package, the element macros are named
> after the tag, and the element functions after the tag*.
> 
>    (defun p* (…) …)
>    (defmacro p (…) (p* …)
> 
> In this case, I assume clients of the package will use the macro in
> general (p compilation-time-data)  but they may also need to call the
> function at run-time (mapcar (function p*) …) or just (p* run-time-data).
> 
> 
> 
> For a single functionality, DEFINE-FROB and MAKE-FROM sound good.
> 
> -- 
> __Pascal Bourguignon__                     http://www.informatimago.com/
> A bad day in () is better than a good day in {}.
> 
> _______________________________________________
> pro mailing list
> pro at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/pro




More information about the pro mailing list