develooper Front page | perl.perl5.porters | Postings from May 2021

Re: Namespaces (was Re: Revisiting trim)

Thread Previous | Thread Next
Paul "LeoNerd" Evans
May 28, 2021 20:48
Re: Namespaces (was Re: Revisiting trim)
Message ID:
Unclear from this discussion whether it was explicitly pointed out, but
one thing I'd like to see from the "keyword" functions is that they
*not* appear in the package's symbol table.

It's annoying enough that when you do this

  package My::Class;
  use Scalar::Util 'weaken';

Then `weaken` is visible as a method:

  My::Class->weaken( ... )
  $myobj->weaken( ... )

It would be great if code could enable keyword-shaped operators like
"trim(med)?" and so on without adding massively to their exposed "API"

Already I have begun experimenting with keyword-implemented list
utility functions under List::Keywords - and those have the property of
only being lexically visible and not visible as object/class methods:

$ perl -e \
  'package My::Class { use List::Keywords 'all' } My::Class->all(1,2,3)'
Can't locate object method "all" via package "My::Class" at -e line 1.

It would be great if the same could be said of

$ perl -e \
  'package My::Class { use keyword 'string::trimmed' } ...

Paul "LeoNerd" Evans      |  |

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About