Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: YAML::XS perl/regexp (?u:(?u:

by ikegami (Patriarch)
on Dec 05, 2017 at 15:32 UTC ( [id://1204967]=note: print w/replies, xml ) Need Help??


in reply to YAML::XS perl/regexp (?u:(?u:

YAML should store the pattern (( re::regexp_pattern($re) )[0]) and the modifiers (( re::regexp_pattern($re) )[1]) separately.

Replies are listed 'Best First'.
Re^2: YAML::XS perl/regexp (?u:(?u:
by shmem (Chancellor) on Dec 06, 2017 at 22:07 UTC
    YAML should store the pattern (( re::regexp_pattern($re) )[0] ) and the modifiers ( ( re::regexp_pattern($re) )[1] ) separately.

    ...and YAML::XS should make use of XS(XS_re_regexp_pattern) in universal.c to achieve that. Inevitably, this raises backcompat issues.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

      and YAML::XS should make use of XS(XS_re_regexp_pattern) in universal.c

      And how does one do that? XS(XS_re_regexp_pattern) creates the Perl sub re::regexp_pattern, so that's a very weird way of saying that YAML::XS should call Perl sub re::regexp_pattern.

      Inevitably, this raises backcompat issues.

      This can be addressed by storing them as a different type than perl/regexp (perl/regexp_plus_mods?).

        i think shmem was talking about regexp_pattern only available since perl 5.10, while YAML and YAML::XS aim to spport 5.8. I wonder how your suggeestion addresses that. Can you elaborate or did you mean something else?
Re^2: YAML::XS perl/regexp (?u:(?u:
by tinita (Parson) on Dec 08, 2017 at 16:54 UTC
    It would be possible to store a regex as a sequence and use the same tag for it:
    --- re1: !!perl/regexp (?^usi:pattern) re2: !!perl/regexp [ pattern, isu ]
    For perl 5.8 the old behaviour could be used. This could be done for YAML and YAML::XS. Possibly also for YAML::Syck, which has the same problem, but I would have to ask Todd, the maintainer.

      You can add understanding of !!perl/regexp [ pattern, isu ] at any time, but backwards compatibility requires making the generation of that an option. Eventually, once support has been established, it could default to the new method.

        Another possibility would be to continue just using a string. Check with regexp_pattern(), if there are any flags (ignoring u), just store the stringified regex, otherwise store the pattern itself. This would still lead to unnecessary (?:...) but it wouldn't grow in roundtrips.
        Have been looking into universal.c how regexp_pattern() is implemented. At the moment it's too much magic for me to understand.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1204967]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-26 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found