develooper Front page | perl.perl5.porters | Postings from July 2001

[PATCH op.c] \? prototype

Thread Previous | Thread Next
From:
Jeff 'japhy/Marillion' Pinyan
Date:
July 29, 2001 07:49
Subject:
[PATCH op.c] \? prototype
Message ID:
Pine.GSO.4.21.0107291047470.28213-100000@crusoe.crusoe.net
On Jul 29, Arthur Bergman said:

>01-07-29 03.05, skrev Michael G Schwern på schwern@pobox.com följande:
>
>>> my %hash = (a => 1, b => 2);
>>> my $ref  = \$hash;
>>> readonly \%hash;     # clamped
>> 
>> C<readonly %hash> should be achievable by simply using the \% prototype.
>
>No, since you can do readonly $scalar aswell.
>
>I have the same problem with
>lock/unlock/cond_wait/cond_signal/cond_broadcast
>
>A \($|@|%) prototype or something like that taking a reference to anything
>would be a very very very welcome addition.

How about a \? prototype, which automatically takes a reference?  Then the
user can decide, inside the function, what to accept?  Patch below sig.

I've not done RIGOROUS testing, nor patched the docs, since I want to know
if anyone feels strongly about it being this way.

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **

--- op.c.old	Sun Jul 29 10:46:18 2001
+++ op.c	Sun Jul 29 10:46:38 2001
@@ -6594,6 +6594,8 @@
 		proto++;
 		arg++;
 		switch (*proto++) {
+		case '?':
+		    goto wrapref;
 		case '*':
 		    if (o2->op_type != OP_RV2GV)
 			bad_type(arg, "symbol", gv_ename(namegv), o2);


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About