[Issue 8338] Unqual doesn't work properly on arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 2 21:01:16 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8338



--- Comment #4 from Kenji Hara <k.hara.pg at gmail.com> 2012-07-02 21:01:13 PDT ---
(In reply to comment #3)
> Maybe. But I'm not completely convinced that it would break all that much code
> - particularly since I would have expected any code using Unqual to be written
> with the intention of stripping _all_ of the qualifiers (as the documentation
> says).

But, getting type stripped full qualifiers is much unsafe than just top.

  const string s = "Hello";   // const(immutable(char)[])
  auto mutable_s = cast(Unqual!(typeof(s)))s;  // ???

In many cases, current Unqual is used with unsafe casting, even if it is bad
idiom. Changing the implementation of Unqual will become such codes *more*
unsafe silently.
(As far as I know, Phobos doesn't have such bad using. I'm talking about the
user codes written by programmers don't know well about const/immutable type
system.)

And in (sadly) few cases that uses Unqual correct way, it will change codes
from safe to unsafe.

  Stripping top qualifier of array/string types:
 
https://github.com/D-Programming-Language/phobos/blob/master/std/format.d#L1634
 
https://github.com/D-Programming-Language/phobos/blob/master/std/format.d#L1705


> If we don't make the change though, we need a new template similar to
> Unqual (FullUnqual? RecUnqual?) which really _does_ strip all of the
> qualifiers.

Noqual?

Or, add new two templates, one removes just top qualifier, another does all
qualifiers. I think this is the best way, but have no idea about their names...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list