Re: const?? When and why? This is ugly!

2009-03-08 Thread Burton Radons
Walter Bright Wrote: > Burton Radons wrote: > > Walter Bright Wrote: > > > >> Burton Radons wrote: > >>> This wouldn't be too bad because const is worthless when > >>> optimising, but if invariant is going to be given any weight then >

Re: const?? When and why? This is ugly!

2009-03-07 Thread Burton Radons
Walter Bright Wrote: > Burton Radons wrote: > > This wouldn't be too bad because const is worthless when optimising, > > but if invariant is going to be given any weight then we must never > > cause data to be casted to invariant unless if it's actually >

Re: const?? When and why? This is ugly!

2009-03-07 Thread Burton Radons
Derek Parnell Wrote: > On Sat, 07 Mar 2009 17:08:58 -0500, Burton Radons wrote: > > > Am I going to become a broken record on this? Because > > "invariant (char) []" is the string type, data that > > is going to be mutable will always find its way into > >

Re: const?? When and why? This is ugly!

2009-03-07 Thread Burton Radons
Walter Bright Wrote: > If I may restate your case, it is that given function that does > something with character arrays: > > int foo(string s); > > and you wish to pass a mutable character array to it. If foo was > declared as: > > int foo(const(char)[] s); > > then it would just work. So w

Re: const?? When and why? This is ugly!

2009-03-07 Thread Burton Radons
Walter Bright Wrote: > Burton Radons wrote: > > That's what we said about strings in 1.0. You modify it, you copy it, > > or you tell the user. The gentleman's agreement worked perfectly and > > that came without a mess of keywords, without implicit or explici

Re: const?? When and why? This is ugly!

2009-03-07 Thread Burton Radons
Walter Bright Wrote: > When we first got into what to do with strings and > const/immutable/mutable, I was definitely in the camp that strings > should be mutable char[], or at worst const(char)[]. The thing is, > Andrei pointed out to me, languages that are considered very good at > dealing w

Re: const?? When and why? This is ugly!

2009-03-06 Thread Burton Radons
Andrei Alexandrescu Wrote: > Burton Radons wrote: > > Andrei Alexandrescu Wrote: > > > >> This is a known problem for hich we will provide a solution. > > > > If you have something which works everywhere please tell us because > > we've been tryi

Re: Associating symbols with attributes (D 2.0)

2009-03-06 Thread Burton Radons
Jarrett Billingsley Wrote: > On Fri, Mar 6, 2009 at 4:25 PM, Burton Radons wrote: > > Not even the great Jarrett Billingsley has done this one? Dmn. Guess we > > will need attributes then. > > > > Psh! Most template hacking I learned from the best - Don an

Re: const?? When and why? This is ugly!

2009-03-06 Thread Burton Radons
Andrei Alexandrescu Wrote: > This is a known problem for hich we will provide a solution. If you have something which works everywhere please tell us because we've been trying to find one for a long time, but as far as I know there is no solution. The best I've ever gotten to is: // "A" mea

Re: const?? When and why? This is ugly!

2009-03-06 Thread Burton Radons
Andrei Alexandrescu Wrote: > In D you will be able to break any design with a cast, unless you use > the not-yet-defined D2 which disallows all risky casts. So the fact that > you can cast const away is hardly changing anything. Oh, and this is an idea which is almost exactly 20 years old, from

Re: Associating symbols with attributes (D 2.0)

2009-03-06 Thread Burton Radons
Not even the great Jarrett Billingsley has done this one? Dmn. Guess we will need attributes then.

Re: const?? When and why? This is ugly!

2009-03-06 Thread Burton Radons
Andrei Alexandrescu Wrote: > Burton Radons wrote: > > A more accurate way would be for the string type to be "const (char) > > []", and for functions which retain strings that can't change to take > > "invariant (char) []". That makes pretty good cla

Re: const?? When and why? This is ugly!

2009-03-06 Thread Burton Radons
Walter Bright Wrote: > Burton Radons wrote: > > I don't get it either. Any possible application for const in the form > > of code correctness went out the window once the invariant virus > > forced all strings to be invariant whether they were or not; so I > > st

Re: const?? When and why? This is ugly!

2009-03-05 Thread Burton Radons
I don't get it either. Any possible application for const in the form of code correctness went out the window once the invariant virus forced all strings to be invariant whether they were or not; so I still need to use dup to guarantee that data won't change underneath me, but then I need to cas

Re: Null references (oh no, not again!)

2009-03-05 Thread Burton Radons
Walter Bright Wrote: > Jason House wrote: > > IMHO, this type of thing is easy to understand. > > Yeah, well, I still get regular emails (for the last 20 years at least) > from the gamut of professional programmers at all levels of expertise > who do not understand what "undefined symbol" from

Associating symbols with attributes (D 2.0)

2009-03-05 Thread Burton Radons
I'm working on a string conversion template (well, incidentally to more important stuff). I've got it automatically converting enumerations to strings, but I have mask-type enumerations, single-value enumerations, and combination enumerations where there's a value in one part of the integer and