From: Paul Makepeace <[email protected]>
   Date: Fri, 18 Jun 2010 17:29:31 -0700

   On Thu, Jun 17, 2010 at 12:55, Tom Metro <[email protected]> wrote:
   >
   > Steve Scaffidi wrote:
   > > First, I read this here: http://www.perlmonks.org/?node_id=304883
   >
   > Yup, that's pretty much the definitive reference on this "feature."
   >

   All this nonsense when perl presumably has everything it needs to
   support actually naming the thing syntactically,

     my $foo = sub foo { ... };

   Anyone know if there's some philosophical/technical reason not to have
   this in the language? (Not to be able to call it by name, just name
   it)

   Paul

The problem with this particular syntax is that "sub foo { ... }"
(i.e. with a bareword) has always meant "define 'foo' as a sub in the
current namespace", even from within an outer sub.  Whether that's
enough of a philosophical barrier or not, I don't know.

   The other problem is that "$foo" and "foo" ought always to agree [1].
Having to specify both is awkward, and leads to problems if one gets
changed without changing the other.  (This is also a drawback of
Sub::Name.)

   In any case, ISTM that Perl could use something like

        sub my $foo { ... }

This strikes me as syntactically parallel to autovivifying lexical
filehandles via "open(my $foo, ...)".  (Except that you'd have to say it
somewhat differently if you wanted $foo to be recursive.)

   But I note that the earliest copyright on Sub::Name is 2004, since
which time all of Larry's energies have been directed towards Perl 6.
So probably nobody has gotten sufficiently motivated to deal with this
in Perl 5.

                                        -- Bob Rogers
                                           http://www.rgrjr.com/

[1]  Modulo scoping issues; there could be more than one $foo sub.

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to