develooper Front page | perl.perl5.porters | Postings from December 2000

Re: [PATCH] Interesting syntax idea

Thread Previous | Thread Next
From:
Jarkko Hietaniemi
Date:
December 28, 2000 14:32
Subject:
Re: [PATCH] Interesting syntax idea
Message ID:
20001228163235.A18526@chaos.wustl.edu
On Wed, Dec 27, 2000 at 05:08:57AM +0000, Simon Cozens wrote:
> This makes
>     foo = bar;
> into
>     foo() = "bar"
> 
> but
>     open foo, "one" or die $!;
>     open bar, "two" or die $!;
>     foo = bar;
> into
>     *foo = *bar;
> 
> at the possible cost of sanity. Combine with previous patch, and think Pythony
> thoughts.

Gimme some tests for this change and I'm prepared to be snakey.

> --- op.c~	Wed Dec 27 02:29:56 2000
> +++ op.c	Wed Dec 27 04:58:54 2000
> @@ -1336,6 +1336,31 @@
>  	PL_modcount++;
>  	return o;
>      case OP_CONST:
> +        if (o->op_private & (OPpCONST_BARE) && 
> +                !(type == OP_GREPSTART || type == OP_ENTERSUB || type == OP_REFGEN)) {
> +            SV *sv = ((SVOP*)o)->op_sv;
> +            GV *gv;
> +
> +            /* Could be a filehandle */
> +            if (gv = gv_fetchpv(SvPV_nolen(sv), FALSE, SVt_PVIO)) {
> +                OP* gvio = newUNOP(OP_RV2GV, 0, newGVOP(OP_GV, 0, gv));
> +                op_free(o);
> +                o = gvio;
> +            } else {
> +                /* OK, it's a sub */
> +                OP* enter;
> +                gv = gv_fetchpv(SvPV_nolen(sv), TRUE, SVt_PVCV);
> +
> +                enter = newUNOP(OP_ENTERSUB,0, 
> +                        newUNOP(OP_RV2CV, 0, 
> +                            newGVOP(OP_GV, 0, gv)
> +                        ));
> +                enter->op_private |= OPpLVAL_INTRO;
> +                op_free(o);
> +                o = enter;
> +            }
> +            break;
> +        }
>  	if (!(o->op_private & (OPpCONST_ARYBASE)))
>  	    goto nomod;
>  	if (PL_eval_start && PL_eval_start->op_type == OP_CONST) {
> 
> -- 
> It's much better to have people flaming in the flesh.  -Al Aho

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

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