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

[BUG] closures lose their attributes

Thread Next
From:
Tom Christiansen
Date:
March 16, 2000 20:54
Subject:
[BUG] closures lose their attributes
Message ID:
17244.953268851@chthon
The short story is that a closure (not just an anonymous function)
loses its attributes.


Demo:

    #!/usr/bin/perl -l
    use attributes;
    sub prat { "[" . join(" : ", attributes::get(shift)) . "]" } 

    my $empty  = sub () : locked: method {        };
    my $full   = sub () : locked: method { time() };
    my $closed = sub () : locked: method { $empty };

    print "empty has attrs: ",  prat($empty);
    print "full has attrs: ",   prat($full);
    print "closed has attrs: ", prat($closed);

Output:

    empty has attrs: [locked : method]
    full has attrs: [locked : method]
    closed has attrs: []

--tom

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