better string
Mike B Johnson via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 7 16:57:44 PDT 2017
On Wednesday, 7 June 2017 at 21:32:25 UTC, ag0aep6g wrote:
> On 06/07/2017 12:58 PM, Mike B Johnson wrote:
>> Why not alias string so that one can easily switch from the
>> old string or wstring, etc?
>>
>> e.g., rename string internally to sstring or whatever.
>>
>> then globally define
>>
>> alias string = sstring;
>>
>> Which can be over realiased to wstring to affect the whole
>> program
>>
>> alias string = wstring;
>>
>> Or use a command line to set it or whatever makes you happy.
>
> I'm not sure what exactly you're asking for, but `string` is an
> alias already (of `immutable(char)[]`). And you can define your
> own `string` as you like. `alias string = wstring;` works.
But that isn't program/compiler wide. e.g., stringof won't return
a wstring if you do the alias, will it?
Or will simply setting "alias string = wstring;" at the top of my
program end up having the entire program, regardless of what it
is, use wstring's instead of strings?
e.g.,
when I do a string literal
"This is a string" but do your alias, is the literal a string or
wstring?
The reason I say this is because I converted my program to use
wstrings but I got many errors because of string literals being
interpreted as strings and no automatic conversion took place, I
had to append w to turn then in to wstrings.
More information about the Digitalmars-d
mailing list