[Issue 7260] "g" on default in std.regex

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 10 11:54:58 PDT 2013


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



--- Comment #8 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2013-03-10 11:54:55 PDT ---
(In reply to comment #7)
> (In reply to comment #5)
> 
> > match(someString, pattern).all //range of all matches
> > match(someString, pattern).first //only the first one
> > match(someString, pattern) // using the "g" flag to decide
> 
> 
> (In reply to comment #6)
> 
> > No overrides used would imply "use whatever the default mode is". 
> > 
> > How does it sound? 
> > 
> > Then we place nice bold warning that use of "g" option is discouraged and is
> > provided only for compatibilty and is going be deprecated in future.
> > 
> > A year later and depending on the mood of people it gets finally deprecated and
> > slowly shifted towards oblivion.
> 
> Once "g" is deprecated what is match(someString, pattern) (without all and
> first) doing?

Could go both ways. The other posibility I just thought about is:

match(...).first - is the same as current match(...).front i.e. simplify
interface for the case when 1 match is needed
match(...).all - the same as current match(... with "g" overrided) i.e. a range

Then once "g" is off we could either make .all a nop.

Alternative is to make it opaque object that has 2 methods only .first/.all.

The third alternative to add alias this to make .first implicit. I feel it
won't work reliably with range-based templates as it would make it "2 ranges in
one".

So only the first 2 are viable. I'd go with 1st that gets upgraded to the
second once people forget about "g" switch entierly.

-- 
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