Re: An idea for a freak DWIM lisp-2
- From: Gareth McCaughan <Gareth.McCaughan@xxxxxxxxx>
- Date: Sat, 07 May 2005 12:46:20 GMT
(Warning: mathematicophilosophical maunderings ahead.
Proceed with caution.)
Kent M Pitman wrote:
[about the "0,1,infinity rule"]
>>> Yeah, and I'm sure it's probably linked to or mirrored at www.mormon.org.
>>
>> ?
>
> I was wondering if anyone was going to be confused. Since you ask, there
> are two reasons I mentioned this.
>
> First, Mormons support polygamy. Presumably they could argue, by the
> aforementioned rule, that 'infinity' is a bound that requires no
> justification and is simply an obviously elegant boundary.
>
> But second, it brings up the matter that I see is confirmed later in
> that entry, which is whether the rule "one, two, many" has as much weight.
[etc]
I don't think anyone seriously regards the 0,1,oo rule
as Holy Writ. It's a useful rule of thumb. Let me suggest
two other ways of stating more or less the same thing:
- Anywhere in your program or design where you have
a number, it's probably a bad sign if there isn't
a clear answer to all questions of the form "so why
not ___ instead?" with another number filled in.
(An answer might be clear by virtue of being already
there in the comments or design documents, or by
virtue of being obvious.)
- Anything in your design that needs *numbers* as such
is likely to be wrong; all numbers should be readily
explicable (and explained) in non-numerical terms.
Neither of these is intended to be more than a rule of
thumb either. And I hope I don't need to say explicitly
that, e.g., the second version doesn't justify using
9 as a magic number in a networking protocol because
you could replace it with "the number of planets in
our solar system" :-).
These are both special cases of a more general principle.
- Suppose there is some symmetry or near-symmetry of
the space of all programs. Then any respect in which
your program fails to be invariant under it needs
justification. (Likewise for designs.)
More tersely: symmetries should not be broken without
reason.
All numbers look somewhat alike, especially large-ish
ones, so if you use the number 1729 somewhere in your
program or design then there ought to be some reason
why it's better than 1728 or 729 or 9271. (Anyone who
thinks I'm denying that different numbers have
different properties should google for "hardy taxicab"
and reflect on my choice of example.)
Similarly, if your program has variables called a,b,c
then permuting them is a near-symmetry, so either your
program should be invariant under that permutation
(as e.g. if everything done with them is symmetrical)
or there should be a reason for the asymmetry (as
e.g. if you're using c for the speed of light).
Once again, if you try to treat this as a hard-and-fast
rule you'll likely get silly results.
Here's a complementary principle:
- Suppose your program is invariant under some symmetry.
Then that's probably a sign that you could make it
shorter and clearer by expressing the symmetry explicitly.
This is why you replace repeated code with loops and
functions and macros and so on, and why you replace
repeated variables with aggregate data structures,
and why you move common structure or functionality
up from subclasses into their common superclasses.
Do these principles contradict one another? Not when
rightly understood, because there are two different
ways in which something can be invariant. It can have
different parts that are the same, or it can have
single parts that are themselves symmetrical. It's
really the first case that's discouraged, not the
second.
This is all rather half-thought-through, but I need
to go and put some shelves up now. :-)
--
Gareth McCaughan
..sig under construc
.
- References:
- Re: An idea for a freak DWIM lisp-2
- From: Kent M Pitman
- Re: An idea for a freak DWIM lisp-2
- From: Kent M Pitman
- Re: An idea for a freak DWIM lisp-2
- From: Adam Warner
- Re: An idea for a freak DWIM lisp-2
- From: Kent M Pitman
- Re: An idea for a freak DWIM lisp-2
- From: Gareth McCaughan
- Re: An idea for a freak DWIM lisp-2
- From: Kent M Pitman
- Re: An idea for a freak DWIM lisp-2
- Prev by Date: Re: This Lispofobics really gone too far
- Next by Date: Re: How to change people's minds about LISP?
- Previous by thread: Re: An idea for a freak DWIM lisp-2
- Next by thread: Re: An idea for a freak DWIM lisp-2
- Index(es):
Relevant Pages
|
|