[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Re: Whether to laugh or cry



simon@brecon.co.uk (Simon Cozens) writes:

> Damian Conway (lists.perl-friends):
> >BTW, have you looked inside the Class::Data::Inheritable?
> >Trampolines that are closures containing recursive trampolines: bwah-ha-ha-ha!
> 
> Youch, that's uh, somewhat odd. I think in what I was doing, trampolines
> made a bit of sense - deciding on demand which way to do something.
> Maybe a function ref would have been simpler, though.
> 
> Besides, why can't one assign to *foo{CODE}? It seems less messy than
> zapping the entire glob.

But saying "*foo = sub { ... }" doesn't zap the glob:

..............................................................................
<bioserv 164 [13:26] ~/Perl/Error >perl -de 42

Loading DB routines from perl5db.pl version 1.0402
Emacs support available.

Enter h or `h h' for help.

main::(-e:1):   42
  DB<1> $x = 'foo'

  DB<2> @x = qw/this quick fox/

  DB<3> *x = sub { print "hello, world!\n" }

  DB<4> x @x
0  'this'
1  'quick'
2  'fox'
  DB<5> x $x
0  'foo'
  DB<6> p x 
hello, world!
1

..............................................................................

Assigning a ref to a glob only overwrites the appropriate slot.  You
still can't assign to *foo{CODE} (or *foo{SCALAR}), though.  Go
figure.

-- 
Ariel Scolnicov        |"GCAAGAATTGAACTGTAG"            | ariels@compugen.co.il
Compugen Ltd.          |Tel: +972-2-6795059 (Jerusalem)	\ We recycle all our Hz
72 Pinhas Rosen St.    |Tel: +972-3-7658514 (Main office)`---------------------
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555    http://3w.compugen.co.il/~ariels

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe