Morale of a story: ~ is the right choice for concat operator

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat May 26 00:21:12 UTC 2018


On Friday, May 25, 2018 23:57:03 IntegratedDimensions via Digitalmars-d 
wrote:
> On Friday, 25 May 2018 at 23:05:51 UTC, Jonathan M Davis wrote:
> So, you think by forcing programmers to use a break, goto, or
> return at the end of a case somes errors but really what it does
> it make programmers less aware of the problems. They become less
> effective programmers in the long run.

I don't see how it makes anyone less effective. It catches a programming
mistake, and if you want to purposefully fall through to the next statement,
then use goto case;. No expressiveness is lost, and there's no problem that
the programmer is not left aware of.

> The mentality that you think you can police everything and that
> you also have the experience and knowledge to protect everyone is
> ignorant and provably catastrophic in the long run.

We can't protect everyone from everything. And what we've done here (or what
primarily Walter has done here) is to make some simple constructs that have
proven over time to cause bugs illegal. In each case, there's a simple
alternative that really doesn't cost you anything more. So, a simple mistake
is prevented without you losing expressiveness in the language and without
hiding problems. The programmer still has to do know what they're doing, and
they can still do exactly the same things that they could do before. It's
just that one class of mistake just became illegal in the language, so you
won't have that particular bug.

I really don't understand why you think that that's a bad thing. It would be
one thing if D prevented you from doing something the simple way and forced
you to bend over backwards to in order to be able to do it, but that's not
how we generally do things in D. In some cases, you do have to tell the
compiler that you know what you're doing and don't want the hand-holding
(e.g. with @safe vs @system), but in general, the stuff that's made illegal
is stuff that's going to cause problems, and the alternatives are pretty
much just as simple as what's being prevented.

You seem to be saying the programming equivalent to arguing that knives
don't need handles (just bare blades) and that anyone who wants to use a
knife should learn how to hold the blade properly without cutting
themselves.

No, we can't protect programmers from everything (and shouldn't try), but
that's no reason to give up on designing language features in a way that
minimizes stupid mistakes - especially when the result is just as expressive
and doesn't actually restrict the programmer.

If you want a language that doesn't protect you from anything, then C is
going to be a much better fit for you than D.

- Jonathan M Davis



More information about the Digitalmars-d mailing list