www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9391] New: Constant std.regex.regex

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9391

           Summary: Constant std.regex.regex
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This is a low-priority enhancement request (meta-enhancement request: in
Bugzilla I'd like different tags for different enhancement request priorities).

This code works:


import std.stdio, std.regex;
void main() {
    auto r = regex(r"\d+", "g");
    "10 20 30".match(r).writeln();
}


And prints:

[["10"], ["20"], ["30"]]



While this code:

import std.stdio, std.regex;
void main() {
    const r = regex(r"\d+", "g");
    "10 20 30".match(r).writeln();
}


Shows (dmd 2.062alpha):

test.d(4): Error: template std.regex.match does not match any function template
declaration. Candidates are:
...\dmd2\src\phobos\std\regex.d(6532):        std.regex.match(R, RegEx)(R
input, RegEx re) if (isSomeString!(R) && is(RegEx ==
Regex!(BasicElementOf!(R))))
...\dmd2\src\phobos\std\regex.d(6539):        std.regex.match(R, String)(R
input, String re) if (isSomeString!(R) && isSomeString!(String))
...\dmd2\src\phobos\std\regex.d(6545):        std.regex.match(R, RegEx)(R
input, RegEx re) if (isSomeString!(R) && is(RegEx ==
StaticRegex!(BasicElementOf!(R))))
...\dmd2\src\phobos\std\regex.d(6532): Error: template std.regex.match cannot
deduce template function from argument types !()(string,const(Regex!(char)))


I suggest to support constant regex, if possible. (In D code I like to mark
everything as not mutable unless it has to mutate).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9391


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh gmail.com
           Severity|enhancement                 |normal



12:50:39 PST ---
This is more like a minor bug. Got to fix it.

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