Module naming advice
Hi all, I'm about to release Aliased to the CPAN. Yeah, it's a root level name, but it will soon become clear why it needs to be short. SYNOPSIS: use Aliased 'Really::Long::Module::Name'; use Aliased 'Really::Long::Conflicting::Module::Name' as MName; use Aliased 'Another::Silly::Example' import = [qw/foo bar baz/]; # my $name = Really::Long::Module::Name-new; my $name = Name-new; # my $mname = Really::Long::Conflicting::Module::Name-new my $mname = MName-new; # my $wibble = Another::Silly::Example-constructor. my $wibble = Example-constructor; Basically, when you have long package names, it can be cumbersome to retype the package name all the time. This module allows you to skip that if the subroutines are called as methods. It exports a subroutine into your namespace that is the desired alias for the module. Having used something similar in a large system, I found that having this feature became quite addictive. Since this affects compile-time behavior, it seemed more appropriate to think of this as a pragma and have use aliased but I know that some frown on that (of course, Ingy released only and I didn't hear any complaints.) Is Aliased a good name? Is aliased better? Am I overlooking anything? Cheers, Ovid = Silence is Evil http://users.easystreet.com/ovid/philosophy/decency.html Ovid http://www.perlmonks.org/index.pl?node_id=17000 Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/
Re: Module naming advice
On Tue, 4 Jan 2005 12:49:16 -0800 (PST), Ovid [EMAIL PROTECTED] wrote: I'm about to release Aliased to the CPAN. [ . . . . ] Basically, when you have long package names, it can be cumbersome to retype the package name all the time. This module allows you to skip that if the subroutines are called as methods. It exports a subroutine into your namespace that is the desired alias for the module. Having used something similar in a large system, I found that having this feature became quite addictive. [ . . . . ] Is Aliased a good name? Is aliased better? Am I overlooking anything? Are you aware of Alias.pm? - Kurt
Re: Module naming advice
--- Kurt Starsinic [EMAIL PROTECTED] wrote: On Tue, 4 Jan 2005 12:49:16 -0800 (PST), Ovid [EMAIL PROTECTED] wrote: I'm about to release Aliased to the CPAN. [ . . . . ] Basically, when you have long package names, it can be cumbersome to retype the package name all the time. This module allows you to skip that if the subroutines are called as methods. It exports a subroutine into your namespace that is the desired alias for the module. Having used something similar in a large system, I found that having this feature became quite addictive. [ . . . . ] Is Aliased a good name? Is aliased better? Am I overlooking anything? Are you aware of Alias.pm? I am aware of that module. It does something completely different from mine, so I'm not worried about duplicating functionality. However, I do realize the name can cause some confusion. I welcome other suggestions. I had briefly considered module.pm or class.pm, but I envisioned howls of protests: use class Really::Long::Class::Name; my $o = Name-new; However, I do think it's more clear. Cheers, Ovid = Silence is Evil http://users.easystreet.com/ovid/philosophy/decency.html Ovid http://www.perlmonks.org/index.pl?node_id=17000 Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/
Re: Class::Validation
On Tue, 23 Nov 2004, Daisuke Maki wrote: The module is tentatively named Params::Validate::Inheritable, but Dave Rolsky and I neither like that particular idea. To quote Dave: I think P::V::Inheritable isn't quite right for classes that are intended to be generic superclasses, or to add methods to other classes. In fact, it's really a role-type class, and something like Class::Validating might be better. On top of Dave's suggestion I'm thinking towards the line of Class::ValidateArgs, Class::Validation, Class::ParamValidation, etc. Please let me know if you have any comments. Looks like you got warnocked on this one, huh? I'd really like to see this released, cause I could use it. I think since it is a generic add something to a class module, it needs to be in Class::. Beyond that, I'm not too concerned. I think having the second part end in -ing or -es is good, as opposed to a noun, since it adds an _action_ to a class, not a property (well it adds both, but it's the action that's important, I think). -dave /*=== VegGuide.Org Your guide to all that's veg. ===*/
RE: Module naming advice
My only quibble is that alias is 'less cumbersome' than aliased---sadly already used... --hsm p.s. nice idea!! -Original Message- From: Ovid [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 1:49 PM To: module-authors@perl.org Subject: Module naming advice Hi all, I'm about to release Aliased to the CPAN. Yeah, it's a root level name, but it will soon become clear why it needs to be short. SYNOPSIS: use Aliased 'Really::Long::Module::Name'; use Aliased 'Really::Long::Conflicting::Module::Name' as MName; use Aliased 'Another::Silly::Example' import = [qw/foo bar baz/]; # my $name = Really::Long::Module::Name-new; my $name = Name-new; # my $mname = Really::Long::Conflicting::Module::Name-new my $mname = MName-new; # my $wibble = Another::Silly::Example-constructor. my $wibble = Example-constructor; Basically, when you have long package names, it can be cumbersome to retype the package name all the time. This module allows you to skip that if the subroutines are called as methods. It exports a subroutine into your namespace that is the desired alias for the module. Having used something similar in a large system, I found that having this feature became quite addictive. Since this affects compile-time behavior, it seemed more appropriate to think of this as a pragma and have use aliased but I know that some frown on that (of course, Ingy released only and I didn't hear any complaints.) Is Aliased a good name? Is aliased better? Am I overlooking anything? Cheers, Ovid = Silence is Evil http://users.easystreet.com/ovid/philosophy/decency.html Ovid http://www.perlmonks.org/index.pl?node_id=17000 Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/
Re: Module naming advice
On Tue, 2005-01-04 at 12:49 -0800, Ovid wrote: Hi all, I'm about to release Aliased to the CPAN. Yeah, it's a root level name, but it will soon become clear why it needs to be short. [...] I've always felt that this one should have a lowercase name, since it's rather pragma-ish. Are pragmas allowed outside of the core Perl distribution? Maybe it should be submitted as a core pragma, actually. It's a really lightweight beast, and very useful. Would certainly get my vote. -- Bruce J Keeler [EMAIL PROTECTED]
Re: Module naming advice
On Jan 4, 2005, at 2:47 PM, Bruce J Keeler wrote: I've always felt that this one should have a lowercase name, since it's rather pragma-ish. Are pragmas allowed outside of the core Perl distribution? Maybe it should be submitted as a core pragma, actually. It's a really lightweight beast, and very useful. Would certainly get my vote. I agree that it should be lowercased; yes, there are modules on CPAN that look like pragmas (such as only). I personally would prefer, however, that the name tell me that it's doing something more than loading a class; class and module don't do that. Here are some other options: * alias (too close to Aliased?) * nickname * moniker * pseudonym * aka * anonym * handle (not a file handle, though, might be confusing) * label * term * shortcut I kind of like aka, actually. But nickname, moniker, and shortcut are all good, too. Just my $0.02. Regards, David
Re: Module naming advice
aka is cool. I'll throw a few suggestions: * mask * camo * pose * cover * veil * guise But yeah, aka is probly the best bet. On Tue, Jan 04, 2005 at 02:55:08PM -0800, David Wheeler wrote: On Jan 4, 2005, at 2:47 PM, Bruce J Keeler wrote: I've always felt that this one should have a lowercase name, since it's rather pragma-ish. Are pragmas allowed outside of the core Perl distribution? Maybe it should be submitted as a core pragma, actually. It's a really lightweight beast, and very useful. Would certainly get my vote. I agree that it should be lowercased; yes, there are modules on CPAN that look like pragmas (such as only). I personally would prefer, however, that the name tell me that it's doing something more than loading a class; class and module don't do that. Here are some other options: * alias (too close to Aliased?) * nickname * moniker * pseudonym * aka * anonym * handle (not a file handle, though, might be confusing) * label * term * shortcut I kind of like aka, actually. But nickname, moniker, and shortcut are all good, too. Just my $0.02. Regards, David
Re: Module naming advice
David Wheeler wrote: On Jan 4, 2005, at 2:47 PM, Bruce J Keeler wrote: I've always felt that this one should have a lowercase name, since it's rather pragma-ish. Are pragmas allowed outside of the core Perl distribution? Maybe it should be submitted as a core pragma, actually. It's a really lightweight beast, and very useful. Would certainly get my vote. I agree that it should be lowercased; yes, there are modules on CPAN that look like pragmas (such as only). I personally would prefer, however, that the name tell me that it's doing something more than loading a class; class and module don't do that. Here are some other options: * alias (too close to Aliased?) * nickname * moniker * pseudonym * aka * anonym * handle (not a file handle, though, might be confusing) * label * term * shortcut I kind of like aka, actually. But nickname, moniker, and shortcut are all good, too. There is Package::Alias[1]. Does the same thing, but I haven't used it. I like the idea of it being a pragma; 'aka' seems kinda perlish. It'd be nice if this was supported in perl, so it would be possible to alias entire namespaces use aka 'Apache2::Apache::' as 'Apache::'; # ;-) Which would all all modules in the first namespace to be addressed as if they were in the second, including munging %INC so it does the right thing. 1. http://search.cpan.org/dist/Package-Alias/
Re: Module naming advice
# The following was supposedly scribed by # David Wheeler # on Tuesday 04 January 2005 04:55 pm: I agree that it should be lowercased; yes, there are modules on CPAN that look like pragmas (such as only). I personally would prefer, however, that the name tell me that it's doing something more than loading a class snip I kind of like aka, actually. Me too, except for how it reads in the 'use' statement. use aka 'Really::Long::Module::Name'; use aka 'Really::Long::Conflicting::Module::Name' as MName; use aka 'Another::Silly::Example' import = [qw/foo bar baz/]; That looks like 'use' is Also Known As Really::Long::Module::Name, when what we really mean (and therefore want to say) is more like: use Really::Long::Module::Name aka Name; Of course, the 'use' mechanism isn't able to do this at present (that is: pragmas don't even work this way), so maybe one of the other names is in order. 'alias' as an adverb doesn't work in that order either, but works as a verb, which is sort-of where you're stuck unless you build this functionality into the use() function. Of course, alias as a verb isn't in the dictionary, we geeks just read it that way because of the bash function. It any case, it seems that 'alias.pm' might get confused with 'Alias.pm'. Now I'm strapped to come-up with a verb which doesn't sound so nounish. Consulting the resident linguist (aka wife) results in 'dub' (as in 'I dub thee'), so I'll throw that out as a suggestion. use dub 'Really::Long::Module::Name' as 'Name'; That also seems to work well as an alternative to the use function rather than a module or pragma (yeah, perl needs more functions in the core.) dub Long::Name; dub Long::Name as Name; As for the interface, I really like the 'as' part, but the 'import = [qw(stuff)]' seems clunky. Is there a reason that this syntax can't work: use dub 'Long::Name' qw(foo bar baz); use dub 'Long::Name' as 'Name' qw(foo bar baz); --Eric -- Chess is a foolish expedient for making idle people believe they are doing something very clever when they are only wasting their time. --George Bernard Shaw
Re: Module naming advice
--- Eric Wilhelm [EMAIL PROTECTED] wrote: Me too, except for how it reads in the 'use' statement. use aka 'Really::Long::Module::Name'; Yeah, that bugs me too. Still, aka.pm is the name I lean toward. It any case, it seems that 'alias.pm' might get confused with 'Alias.pm'. Which is my problem with 'alias.' Case-insensitive systems will happily load a module with incorrect case (after loading, though, using the name with incorrect case will cause problems). Which module would get loaded? As for the interface, I really like the 'as' part, but the 'import = [qw(stuff)]' seems clunky. Is there a reason that this syntax can't work: use dub 'Long::Name' qw(foo bar baz); use dub 'Long::Name' as 'Name' qw(foo bar baz); That fails because if the real module accepts 'as' in the import list, I have no way to disambiguate things. As a convenience, if you only have a single import item, you can do this: use aka 'Really::Long::Module::Name' import = 'thingy'; Cheers, Ovid = Silence is Evil http://users.easystreet.com/ovid/philosophy/decency.html Ovid http://www.perlmonks.org/index.pl?node_id=17000 Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/
Re: Module naming advice
On Tue, 2005-01-04 at 18:29 -0500, Randy W. Sims wrote: There is Package::Alias[1]. Does the same thing, but I haven't used it. Upon a quick glance, this does a similar thing but via a different mechanism. Ovid's module installs a constant sub into the caller's namespace which returns the long name of the module. All this is really good for is calling class methods. use Aliased 'Long::Module::Name' as 'Name'; # i.e. use constant Name = 'Long::Module::Name'; Name-new(); # Works print $Name::VERSION; # Doesn't work. Package::Alias sounds like it messes with the stash, something like $::{'Name::'} = $::{'Long::Module::Name::'} if I recall the syntax correctly. The downside to this approach is that objects created via an aliased package name will be blessed into the aliased package name rather than the original one, which could confuse things. I like the idea of it being a pragma; 'aka' seems kinda perlish. It'd be nice if this was supported in perl, so it would be possible to alias entire namespaces use aka 'Apache2::Apache::' as 'Apache::'; # ;-) Which would all all modules in the first namespace to be addressed as if they were in the second, including munging %INC so it does the right thing. This is a completely different problem, requiring a different solution. For the record, I still like the name 'aliased', partly because I'm used to it. -- Bruce J Keeler [EMAIL PROTECTED]
Re: Module naming advice
From: Ovid [EMAIL PROTECTED] --- Eric Wilhelm [EMAIL PROTECTED] wrote: Me too, except for how it reads in the 'use' statement. use aka 'Really::Long::Module::Name'; Yeah, that bugs me too. Still, aka.pm is the name I lean toward. Agreed. As for the interface, I really like the 'as' part, but the 'import = [qw(stuff)]' seems clunky. Is there a reason that this syntax can't work: use dub 'Long::Name' qw(foo bar baz); use dub 'Long::Name' as 'Name' qw(foo bar baz); That fails because if the real module accepts 'as' in the import list, I have no way to disambiguate things. As a convenience, if you only have a single import item, you can do this: use aka 'Really::Long::Module::Name' import = 'thingy'; Has anyone ever seen a module with a space in the name? If not we might just as well use use aka 'Really::Long::Module::Name as MName' qw(foo bar baz); Eric Wilhelm [EMAIL PROTECTED] suggested: Now I'm strapped to come-up with a verb which doesn't sound so nounish. Consulting the resident linguist (aka wife) results in 'dub' (as in 'I dub thee'), so I'll throw that out as a suggestion. use dub 'Really::Long::Module::Name' as 'Name'; Sorry, that would not work for me. I found it in the dictionary, but I've never heard/seen it. And I doubt other foreigners did either, may be mistaken. Actually, what about renamed? use renamed 'Really::Long::Module::Name as MName' qw(foo bar baz); Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery
Re: Module naming advice
David Wheeler wrote: I agree that it should be lowercased; yes, there are modules on CPAN that look like pragmas (such as only). I personally would prefer, however, that the name tell me that it's doing something more than loading a class; class and module don't do that. However, this code reads very well: use module 'Foo::Bar' as 'Bar'; use package 'Foo::Bar' as 'Bar'; And this does not read as well (at least, in English): use aka 'Foo::Bar' as 'Bar'; My suggestion; use aliasing to 'Bar', 'Foo::Bar'; With the upside that aliasing also clearly states what the module does. -- Sam Vilain, sam /\T vilain |T net, PGP key ID: 0x05B52F13 (include my PGP key ID in personal replies to avoid spam filtering)
Re: Module naming advice
--- Sam Vilain [EMAIL PROTECTED] wrote: However, this code reads very well: use module 'Foo::Bar' as 'Bar'; use package 'Foo::Bar' as 'Bar'; 'package' is a reserved word, so I won't use that. 'module' is worse than 'class' because 'class' at least let's us know that this pragma is only for OO modules. And this does not read as well (at least, in English): use aka 'Foo::Bar' as 'Bar'; Yeah, I really don't like it. My suggestion; use aliasing to 'Bar', 'Foo::Bar'; With the upside that aliasing also clearly states what the module does. That fails because it makes the common case more difficult: use aliasing Really::Long::Class:Name; # or use aliasing Really::Long::Class:Name, as = CName; However, I do like the name aliasing.pm Anyone else? It's not perfect, but the one that reads the most naturally class, seems to not be favored by people. Cheers, Ovid = Silence is Evil http://users.easystreet.com/ovid/philosophy/decency.html Ovid http://www.perlmonks.org/index.pl?node_id=17000 Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/
Re: Module naming advice
# The following was supposedly scribed by # Jenda Krynicky # on Tuesday 04 January 2005 06:28 pm: Has anyone ever seen a module with a space in the name? If not we might just as well use use aka 'Really::Long::Module::Name as MName' qw(foo bar baz); Right. No, it's not even possible to have a space in a module name, so your suggestion gives Ovid an easy ($new, $old) = split(/\s+as\s+/, $arg); to work-out which as is which. Eric Wilhelm [EMAIL PROTECTED] suggested: 'dub' (as in 'I dub thee'), so I'll throw that out as a suggestion. Sorry, that would not work for me. I found it in the dictionary, but I've never heard/seen it. And I doubt other foreigners did either, may be mistaken. Hmm. Never seen/heard/read anything about knights/knighthood? What about 'dubya'? Have you heard of him? (so-named for his tendency to assign nicknames to members of his cabinet, foreign ministers, etc.) Oh well. Dreams and kittens... --Eric -- Matter will be damaged in direct proportion to its value. --Murphy's Constant
Re: Including a 480K data file with a module
The advantages of having the data on CPAN is that the entire module is self-sufficient and widely mirrored. It makes it much easier to install, and if you have a CPAN distribution on CD or in a local mirror, you have everything you need. The disadvantage is that it takes up 480K on every single CPAN mirror. I'd be more concerned about the updates. Make ::Data subdistro of it, like brian d foy has done with Business::ISBN and Business::ISBN::Data. When the code updates, you don't have to push out half a gig again. Code and data are separate distros. xoxo, Andy -- Andy Lester = [EMAIL PROTECTED] = www.petdance.com = AIM:petdance
Re: Module naming advice
Ovid [EMAIL PROTECTED] writes: [...] That fails because it makes the common case more difficult: use aliasing Really::Long::Class:Name; # or use aliasing Really::Long::Class:Name, as = CName; However, I do like the name aliasing.pm Anyone else? It's not perfect, but the one that reads the most naturally class, seems to not be favored by people. What about something like 'shortname': use shortname Really::Long::Class::Name; use shortname CName = Really::Long::Class::Name; or use shortname CName for Really::Long::Class::Name; It's confusing to have unrelated modules called Alias and aliasing. ScottG.
Re: Including a 480K data file with a module
A private emailer wrote: [...] Even better isn't all this on a USPS server? Whatever tool you use to grab their server database, include it and do that as part of the build process or perhaps offer it as an option , the alternative being to go to the USPS server every time. Three things I don't like about that. First, it gives a single point of failure for the system, as compared to relying on CPAN's large network of mirrors; worse, it would break if USPS's server ever changed the file location or format. Second, if you want to use something like CPAN on CD to install onto a non-Internet connected machine, downloading from an external server will break; you'll have to arrange for that one file to be copied over and installed by hand. Third, if you cache CPAN modules for installation to many machines, this will bypass the cache. Andy Lester [EMAIL PROTECTED] writes: [...] I'd be more concerned about the updates. Make ::Data subdistro of it, like brian d foy has done with Business::ISBN and Business::ISBN::Data. Right, the data is in a new module called Geo::PostalCode::US; Geo::PostalCode is the main module. The code for Geo::PostalCode::US is 26 lines plus some cleverness in Makefile.PL, so I'm not too concerned about seperating code and data for this module. When the code updates, you don't have to push out half a gig again. Just to be clear, it's half a meg; I wouldn't put half a gig onto CPAN. Chris Josephes [EMAIL PROTECTED] writes: [...] Is the data currently encoded in a standard format? How difficult is it for end users and developers to get updated copies of the data. [...] One concern I would have is how dependent would your users be on you to be the primary provider of the data updates? The main Geo::PostalCode module provides easy instructions for generating your own location database from a simple tab-seperated value file. Geo::PostalCode::US is just for easier download and installation. Would updates always be in the form of a re-versioned perl module? Yes. They'd be very infrequent. The data we're using now is from 1999. I'm working on this in response to a user on PerlMonks who had a very difficult time getting Geo::PostalCode installed and set up right on a hosting provider. It's much nicer to be able to install it with the standard perl Makefile.PL; make; make test; make install. ScottG.
aka.pm (was: Module naming advice)
Thanks to everyone for their input. There was quite a bit more discussion than I expected and most who have commented about the module seem rather jazzed by the idea. While the alternate implementation ideas sound interesting, I see no compelling reason to change the interface. In large part this is because I have (with the permission of Rentrak, Inc.), reimplemented their Aliased.pm code that I and many others have been using for a long time. The syntax is quite natural and has stood the test of time in a company that produces enterprise-class code (if you'll forgive the buzzword.) I was going to list the choices for the name and put things up for a vote. However, I've decided that I will simply go with aka.pm (with explanations in the POD for those unfamiliar with the acronym for also known as). I realize that not everyone will be happy with that but I can't please everyone. Instead, I'll settle for the name that is short enough to fit my primary goal and is acceptable enough to programmers that I won't be screamed at too much. In emailing [EMAIL PROTECTED], brian d foy wrote back with some thoughts but didn't seem to have a problem with calling this module a pragma, so I think this is good to go. I'll shoot another email to that list and barring some last minute objection, I hope to have this uploaded tomorrow. Cheers, Ovid = Silence is Evil http://users.easystreet.com/ovid/philosophy/decency.html Ovid http://www.perlmonks.org/index.pl?node_id=17000 Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/