PEP 285: Adding a bool type

Alex Martelli aleax at aleax.it
Tue Apr 2 15:49:52 EST 2002


Chris Barker wrote:
        ...
> do think that that is how it should be in the ideal language. The
> concept of True or False is distinct from the concept of a number, and
> I'd like to see it stay that way in the language.

Have a look at Icon (or Snobol, but that was goto-based... Icon's
much nicer).  It CENTERS on this concept.


> Yes, you would be writing a lot of
> 
> if bool(expression):
> 
> rather than
> 
> if expression:

Tut, tut -- in Icon you do write "if expression" (well, syntax's a bit
different and my memory rusty, but, basically).  There's no concept
of true or false or a boolean type: rather, any expression succeds
or fails. Only if it succeeds does it return anything (and there's no
such thing as 'returning a boolean', of course).  'if' tests whether
the expression succeeds (and doesn't care about what it returns,
as long as it does -- but you can save it somewhere with a :=,
since x:=expression succeeds iff expression does).

There's more, of course, such as the ability to backtrack (trying to
make the expression succeed by pumping sub-expressions for
multiple results), the ability to return multiple results one after the
other (and control structures to pump an expression for all of its
results), and so on.  Often you'll find these things reminiscent of
Python concepts (exceptions, iterators), but Icon was there first
(there may have been some indirect inspiration from Icon in some
of Python's aspects).

See: http://www.cs.arizona.edu/icon/ .

Icon's a stimulating language, and far from dead (version 9.4.1 for
Unix was released on March 27, although the Windows version is
still current at 9.3.2).  However, it has had nothing like Python's
success.  I think it's worth studying if only to understand what DID
Python get right, or luckier, than Icon.  (And anyway, Icon's
paradigms are different enough from most other language's
to make its study worthwhile as a mind-widening experience).

If you want "booleans" given the respect you seem to think they
deserve, you may actually be happier with Icon than with Python.
Me, I think that Python's decision regarding "concrete nothings",
although less pure, was more pragmatically useful than Icon's
purity in distinguishing "something or nothing" from any actual
kind of "somethings", and contributed to Python's greater success.
But - study Icon, try it out on some concrete programming task,
and make up your own mind.


Alex




More information about the Python-list mailing list