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

Re: [PATCH] Interesting syntax idea

Thread Previous | Thread Next
From:
Simon Cozens
Date:
December 29, 2000 11:49
Subject:
Re: [PATCH] Interesting syntax idea
Message ID:
20001229151016.A8678@deep-dark-truthful-mirror.perlhacker.org
On Fri, Dec 29, 2000 at 02:34:04PM +0000, Simon Cozens wrote:
> +# Testing DWIM of foo = bar;
> +sub foo : lvalue {
> +    $a;
> +}
> +open bar, ">nothing" or die $!; 

This might cause people to wonder why I didn't test the case where
you have a name representing both a filehandle and a subroutine.

The answer is, you can't (yet) do that. This is pretty weird:

    sub bar {print( "Called at line ", (caller)[2], "\n"); };
    open bar, ">-";
    print bar "This is stdout";
Called at line 2
Called at line 3
1

Hmm.

    open bar, ">-";
    sub bar {print( "Called at line ", (caller)[2], "\n"); };
    print bar "This is stdout";
Called at line 3
1

Hmm hmm.

    open bar, ">-";
    print bar "This is stdout";
    sub bar {print( "Called at line ", (caller)[2], "\n"); };
This is stdout

Hmm hmm hmm.

Is that *right*?

-- 
I did write and prove correct a 20-line program in January, but I made
the mistake of testing it on our VAX and it had an error, which two
weeks of searching didn't uncover, so there went one publication out the
window.  - David Gries, 1980

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