In English, hyphens normally indicate an extra level of reification, where e.g. what is normally a phrase is used in a context that requires a single word: "The miller gave us the run of the mill." vs. "It was a run-of-the-mill event."
As such, examples like "day?of?week" are somewhat infelicitous, as they could go either way depending on context. In fact, I'd be tempted to go with the punctuation-free "weekday", despite spoiling the nice parallelism with "day?of?month", "year", etc. (Perhaps a generic day_of() that takes a keyword argument would be a useful addition?) But that's going off the track (or off-track). Programming statements do not, in general, read like English, and as such, trying to apply English punctuation rules will at best yield ambiguous results. On Sat, Apr 10, 2010 at 5:25 PM, Damian Conway <dam...@conway.org> wrote: > 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 > -- Mark J. Reed <markjr...@gmail.com>