help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Partition for Emacs Lisp


From: TomSW
Subject: Re: Partition for Emacs Lisp
Date: Sun, 28 Jun 2009 13:46:10 -0700 (PDT)
User-agent: G2/1.0

On Jun 28, 10:16 pm, Marc Tfardy <b...@cyk.cyk> wrote:

> Is there some reason (performance?) to write partition as above
> and not as:
>
> (defun partition (sequence length)
>    (cond ((listp sequence)
>           (partition-list sequence length))
>          ((stringp sequence)
>           (partition-vector sequence length)) ; emacs lisp strings are not 
> vectors!
>          ((vectorp sequence)
>            (partition-vector sequence length))))

etypecase has three advantages over cond. It clearly documents the
fact that what you're interested in is the type of the argument, it
saves you repeating the name of the argument in every clause - making
the type more salient, and it raises an error if the argument isn't
one of the types catered for (that's the "e" in etypecase).

regards,
Tom SW


reply via email to

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