This and other RFCs are available on the web at
http://dev.perl.org/rfc/
=head1 TITLE
Allow Calling Any Function With A Syntax Like s///
=head1 VERSION
Maintainer: John Porter <[EMAIL PROTECTED]>
Date: 17 Aug 2000
Version: 1
Mailing List: [EMAIL PROTECTED]
Number: 139
=head1 ABSTRACT
The calling syntaces of m()/s() should be consistent with other forms of
function call; this should be achieved not by eliminating the traditional
C<//> form from m()/s(), but by allowing any function to be called with C<//>.
=head1 DESCRIPTION
The strings delimited by the slashes, or other allowed delimiters, would be
passed as the arguments to the function. Note that this would include a
possible trailing string of C<\w> characters.
Furthermore, if the binding operator is used in conjunction with the function
call, it is passed as the first argument by reference, appropriately arranged.
Some simple example should help to demonstrate the idea:
greek( 'alpha', 'beta' );
could be written as any of the following:
greek/alpha/beta/;
greek#alpha#beta#;
greek(alpha){beta};
And, taking advantage of the trailing C<\w> string:
greek/alpha/beta;
greek#alpha#beta;
greek(alpha)beta;
Now, the following in the new syntax
$foo =~ greek/alpha/beta;
would be the same as the following in old syntax:
greek( \$foo, 'alpha', 'beta' );
=head1 IMPLEMENTATION
The mechanism that is currently invoked in the parsing of m()/s() expressions
could be used generally.
Note that all the parameters are necessarily strings; numeric literals
do not get pre-converted by the compiler. Or rather, whatever perl does
for m()/s() arguments, that would also be done when this syntax is used
to call other functions.
head2 Further Observations
The proposed semantics of the binding operator C<=~> looks to my eye very much
like a method referencing operator for direct (non-blessed) variable objects.
That is, there is no reason to suppose that
for ( %db =~ grok/SSN/$ssn/g ) ) { ...
is not an invocation of the C<grok> "method" on the C<%db> "object".
=head1 REFERENCES
L<perlop> for details on the calling syntax of m//, s///.