On 20-May-2000, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote:
> Sat, 20 May 2000 20:45:47 +1000, Fergus Henderson <[EMAIL PROTECTED]> pisze:
> 
> > For the next version of Haskell, I propose changing the wording to
> > 
> >       The integer literal i is equivalent to fromInteger i.  Normally
> >       fromInteger is a method in the standard Prelude class Num (see Section
> >       6.4.1), but it is also possible for modules to use `import qualified
> >       Prelude' and then define their own fromInteger function or method,
> >       or import fromInteger from another module.
> 
> Such breakage of lexical scoping is generally dangerous and bad
> language design (like using C preprocessor); not because it is a
> change, but in itself.
> 
> I would be disappointed if code like:
>     bad x = -x
>         where
>         negate = ...
> did not use standard meaning of unary negation.

You raise a good point about accidental redefinition for cases like this.
But the current definition of Haskell doesn't just prevent accidental
redefinition, it also prevents deliberate redefinition.  Wouldn't it
be better if we could somehow allow deliberate redefinition, so people
like S.D.M. could design alternative preludes, while still preventing
all or at least almost all cases of accidental redefinition?

I think it would.

One way to achieve this would be simply to define all the syntactic
constructs to expand to calls to functions with a long prefix that
people are unlikely to define accidentally.  For example, rather
than defining the `do' syntax to call `>>' directly, it could be
defined to call say `__builtin_do_syntax__BIND__', which would
be defined in the standard Prelude to call `>>'.
Similarly, unary minus could be defined in terms of
`__builtin_negation_syntax__NEGATE__', which would be defined
in the standard Prelude to call `negate'.

I understand why you would be disappointed if code like

     bad x = -x
         where
         negate = ...

did not use standard meaning of unary negation.
But if the code looks like

     bad x = -x
         where
         __builtin_negation_syntax__NEGATE__ = ...

then it's much more obvious that something funny is going on here.
If you would still complain about this, I would say that it is a small
price to pay in order for people to be able to define alternative
preludes.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to