Skip to content

Feature Request: Expand MRB_SYM/MRB_GVSYM support for symbols with special characters and numbers #6687

Description

@buty4649

When optimizing performance in mruby-onig-regexp, symbols containing special characters or numbers are not supported by MRB_SYM or MRB_GVSYM macros, requiring runtime mrb_intern_lit() calls that create performance bottlenecks.
Target symbols: $~, $&, $`, $', $+, $0~$9, []

Current Limitations

// Cannot use these
MRB_GVSYM(~) // error: pasting "MRB_GVSYM__" and "~" does not give a valid preprocessing token
MRB_GVSYM(0) // error: ‘MRB_GVSYM__0’ undeclared (first use in this function); did you mean ‘MRB_GVSYM_2’?
MRB_SYM([])  // error: pasting "MRB_SYM__" and "[" does not give a valid preprocessing token

Current Workaround Issues

Currently using workarounds like below, but they have initialization overhead:

// Current workaround
static mrb_sym sym_dollar_tilde;
sym_dollar_tilde = mrb_intern_lit(mrb, "$~");

Request

Could you please add support for symbols containing special characters and numbers to the MRB_SYM/MRB_GVSYM macros? This would significantly improve regular expression processing performance and enable efficient implementation of Ruby's regular expression library in mruby.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions