Const template

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Sat Jan 20 22:46:54 PST 2007


Dave wrote:
> IIRC, Walter has made mention of const truly being 'readonly', even to 
> the point of wishing for some way to enforce it with hardware or OS 
> support. It should be in the archives somewhere. Like I said I hope he 
> can be or already is convinced otherwise since hardware / OS support 
> isn't available, at least on the most popular platforms.

OS support is often available, but in too coarse a manner (page-level 
read-only) to be used pervasively at language level. C++ compilers of 
today go as far as massaging all read-only data of an executable in 
read-only pages, which has been quite effective, yet not applicable at a 
finer scale.

Things have improved with regards to understanding the value of const. 
It turns out that true read-only is the least interesting of const's 
benefits, and that 'view-only domains' is a much more powerful paradigm. 
  D will have const. The main issues wrt const are (1) fixing the inout 
disaster, (2) figuring a semantics for const that works with the current 
D and devising the appropriate blend of deduction and user-level 
annotation (C++ has too little of the former and imposes too much of the 
latter), and (3) figuring a priority of the implementation on D's busy 
agenda, where there are many much more exciting features than const.

> I should qualify "designs".. There were a few posts that may be 
> considered full-fledged "designs", but most of them were just ideas put 
> forward on const and how to make it generally usable. The problem always 
> came to be that none of them could guarantee what was understood as a 
> prerequisite from Walter - truly read-only.

Or none of them converted that lack of guarantee miraculously into a 
feature :o). (I'm more serious than I might seem!)


Andrei



More information about the Digitalmars-d mailing list