Christopher Smith wrote:
If you don't appreciate the advantages over Java and C#, I can't explain
them to you.

Funky.

runtime cost for this should be no more than the cost of adding the null
pointer check manually in each place in the code (this is the joy of

Which is actually more of a performance hit than many languages that have this sort of checking built in.

In Ada, for example, you can code something like
  for i := x'first to x'last do y := y + x[i]
(And I'm sure I'm forgetting the proper syntax there).

The compiler can look at that and know that i never goes out of bounds and not bother to generate array bounds checks. Even if you managed something like that in C++, you'd still then have the problem of things like other threads stomping on variables inappropriately, such that the optimized code doesn't do what the unoptimized code does. *That* is why language designers build stuff into the language instead of putting everything in libraries.

I don't see why knowing that you've got
guaranteed checks prior to dereferencing in C++ ought to add more
cognitive load than knowing that in some other language.

The cognitive load is deciding each time whether you need a checked pointer or an unchecked pointer. If you *never* need an unchecked pointer, why isn't it built in?

--
  Darren New / San Diego, CA, USA (PST)
    His kernel fu is strong.
    He studied at the Shao Linux Temple.

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to