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

Re: PUSH / human factors / consistency principles



One problem with striving for consistency is that there are many
dimensions to which consistency can apply.  For example, I happen
to be perhaps more visually- or structurally-minded than most, so
I like the argument order of things that build structures to reflect
something about resulting order of components of that structure.
I think this is especially relevant to a language like LISP.

For example UCI LISP reversed earlier LISP's argument ordering for
the PUTPROP functions, to be (PUT atom val prop-name).  However,
because PLISTS internally are a list consisting of property names
*followed by* values, I find UCI LISP's argument order confusing and
counterintuitive.  As a result I program using only my versions of
PUTPROP that correct this flaw.  CONS and APPEND reflect this
principle too.

Thus, when I want to push an item on a list, saying:
     (PUSH ITEM (ITEM1 ITEM2 ITEM3 ...))
reflects the resulting structure better than saying:
     (PUSH (ITEM1 ITEM2 ITEM3 ...) ITEM)
which, according to my criteria, is ass backwards.  That is basically
Gregg's point too.  I find this a much stronger principle than the
object-oriented principle that, to the best of my introspection,
has never participated in my use of LISP, and which I don't find
terribly relevant (maybe because I try to avoid side-effect
programming as much as possible).

Another /minor\ rule of thumb I use in determining argument order
is to try to put the "simpler" or "smaller" arguments first.  This
yeilds, I believe, slightly clearer and more readable code.  For
example according to this, the (PUTPROP atom property-name value)
argument order is preferable, since the property-name is practically
always an atom, but the value may be a complicated expression.  Having
the item before the list with PUSH would usually produce a cleaner
expression also.
-------