develooper Front page | perl.perl6.language | Postings from April 2010

Re: underscores vs hyphens (was Re: A new era for Temporal)

Thread Previous | Thread Next
From:
Damian Conway
Date:
April 10, 2010 14:25
Subject:
Re: underscores vs hyphens (was Re: A new era for Temporal)
Message ID:
y2h832f158a1004101425i3d2b5965y4798d006c0debf5c@mail.gmail.com
Personally, I'd prefer to see the English conventions carried over to
the use of general use of hyphen and underscore in identifiers in
the core (and everywhere else).

By that, I mean that, in English, the hyphen is notionally a
"higher precedence" word-separator than the space
(or than its intra-identifier stand-in: the underscore).

For example: there's an important difference between:

    initiate_main-sequence_detonator_phase()

and:

    initiate_main_sequence-detonator_phase()

The former initiates the detonator phase for the main sequence;
the latter initiates the main phase of the sequence detonator.

More simply, there's a difference between:

     $obj1.set_difference($obj2);

and:

     $obj1.set-difference($obj2);

The first is setting a difference; the second is computing a difference-of-sets.

The rule I intend to use and recommend when employing this new
identifier character in multiword names is that you should place an
underscore between "ordinary unrelated" words, and a hyphen only
between a word and some modifier that applies specifically to that word.

Which, if applied to Temporal, would lead to:

    my $now = DateTime.from_epoch(time);

    The C<day> method also has the synonym C<day-of-month>.

    (These are also available through the methods C<week-year> and
    C<week-number>, respectively.)

    There's a C<day-of-week> method,

    The C<weekday-of-month> method returns a number 1..5

    The C<day-of-quarter> method returns the day of the quarter.

    The C<day-of-year> method returns the day of the year,

    The method C<whole-second> returns the second truncated to an integer.

    The C<time-zone> method returns the C<DateTime::TimeZone> object

(i.e. only C<.from_epoch()> actually uses underscore).

Oh, and the optional C<:timezone> argument to C<.new()> should probably
become C<:time-zone> for consistency with the C<.time-zone()> method
(or, preferably, we should jut bite the bullet and go with C<timezone>
throughout).

Damian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About