D const design rationale

Derek Parnell derek at psych.ward
Sat Jun 23 16:24:15 PDT 2007


On Sat, 23 Jun 2007 08:32:36 -0700, Sean Kelly wrote:

> Will 'invariant' help to make my code more optimal?

Yeah ... what he said.

I'm with Sean on these points. There seems to be a false dichotomy being
peddled here; that optimal run-time performance is mutually exclusive with
source code that is cheap to write and maintain.

D is so close to given us both that I constantly scream at the ugly warts
that is being instilled into this wonderful language.

I agree that the concepts behind 'const' and 'invariant' represent two
different and valid concepts that need to be catered for. The problem is in
their proposed implementation. The keywords chosen are a hinderence to D
source maintenance because they both appear to mean either of these two
concepts. Sure, they will be learned and distingushed in one's mind over
time, I've no doubt of that, but that is the problem in itself. Instead,
why not use different key words that actually reflect the differences in
the two concepts.

A second issue I have is that by forcing 'const' to be explicitly coded in
function parameter lists, you are reducing the ability of the compiler to
help detect bugs.

-- 
Derek Parnell
Melbourne, Australia
"Justice for David Hicks!"
skype: derek.j.parnell



More information about the Digitalmars-d mailing list