Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.86k stars 528 forks source link

globbing modules' mutual inconsistencies #1500

Open p5pRT opened 24 years ago

p5pRT commented 24 years ago

Migrated from rt.perl.org#2713 (status was 'open')

Searchable as RT2713$

p5pRT commented 24 years ago

From tchrist@chthon.perl.com

File​::DosGlob uses 'GLOBAL_glob' (not a real function) for the same kind of thing that File​::Glob uses '​:globally' (an import tag) for.

Perl should figure out a regular convention for this kind of thing. Here's one way​:

  use File​::DosGlob '​:EVERYWHERE';   use File​::Glob '​:EVERYWHERE';

Normally\, I'd say "​:GLOBALLY"\, but that looks too confusing with these globbish modules.

I've already reported the oddness that File​::Glob's "​:globally" doesn't even make the fileglobbing operators use &File​::Glob​::glob\, either. It makes it use csh_glob instead.

You know\, that read better this way​:

  use File​::Glob qw/csh_glob :EVERYWHERE/;   use File​::Glob qw/glob :EVERYWHERE/;

But violates the "put the colon tags first" notion. Legibility in English is the more important factor here\, so that notion can be trampled on.

Another idea is from there's CGI.pm's -foo style​:

  use File​::Glob qw/-everywhere csh_glob/;   use File​::Glob qw/-everywhere glob /;

Or\, since we're rolling our own imports\, even something like

  use File​::Glob qw/ glob=csh_glob :UBIQUITOUSLY /;   use File​::Glob qw/ glob=posix_glob :UBIQUITOUSLY /;

Or shorter​:

  use File​::Glob qw/​:UBI glob=csh_glob /;   use File​::Glob qw/​:UBI glob=posix_glob /;

Or

  use File​::Glob qw/​:UBI=package glob=csh_glob /;   use File​::Glob qw/​:UBI=program glob=posix_glob /;

Or

  use File​::Glob qw/​:WHERE=PACKAGE glob=csh_glob /;   use File​::Glob qw/​:WHERE=PROGRAM glob=posix_glob /;

--tom

p5pRT commented 24 years ago

From [Unknown Contact. See original ticket]

Tom Christiansen writes​:

use File​::DosGlob '​:EVERYWHERE';
use File​::Glob    '​:EVERYWHERE';

If you make it an adjective\, it works​:

  use File​::Glob '​:UNIVERSAL';   use File​::Glob '​:UNIVERSAL csh_glob';

This risks confusion with UNIVERSAL​::\, but the concept is pretty similar.

Nat

p5pRT commented 24 years ago

From [Unknown Contact. See original ticket]

If you make it an adjective\, it works​: use File​::Glob '​:UNIVERSAL'; use File​::Glob '​:UNIVERSAL csh_glob';

I tend to think of it as wanting to modify "use" as an adverb of location not the package name or function name. And yes\, adverbs can float better than adjectives in English\, but they don't like being put here​:

  # (we'll skip the "​:GLOBALLY" and "​:UBIQUITOUSLY" this time around)

  use File​::Glob qw(​:UNIVERSALLY &csh_glob);   use File​::Glob qw(​:HERE &csh_glob); # redundant   use File​::Glob qw(​:PROGRAM-WIDE &csh_glob);   use File​::Glob '​:ALL OVER THE PLACE'\, '&posix_glob';

whereas if you put the modifer at the end of the list\, it can be an adverb for "use" once again.

  use File​::Glob qw(&glob :UNIVERSALLY);

Even though this isn't really like CLI programs that expect their modifiers right after the verb (which we can't do\, because we need the package their) and before their objects.

  execute -quickly someproggy

I think the problem is that the package is the genitive for the noun list following\, so

  use File​::Glob '&csh_glob';

really reads

  Please use the File​::Glob module's csh_glob function.

or

  Please use File​::Glob's &csh_glob.

And English isn't happy interposing a non-immediate modifier between the possessive and the possessed. (Yes\, I just said that csh is possessed\, but we knew that. :-) It's something of a determiner in this regard. So we could use File​::Glob's bodacious &glob but we couldn't use File​::Glob's universal &glob\, because then universal would end up modifying "&glob" not "use"\, and there is no UNIVERSAL​::glob\, but rather a CORE​::glob. Hm...

  use File​::Glob qw/CORE glob/;   use File​::Glob qw/​:CORE glob/;

That might work.

--tom