#3936 compiled regexp behaves differently

obsolete: 8.5.1
open
8
2008-07-21
2008-02-27
No

From comp.lang.tcl: <slrnfro618.4ug.avl@gamma.logic.tuwien.ac.at>

% set pattern --; set text ----
% regexp $pattern $text; # no error
1
% regexp -- ---- ; # error for same arguments.
wrong # args: should be "regexp ?switches? [...]"

This bug-report only documents the difference,
not which of the two is to be considered correct.

Discussion

  • Don Porter

    Don Porter - 2008-03-11

    Logged In: YES
    user_id=80530
    Originator: NO

    This is the same issue as the compiled
    two argument [switch].

     
  • Don Porter

    Don Porter - 2008-03-11
    • priority: 5 --> 8
     
  • Don Porter

    Don Porter - 2008-03-11

    Logged In: YES
    user_id=80530
    Originator: NO

    That is, 1899962.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2008-03-12

    Logged In: YES
    user_id=72656
    Originator: NO

    I believe the 2nd variant (eval version) is what should be fixed. The extended info from wrong#args is:

    wrong # args: should be "regexp ?switches? exp string ?matchVar? ?subMatchVar subMatchVar ...?"

    This indicates 2 known required args, and 2 args are given to regexp. Why try to find errors when we can otherwise assume a regexp+2args == [regexp $pat $str] at all times?

     
  • Don Porter

    Don Porter - 2008-03-12

    Logged In: YES
    user_id=80530
    Originator: NO

    I agree that is the most sensible
    way to define the behavior of this
    command.

    The snag is that the implementation
    over many years *and the documentation*
    disagree, saying that anything that
    starts with "-" gets an attempt at
    interpretation as a switch.

    This is stupid, and it foils many
    cases that could otherwise be compiled,
    so I agree we should change it like
    we changed [switch].

    Just be ready for the same flood of
    complaints we got about the [switch]
    change.

     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902
    Originator: NO

    Be aware of the test regexp-20.2

     
  • Don Porter

    Don Porter - 2008-03-27

    Logged In: YES
    user_id=80530
    Originator: NO

    dkf points out the roadblock case:

    % regexp -about foo
    0 {}
    % set e -about
    -about
    % set s foo
    foo
    % regexp $e $s
    0

     
  • miguel sofer

    miguel sofer - 2008-07-21

    Logged In: YES
    user_id=148712
    Originator: NO

    This is tclguy's turf, I believe (and hope)

     
  • miguel sofer

    miguel sofer - 2008-07-21
    • assigned_to: msofer --> hobbs