Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Damian Conway provides some excellent insight/advice on underscores vs hyphens:

  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
From Perl6 mailing list: http://www.nntp.perl.org/group/perl.perl6.language/2010/04/m...


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: