Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.perl.misc > Newsgroup comp.lang.perl.modules

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-26-2012, 06:23 AM
Ivan Shmakov
Guest
 
Posts: n/a
Default naming modules

[Cross-posting to news:comp.lang.perl.misc, as
news:comp.lang.perl.modules doesn't seems too active.]

I've decided to put certain Perl sources to CPAN, but I'm having
trouble inventing some nice names for them.

In particular, I understand that a module name shouldn't be
comprised of just the lowercase letters, so to avoid a potential
name clash with a future Perl pragma. However, is there a
reason to avoid all-lowercase names containing colons (as in,
e. g., common::sense)?

The other question is whether I should use foo::bar or
App::Foo::Bar for the modules related to an application Foo?

And then the third one. I intend to provide a module to compute
multiple SHA digests at the same time (as may be used, e. g., to
generate Debian list files.) The working title is
Digest::SHA::combined, but I wonder if I should use
Digest::SHA::Combined for consistency instead?

TIA.

--
FSF associate member #7257
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 03-26-2012, 07:18 AM
Ben Morrow
Guest
 
Posts: n/a
Default Re: naming modules


Quoth Ivan Shmakov <oneingray@gmail.com>:
> [Cross-posting to news:comp.lang.perl.misc, as
> news:comp.lang.perl.modules doesn't seems too active.]
>
> I've decided to put certain Perl sources to CPAN, but I'm having
> trouble inventing some nice names for them.
>
> In particular, I understand that a module name shouldn't be
> comprised of just the lowercase letters, so to avoid a potential
> name clash with a future Perl pragma. However, is there a
> reason to avoid all-lowercase names containing colons (as in,
> e. g., common::sense)?


I would say that module names with the first part all in lowercase
should be considered reserved: the core has warnings::register, for
instance, and there are version::AlphaBeta and version::Limit on CPAN
which are subclasses of version. OTOH there are quite a lot of modules
with parts after the first in lowercase: LWP::Protocol::*, for instance,
or quite a few of the DBD modules.

common::sense considers itself to be pragmatic in nature, since all it's
doing is turning on various core pragmas.

> The other question is whether I should use foo::bar or
> App::Foo::Bar for the modules related to an application Foo?


App:: is for implementations of applications, not modules which relate
to them. So, for instance, App::Ack implements the guts of ack(1),
rather than being an interface for calling it.

> And then the third one. I intend to provide a module to compute
> multiple SHA digests at the same time (as may be used, e. g., to
> generate Debian list files.) The working title is
> Digest::SHA::combined, but I wonder if I should use
> Digest::SHA::Combined for consistency instead?


Yes. Unless you've got a good reason not to, go with WikiWords with
initial caps and no underscores.

Ben

Reply With Quote
  #3 (permalink)  
Old 03-26-2012, 08:24 AM
Ivan Shmakov
Guest
 
Posts: n/a
Default Re: naming modules

>>>>> Ben Morrow <ben@morrow.me.uk> writes:
>>>>> Quoth Ivan Shmakov <oneingray@gmail.com>:


[...]

>> In particular, I understand that a module name shouldn't be
>> comprised of just the lowercase letters, so to avoid a potential
>> name clash with a future Perl pragma. However, is there a reason to
>> avoid all-lowercase names containing colons (as in, e. g.,
>> common::sense)?


> I would say that module names with the first part all in lowercase
> should be considered reserved: the core has warnings::register, for
> instance, and there are version::AlphaBeta and version::Limit on CPAN
> which are subclasses of version. OTOH there are quite a lot of
> modules with parts after the first in lowercase: LWP::Protocol::*,
> for instance, or quite a few of the DBD modules.


ACK. Thanks!

However, for LWP::Protocol::* it's due to the fact that the URI
schema names are all-lowercase themselves, I suppose.

Unfortunately, even though I dislike mixed-case identifiers, I
have no good reason at hand to avoid it for my Perl code.

> common::sense considers itself to be pragmatic in nature, since all
> it's doing is turning on various core pragmas.


There still is a potential clash should the Perl developers
choose to implement their own common::sense.

>> The other question is whether I should use foo::bar or
>> App::Foo::Bar for the modules related to an application Foo?


> App:: is for implementations of applications, not modules which
> relate to them. So, for instance, App::Ack implements the guts of
> ack(1), rather than being an interface for calling it.


Actually, there's to be the modules that handle a format, or
perhaps a faimily of formats, specific to this particular
application.

If App::MyApp::MyFormat doesn't fit, should it be, e. g.,
Data::MyApp::MyFormat?

>> And then the third one. I intend to provide a module to compute
>> multiple SHA digests at the same time (as may be used, e. g., to
>> generate Debian list files.) The working title is
>> Digest::SHA::combined, but I wonder if I should use
>> Digest::SHA::Combined for consistency instead?


> Yes. Unless you've got a good reason not to, go with WikiWords with
> initial caps and no underscores.


Having C, Shell and Lisp dialects as my "programming
background", I find it quite hard to write in CamelCase.

PS. I'll try to file an RT ticket against Digest::SHA on whether my
module could be added to the distribution.

--
FSF associate member #7257
Reply With Quote
  #4 (permalink)  
Old 03-26-2012, 08:41 AM
Dr.Ruud
Guest
 
Posts: n/a
Default Re: naming modules

On 2012-03-26 10:24, Ivan Shmakov wrote:

> Unfortunately, even though I dislike mixed-case identifiers, I
> have no good reason at hand to avoid it for my Perl code.



PACKAGE PurgeAndArchive;

use strict;
use warnings;

our $VERSION; BEGIN { $VERSION = "0.99" }

my %_cache;

....

1; # satisfy require

--
Ruud
Reply With Quote
  #5 (permalink)  
Old 03-26-2012, 11:35 AM
Ben Morrow
Guest
 
Posts: n/a
Default Re: naming modules


Quoth Ivan Shmakov <oneingray@gmail.com>:
> >>>>> Ben Morrow <ben@morrow.me.uk> writes:
> >>>>> Quoth Ivan Shmakov <oneingray@gmail.com>:

>
> Unfortunately, even though I dislike mixed-case identifiers, I
> have no good reason at hand to avoid it for my Perl code.


I find them quote convenient for package names, even though I dislike
them for function and variable names: they're different enough from the
norm to stand out a bit. <shrug> Maybe I'm just used to it .

> > common::sense considers itself to be pragmatic in nature, since all
> > it's doing is turning on various core pragmas.

>
> There still is a potential clash should the Perl developers
> choose to implement their own common::sense.


Yes, though in practice new core module tend to start on CPAN and then
migrate in, nowadays.

> >> The other question is whether I should use foo::bar or
> >> App::Foo::Bar for the modules related to an application Foo?

>
> > App:: is for implementations of applications, not modules which
> > relate to them. So, for instance, App::Ack implements the guts of
> > ack(1), rather than being an interface for calling it.

>
> Actually, there's to be the modules that handle a format, or
> perhaps a faimily of formats, specific to this particular
> application.
>
> If App::MyApp::MyFormat doesn't fit, should it be, e. g.,
> Data::MyApp::MyFormat?


If there's no more specific top-level that fits, then yes, that sounds
good.

> PS. I'll try to file an RT ticket against Digest::SHA on whether my
> module could be added to the distribution.


I strongly suspect the answer will be 'no', given that Digest::SHA is in
the core and really rather important (it's part of the CPAN toolchain,
for instance). Still, there's no harm in asking.

Ben

Reply With Quote
  #6 (permalink)  
Old 03-26-2012, 12:17 PM
Rainer Weikusat
Guest
 
Posts: n/a
Default Re: naming modules

Ben Morrow <ben@morrow.me.uk> writes:
> Quoth Ivan Shmakov <oneingray@gmail.com>:
>> >>>>> Ben Morrow <ben@morrow.me.uk> writes:
>> >>>>> Quoth Ivan Shmakov <oneingray@gmail.com>:

>>
>> Unfortunately, even though I dislike mixed-case identifiers, I
>> have no good reason at hand to avoid it for my Perl code.

>
> I find them quote convenient for package names, even though I dislike
> them for function and variable names: they're different enough from the
> norm to stand out a bit. <shrug> Maybe I'm just used to it .


I'm usually opposed to camel case because I'm convinced that there's a
good reason that the writing style of the Romans,
justuseasequenceoflettersandletthereaderworryabout breakingitupinordertoreconstructwords,
was abandoned a long time ago. OTOH, the Perl convention is such that
camel case is supposed to be used for module names and sticking to an
existing convention in areas of minor relevance is better than
inventing a new one.

Random piece of information: Reportedly, the mixed-case convention was
originally invented to work around the fact that the keyboard used for
the Xerox Alto lacked an underscore key.
Reply With Quote
  #7 (permalink)  
Old 03-27-2012, 07:47 PM
brian d foy
Guest
 
Posts: n/a
Default Re: naming modules

In article <867gy7rick.fsf@gray.siamics.net>, Ivan Shmakov
<oneingray@gmail.com> wrote:

> [Cross-posting to news:comp.lang.perl.misc, as
> news:comp.lang.perl.modules doesn't seems too active.]
>
> I've decided to put certain Perl sources to CPAN, but I'm having
> trouble inventing some nice names for them.


We have some naming advice at:

https://pause.perl.org/pause/query?A..._namingmodules
Reply With Quote
  #8 (permalink)  
Old 03-28-2012, 01:54 AM
Ivan Shmakov
Guest
 
Posts: n/a
Default Re: naming modules

>>>>> brian d foy <brian.d.foy@gmail.com> writes:
>>>>> Ivan Shmakov <oneingray@gmail.com> wrote:


[...]

>> I've decided to put certain Perl sources to CPAN, but I'm having
>> trouble inventing some nice names for them.


> We have some naming advice at:


> https://pause.perl.org/pause/query?A..._namingmodules


Indeed, I've read it first. But it didn't answer some of my
questions.

--
FSF associate member #7257
Reply With Quote
  #9 (permalink)  
Old 04-09-2012, 07:13 PM
Ivan Shmakov
Guest
 
Posts: n/a
Default Digest::combined 0.1 released

>>>>> Ben Morrow <ben@morrow.me.uk> writes:
>>>>> Quoth Ivan Shmakov <oneingray@gmail.com>:


[...]

>> PS. I'll try to file an RT ticket against Digest::SHA on whether my
>> module could be added to the distribution.


> I strongly suspect the answer will be 'no', given that Digest::SHA is
> in the core and really rather important (it's part of the CPAN
> toolchain, for instance). Still, there's no harm in asking.


This question was briefly discussed on CPAN RT [1] and it was
decided to implement a more generic Digest::combined Perl module
[2], available as a separate distribution, which I've happily
released today [3].

[1] https://rt.cpan.org/Ticket/Display.html?id=76044
[2] http://search.cpan.org/perldoc?Digest::combined
[3] http://search.cpan.org/~onegray/Digest-combined-0.1/

--
FSF associate member #7257
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 06:28 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.