from micro-rant to macro-feature

Memovich, Gary GARY.MEMOVICH@kla-tencor.com
Thu, 9 Aug 2001 16:00:42 -0700


> I'm against removing it, even if compatibility was not an issue.
>=20
> Yes, it's an irregularity. But it's convenient, readable, and it
> allows using negative constants in patterns.
>=20
> --=20
>  __("<  Marcin Kowalczyk * qrczak@knm.org.pl =
http://qrczak.ids.net.pl/
>  \__/
>   ^^                      SYGNATURA ZAST=CAPCZA
> QRCZAK

I had either not realized, or forgotten, that unary minus could be used =
in
patterns, that is indeed an important feature.  =20

Unary minus is indeed a confused beast.  If it were considered a part =
of
numeric literals, it wouldn't be possible to apply it to expressions.  =
And
if it were regarded as a normal function it would not be possible to =
match
against it in patterns.  It might almost be considered a kind of =
constructor
(although not beginning with an upper case letter) but this would mean =
the
result of applying it would have to be a different type, and require
extracting the underlying value, or the use of conversion functions, =
when
combining its use with regular numeric types.

Considering it as a constructor, with an automatic conversion to =
regular
numeric types via 'negate', seems to come closest to fitting all of its
properties, except for its precedence level.

Now if we only expanded the flexibility of 'newtype' declarations so =
that we
could include a conversion function to the underlying type, and expand =
the
type checking system to automatically add calls to such a function when
needed, and change the syntax so that the constructor for 'newtype' =
wasn't
limited to identifiers, and change the syntax some more so that new =
'prefix'
declarations were available to adjust the precedence levels of these =
new
constructors, it would be a piece of cake :-)

-- Gary