Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Essentially regexen are two argument (or three argument or hypothetically four) operators which as far as operators go is pretty weird (note the only common operator like this is the ? : ternary operator. Since the nature of the operator itself has room for, 1, (or two or three depending on how you look at it) additional arguments there needs to be a way to invole the fourth. Sorry. to convert all that gobbleygook, look at this:
had the regex operators been expressed as function calls this might have worked as an option set, but notice that in some cases various arguments can be omitted. So if EXPR(1) is omitted $_ is used, in an s/// if REGEX(2) is omitted it uses the last m// pattern on the subject (EXPR(1)), and the modifiers can be omitted. So if this had been positional arguments it would have had a pretty strange argument signature. Try to come up with a reasonable way to pass the arguments into a function based s/// implementation with same behaviour of default operation on $_, and etc. Its not going to be nice, with many common calls using undef in their parameter list. Or alternatively hopelessly verbose like the dotNet regex implementation. So in short regex like operators need the binding part because its an optional part (at the front no less) of what is essentially a quaternary operator. Also as a last thought....
:-)
---
demerphq First they ignore you, then they laugh at you, then they fight you, then you win.
In reply to Re: Re: Why do we say the =~ operator "binds"?
by demerphq
|
|