• Re: Time arithmetic

    From =?UTF-8?B?Q8OzaWzDrW4=?= =?UTF-8?B?IE5pb2Nsw6Fzw61u?= =?UTF-8?B?IEdsb3N0w6lpcg==?=@[email protected] to sci.electronics.design,comp.lang.ada on Wed Jul 15 16:23:35 2026
    From Newsgroup: comp.lang.ada

    Don Y <[email protected]d> wrote: |----------------------------------------------------------------------------| |"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

    Cf. HTTPS://AdaIC.org/resources/add_content/standards/22rm/html/RM-9-6-1.html#I4691

    (S. HTTP://Gloucester.Insomnia247.NL/ fuer Kontaktdaten!)
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Don Y@[email protected] to sci.electronics.design,comp.lang.ada on Wed Jul 15 12:09:19 2026
    From Newsgroup: comp.lang.ada

    On 7/15/2026 9:23 AM, Cóilín Nioclásín Glostéir wrote:
    Don Y <[email protected]d> wrote: |----------------------------------------------------------------------------|
    |"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
    Yes, but imposing strong typing on languages that *aren't*
    strongly typed is a bit of a challenge.

    And, programmers often silently rely on aspects of those encodings
    that aren't actually guaranteed:

    SUNDAY (4)
    MONDAY (92)
    TUESDAY (8)
    WEDNESDAY (0)
    THURSDAY (662)
    FRIDAY (-33)
    SATURDAY (55)

    will likely break code that relies on similarly named manifest
    constants.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@[email protected] to sci.electronics.design,comp.lang.ada on Wed Jul 15 21:04:01 2026
    From Newsgroup: comp.lang.ada

    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.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Don Y@[email protected] to sci.electronics.design,comp.lang.ada on Wed Jul 15 16:49:07 2026
    From Newsgroup: comp.lang.ada

    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:

    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.)

    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.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Keith Thompson@[email protected] to sci.electronics.design,comp.lang.ada on Wed Jul 15 17:13:13 2026
    From Newsgroup: comp.lang.ada

    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:

    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.)

    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.
    --
    Keith Thompson (The_Other_Keith) [email protected]
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Don Y@[email protected] to comp.lang.ada,sci.electronics.design on Wed Jul 15 18:36:54 2026
    From Newsgroup: comp.lang.ada

    On 7/15/2026 5:13 PM, Keith Thompson wrote:
    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:

    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.)

    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.

    It belongs in (and originated in) SED as electronic *products* have
    to deal with time arithmetic (beyond just DoW issues) and have to address
    the needs and expectations of their users (computers tend not to care
    about days-of-week), regardless of implementation language.

    My apologies for not noticing the change in newsgroup distributions
    and REMOVING c.l.a from my followup. Sadly, "Cóilín Nioclásín Glostéir" failed to extend the courtesy of alerting me to his change in distribution.
    If he wants to frolic in c.a.l he of course can freely do so.

    I'll fix my news server to ignore such posts going forward.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From =?UTF-8?B?Q8OzaWzDrW4=?= =?UTF-8?B?IE5pb2Nsw6Fzw61u?==?UTF-8?B?IEdsb3N0w6lpcg==?=@[email protected] to comp.lang.ada,sci.electronics.design on Thu Jul 16 18:27:10 2026
    From Newsgroup: comp.lang.ada

    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.
    (S. HTTP://Gloucester.Insomnia247.NL/ fuer Kontaktdaten!
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Keith Thompson@[email protected] to comp.lang.ada,sci.electronics.design on Thu Jul 16 15:17:52 2026
    From Newsgroup: comp.lang.ada

    Cóilín Nioclásín Glostéir <[email protected]> writes:
    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 change the Newsgroup: header, please do mention it in the body
    of the message. It's not redundant. It's very easy for readers
    to miss the change (I'm not sure all newsreaders even show that
    header by default).
    --
    Keith Thompson (The_Other_Keith) [email protected]
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@[email protected] to sci.electronics.design,comp.lang.ada on Fri Jul 17 04:14:00 2026
    From Newsgroup: comp.lang.ada

    On Wed, 15 Jul 2026 16:49:07 -0700, Don Y wrote:

    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 "<")

    So Mon > Mon?
    --- Synchronet 3.22a-Linux NewsLink 1.2