Don Y <[email protected]d> wrote: |----------------------------------------------------------------------------|Yes, but imposing strong typing on languages that *aren't*
|"If you design strongly typed interfaces and keep this |
|in mind, the user can't specify a "wrong" value. |
| |
|E.g., using {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY}|
|to represent day-of-week instead of some other arbitrary data-type |
|(like [0..6] ... or should that be [1..7]??)" |
|----------------------------------------------------------------------------|
Indeed
type Day_Name is (Monday, Tuesday, Wednesday, Thursday,
Friday, Saturday, Sunday);
is in
Ada.Calendar.Formatting
Don Y <[email protected]d> wrote:
E.g., using {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,
SATURDAY} to represent day-of-week instead of some other arbitrary
data-type (like [0..6] ... or should that be [1..7]??)"
Indeed
type Day_Name is (Monday, Tuesday, Wednesday, Thursday,
Friday, Saturday, Sunday);
is in
Ada.Calendar.Formatting
On Wed, 15 Jul 2026 16:23:35 -0000 (UTC), Cóilín Nioclásín Glostéir wrote:
Don Y <[email protected]d> wrote:
E.g., using {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,
SATURDAY} to represent day-of-week instead of some other arbitrary
data-type (like [0..6] ... or should that be [1..7]??)"
Indeed
type Day_Name is (Monday, Tuesday, Wednesday, Thursday,
Friday, Saturday, Sunday);
is in
Ada.Calendar.Formatting
Which one should come first -- Sunday or Monday? (Or even Saturday, in
some parts of the world.)
Seems to me you want a representation that doesn’t presume a
particular starting point for the week.
On 7/15/2026 2:04 PM, Lawrence D’Oliveiro wrote:
On Wed, 15 Jul 2026 16:23:35 -0000 (UTC), Cóilín Nioclásín Glostéir
wrote:
Don Y <[email protected]d> wrote:Which one should come first -- Sunday or Monday? (Or even Saturday,
E.g., using {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,
SATURDAY} to represent day-of-week instead of some other arbitrary
data-type (like [0..6] ... or should that be [1..7]??)"
Indeed
type Day_Name is (Monday, Tuesday, Wednesday, Thursday,
Friday, Saturday, Sunday);
is in
Ada.Calendar.Formatting
in
some parts of the world.)
Exactly. If you want to encode a relationship in the dataset,
then Mon > Sun > Sat > Fri > Thu > Wed > Tue > Mon > Sun ...
(for some notion of ">" and a corresponding notion of "<")
I.e., there is no "start" of "a week" but, rather, an
"ordering of days-of-the-week".
As such, they can't be expected to resolve to "(numeric) values"
as the above relation wouldn't hold, numerically.
Seems to me you want a representation that doesn’t presume a
particular starting point for the week.
Don Y <[email protected]d> writes:
On 7/15/2026 2:04 PM, Lawrence D’Oliveiro wrote:
On Wed, 15 Jul 2026 16:23:35 -0000 (UTC), Cóilín Nioclásín Glostéir >>> wrote:
Don Y <[email protected]d> wrote:Which one should come first -- Sunday or Monday? (Or even Saturday,
E.g., using {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,
SATURDAY} to represent day-of-week instead of some other arbitrary
data-type (like [0..6] ... or should that be [1..7]??)"
Indeed
type Day_Name is (Monday, Tuesday, Wednesday, Thursday,
Friday, Saturday, Sunday);
is in
Ada.Calendar.Formatting
in
some parts of the world.)
Exactly. If you want to encode a relationship in the dataset,
then Mon > Sun > Sat > Fri > Thu > Wed > Tue > Mon > Sun ...
(for some notion of ">" and a corresponding notion of "<")
I.e., there is no "start" of "a week" but, rather, an
"ordering of days-of-the-week".
As such, they can't be expected to resolve to "(numeric) values"
as the above relation wouldn't hold, numerically.
Yes and no. Questions like "What day is 3 days after Monday?"
are still sensible. On the other hand, "Monday < Tuesday" might
logically be false if it refers to Monday of next week.
"type Day_Number is mod 7;" could be a good fit, but the 'Succ
attribute on enumerated types doesn't wrap around.
Defining Ada.Calendar.Formatting.Day_Name as an enumerated type is very convenient in some ways, but it doesn't *and can't* capture all the
semantics of the days of the week. Any programmer using that package
just has to be aware of that.
And the only operation provided in the package is the Day_of_Week
function.
If you want more functionality, feel free to implement it.
Seems to me you want a representation that doesn’t presume a
particular starting point for the week.
Ideally, yes -- but such a type would be more difficult to use.
Enumerated types are convenient. The choice of which day should be Day_Name'First can only be arbitrary.
Followups to comp.lang.ada; I don't think this has much to do with sci.electronics.
I do not mean to be discourteous and I am sorry that I seemed to be discourteous. I often modify Newsgroups: headers and I do not hide Newsgroups: headers and I also often do not add a redundant "alerting"
about evolving distributions.
If you want to encode a relationship in the dataset,
then Mon > Sun > Sat > Fri > Thu > Wed > Tue > Mon > Sun ...
(for some notion of ">" and a corresponding notion of "<")
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,145 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 293:05:14 |
| Calls: | 14,726 |
| Calls today: | 2 |
| Files: | 186,500 |
| D/L today: |
2,323 files (661M bytes) |
| Messages: | 2,555,791 |
| Posted today: | 4 |