Raku / old-design-docs

Raku language design documents
https://design.raku.org/
Artistic License 2.0
124 stars 36 forks source link

Poor man's enum in spec about timezone #31

Open masak opened 11 years ago

masak commented 11 years ago
<masak> "C<:timezone> is a callable object that takes a C<DateTime> to convert and a C<Bool> that specifies the 
        direction of the conversion: to UTC if true, from UTC if false."
<masak> two things. first: huh?

I actually read this completely wrong the first time. I thought it said that the object should be both a callable and a Bool at the same time. But no; it says that the callable expects two positional parameters.

<masak> second: does this feel like a poor man's enum to someone else?
<masak> the C<Bool> thing.
<moritz> we already have a fitting enum, no?
<moritz> nr: say 'a' cmp 'b'
<p6eval> rakudo 87ad7c, niecza v24-26-g713c785: OUTPUT«Increase␤»
<masak> moritz: no, Increase is not fitting, because this enum is meant to convey "from UTC" or "to UTC", ether of 
        which may be either increasing or decreasing depending on which side of Greenwich you happen to be.

Still, an enumeration should be easy enough to create for this. Its two values could be called fromUTC and toUTC.