[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: request for a new function, say, `sequence'

From: Stefan Monnier
Subject: Re: request for a new function, say, `sequence'
Date: Tue, 25 Mar 2003 10:27:00 -0500

> > The examples in this thread have all created a list (or vector)
> > and then iterated over the elements. 
> The original version of `sequence' is `devanagari-range',
> and it it used as below.
> (defun dev-charseq (from &optional to)
>   (if (null to) (setq to from))
>   (mapcar (function (lambda (x) (indian-glyph-char x 'devanagari)))
>           (devanagari-range from to)))

But in this example as well a variant of `dotimes' would work just as well
and would avoid the unnecessary consing.  Emacs is not very good at
efficiently consing+GCing, so it's good to avoid such things when
it can be done without impacting the readbility (Emacs-21 is dog slow
on my 266Mhz machine).

Also, all the examples I've seen use lists.  Given my background in
type-systems, I must say that I don't like functions that returns either
a list or a vector or a string depending on some extra arg.  If we
want a function for convenience (rather than performance), then
returning a list is good enough.  You can always pass the result
to `string' or to `vector' if you want something else.

Anyway, blue is the color for my bykeshed, what is yours ?

> > If the preloaded file is compiled then 'cl isn't actually loaded
> > at run time.
> Yes, I know that.  So, I understood that not requiring cl is
> a kind of coding convention.  If there's no such convention
> now, that ok, but still loop doesn't work for iterating over

        grep 'require .cl' lisp/**/*.el

will show you that CL is used all over the place, including in files that
are pre-loaded (though fewer of them, admittedly).  As long as CL is only
needed when byte-compiling the file, it's OK (i.e. if it's wrapped in
`eval-when-compile').  At least that was RMS' official position last time
this was brought up.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]