Proposal 2: Exceptions and @nogc

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 14 15:41:47 PDT 2017


On 11.04.2017 19:43, Walter Bright wrote:
> On 4/11/2017 4:39 AM, rjframe wrote:
>> I have no problem with this specific change, but this method of solving
>> problems is going to turn D into a horrible language with all kinds of
>> weird edge cases. I left Python for D mostly because the language was
>> becoming one hack built on top of another; it would be nice if D could
>> avoid that path. The occasional kludge may be necessary, but it shouldn't
>> be normal or the first thought.
>
> On the other hand, overly principled languages tend to not be as
> successful, because what people need to do with programs is often dirty.
>
> Monads, and "functional reactive programming", are obtuse things

They are actually obvious things that happen to usually be explained in 
the language of PL researchers, who are not always interested in 
creating a popular system.

> that
> come about when a functional programming language requires 100% purity
> and immutability.
> ...

Haskell does not do that. Why do you think it does?

> Back in the 80's, like everyone else, I went about creating a GUI user
> interface library. I discovered something interesting - what is
> orthogonal and consistent to a computer is anything but when dealing
> with people. What people view as orthogonal and consistent is a rat's
> nest of exceptions in the code to implement it. This is what makes a
> user interface library fiendishly difficult to pull off.
> ...

Would you mind sharing an example?

> Language design is like that, too.
>

But there is an objective standard of generality, orthogonality and
consistency, set by examples like pure type systems (such as CoC), or
even just the inference rules of first-order logic.

> I hear what you're saying, and agree in principle. That is why this
> feature comes with no new syntax, and existing code should "just work"
> with it to the largest extent possible.

The benefit is that "throw new Exception" becomes @nogc.

In terms of orthogonality and consistency, the proposal does not do so well:

- Orthogonality of 'throw' and 'new' is removed.

- Built-in new being @nogc sometimes but not at other times is inconsistent.

I think this is true for both computers and users.

I don't feel strongly about whether or not the proposal should be 
accepted as it does not really affect me, but it is a trade-off.


More information about the Digitalmars-d mailing list