Why can't a Regex object be immutable?
Shriramana Sharma via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jan 1 18:39:36 PST 2016
cym13 wrote:
> I think it's because regex() only compiles the regex at runtime
> so it needs to be modified later ;
Aw come on. The immutability of the variable is *after* it has been created
at runtime.
> > you'll find that using
> ctRegex() instead will allow you to declare it immutable for
> example. I didn't look at the implementation to identify a
> precise cause though.
You mean ctRegex!(), but nope:
immutable numbers = ctRegex!r"\d+";
or doing const there gives the same error and using auto doesn't.
--
Shriramana Sharma, Penguin #395953
More information about the Digitalmars-d-learn
mailing list