On 2/7/13 1:34 AM, H. S. Teoh wrote:
On Wed, Feb 06, 2013 at 10:09:48PM -0800, Walter Bright wrote:
On 2/6/2013 8:16 PM, Marco Leise wrote:
As for the address taking, I hope it doesn't end up in being
nannied to much by the language. Like in the case with printf,
it could really piss people off that don't understand the
reasoning behind it. Make the error message informative for
that: "Potential escape of pointer to stack local" or
similar.
I think C++ missed an opportunity with reference types. All they are
in C++ are just another way to express a pointer. They don't really
offer any semantic improvement - you can even have null references.
In D, we have an opportunity to define reference types as a kind of
"safe" pointer type - where we can get much of the advantages of
pointers without the potential for memory corruption.
D ref types are currently highly crippled because of the inability to
declare ref variables, which mandates ugly workarounds. It should be a
first-class type qualifier IMO. (Yes I know it's currently a *function*
qualifier, not a type qualifier... which makes it all the more ugly.)
Unfortunately type qualifiers have very high complexity costs. I think
it's very neat that we managed to keep ref the way it is. Yes, I, too,
would like to have a ref variable sometimes, but overall I'm please with
the way it's working (post DIP25 especially).
Andrei