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

Re: Prefix, not postfix

"Kjetil S. Matheussen" <k.s.matheussen@xxxxxxxxxx> writes:

> "Alex Shinn":
>>On 4/13/06, Philippe Meunier <meunier@xxxxxxxxxxx> wrote:
>>> Marc Feeley <feeley@xxxxxxxxxxxxxxxx> wrote:
>>> >1) I prefer prefix syntax, e.g.   (button :text "OK" :action quit)
>>> >2) I prefer suffix syntax, e.g.   (button text: "OK" action: quit)
>>> >3) I don't care
>>As an example of a procedure that looks especially nice with suffix
>>syntax, here is SEND-MAIL from the Hato mail server:
> Okay, this post is a bit lame since the last message in this thread was
> posted over a year ago, and I only read it because of the finalization
> announcement on comp.lang.scheme. However, I want to express my
> opinion on this matter anyway, since a couple of points didn't seem to
> be mentioned explicitly in the discussion.
> Alex' example with suffix:
>   (send-mail From:    "Dr. Watson <guest@xxxxxxxxxxxx>"
>              To:      "Sherlock Homes <not-really@xxxxxxxxxxxxxxxxx>"
>              Subject: "First Report"
>              Charset: "ISO-8859-1"
>              Body:    "Moor is gloomy. Heard strange noise, attached."
>              Attachments: '((File: "howl.ogg")))
> Alex' example with prefix:
>   (send-mail :From    "Dr. Watson <guest@xxxxxxxxxxxx>"
>              :To      "Sherlock Homes <not-really@xxxxxxxxxxxxxxxxx>"
>              :Subject "First Report"
>              :Charset "ISO-8859-1"
>              :Body    "Moor is gloomy. Heard strange noise, attached."
>              :Attachments '((File: "howl.ogg")))
> I think prefix is better, for the following two reasons:
> 1. Its faster to spot the colon when its at the start of a word: "Aha!
>    the first character is a colon, the characters following the colon
>    constructs a keyword."

Interestingly, I think of the ":" as a delimiter between the keyword
and the value, almost as an "=", and so find the CLOS-style very

In fact, in some systems I've used *both* -- a prefix ":" is a flag
(i.e., no argument) and a suffix ":" is a keyword (argument follows)
such as:

   (send-mail From:    "Dr. Watson <guest@xxxxxxxxxxxx>"
              To:      "Sherlock Homes <not-really@xxxxxxxxxxxxxxxxx>"
              Subject: "First Report"
              Body:    "Moor is gloomy. Heard strange noise, attached."
              Attachments: '((File: "howl.ogg"))

(apologies for the anachronism!)

> 2. Vertical alignment. "send-mail"'s arguments consists of a bunch of
>    keywords+argument pairs, where the first coloumn is keywords and the
>    second is arguments. This is easier to spot with prefix because all the
>    colons are vertical aligned.

Yes, I can see that.  I don't usually get visually confused, but it
does happen on occasion, usually when a long argument list is on the
verge of wrapping but hasn't been wrapped yet.  Once it's been wrapped
and indented, I don't have a problem anymore (and I don't usually align
the values, either)

My $0.01 (deflation on account of final status :-)