Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #383272

Re: Calculate date of Easter or Good Friday

From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c
Subject Re: Calculate date of Easter or Good Friday
Date 2024-03-03 11:05 -0800
Organization A noiseless patient Spider
Message-ID <86zfvfrv9l.fsf@linuxsc.com> (permalink)
References <urdmac$1d3vr$1@dont-email.me> <urfu0e$1tvc8$2@dont-email.me> <urhq4h$2g5oc$1@dont-email.me> <urihjb$2la3r$1@dont-email.me>

Show all headers | View raw


Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:

[minor editing]

>> On 25/02/2024 18:39, Lew Pitcher wrote:
>>
>>> On Sat, 24 Feb 2024 21:15:56 +0000, Mike Sanders wrote:
>>>
>>>> Calculate the date of Easter Sunday or Good Friday:
>>>>
>>>> https://busybox.neocities.org/notes/is-easter-or-goodfriday.txt
>>>
>>> My suggestions, with respect to your program, would be to
>>> [...]
>>> b) Don't place your calculations /in/ the object initializations.
>>>     Doing so obfuscates the intent of the logic, and makes
>>>     problem determination and resolution difficult.

Minor comment:  normally I am used to the term "logic" to mean
how control structures are used, not simply the order of
otherwise sequential program elements.  However I think I
understand what you mean so let's ignore that question.

> I base my suggestion on the OP's source:
>  int isEasterOrGoodFriday(const struct tm *now, int checkGoodFriday) {
>
>     int Y = now->tm_year + 1900; // correcting the year
>     int a = Y % 19;
>     int b = Y / 100;
>     int c = Y % 100;
>     int d = b / 4;
>     int e = b % 4;
>     int f = (b + 8) / 25;
>     int g = (b - f + 1) / 3;
>     int h = (19 * a + b - d - g + 15) % 30;
>     int i = c / 4;
>     int k = c % 4;
>     int L = (32 + 2 * e + 2 * i - h - k) % 7;
>     int m = (a + 11 * h + 22 * L) / 451;
>     int month = (h + L - 7 * m + 114) / 31;
>     int day = ((h + L - 7 * m + 114) % 31) + 1;
>
>     if (checkGoodFriday) {
> [rest of code elided]
>
> The program code /depends/ on the specific order of
> the declarations: <<Y>> /must/ be declared before <<a>>,
> <<a>> /must/ be declared before <<h>>, etc.
>
> If some good-meaning (or unknowledgable) maintainer decides to
> reorder or consolidate the above declarations, the program
> either fails or gives erroneous results.

If variables are declared separately, without any initializers,
and all assignments are done after all the declarations, then the
assignment statements can be arbitrarily reordered and still get
a compilable program.  If varibles are all declared with an
initializing expression, as above, then any improper reordering
gives a compilation error, due to a variable being undeclared.
It seems to be that separating the declarations and the initial
assignments is more error prone than keeping them together.

> The OP embedded the /logic/ of the program within the declarations.
> That, to me, is /not/ good programming.

I don't understand why you think that.  Can you explain further?

> Hope this helps clarify my earlier remarks.

It does help clarify the what.  I still don't yet understand the
why.

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Calculate date of Easter or Good Friday porkchop@invalid.foo (Mike Sanders) - 2024-02-24 21:15 +0000
  Re: Calculate date of Easter or Good Friday Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-24 22:54 +0000
    Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-24 23:57 +0100
      Re: Calculate date of Easter or Good Friday Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-24 23:02 +0000
        Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-25 02:00 +0100
          Re: Calculate date of Easter or Good Friday Kaz Kylheku <433-929-6894@kylheku.com> - 2024-02-25 02:27 +0000
          Re: Calculate date of Easter or Good Friday Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2024-02-25 16:58 +0000
            Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-25 18:50 +0100
            Re: Calculate date of Easter or Good Friday Dan Purgert <dan@djph.net> - 2024-02-26 12:43 +0000
        Re: Calculate date of Easter or Good Friday Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-02-24 18:00 -0800
        Re: Calculate date of Easter or Good Friday Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2024-02-26 11:24 -0700
          Re: Calculate date of Easter or Good Friday Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-26 23:20 +0000
            Re: Calculate date of Easter or Good Friday scott@slp53.sl.home (Scott Lurndal) - 2024-02-26 23:31 +0000
              Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-27 12:50 +0100
            Re: Calculate date of Easter or Good Friday James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-02-27 05:02 -0500
              Re: Calculate date of Easter or Good Friday Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-27 22:48 +0000
                Re: Calculate date of Easter or Good Friday James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-02-27 19:06 -0500
                Re: Calculate date of Easter or Good Friday Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-28 00:11 +0000
                Re: Calculate date of Easter or Good Friday James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-02-27 19:24 -0500
                Re: Calculate date of Easter or Good Friday Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-28 20:47 +0000
                Re: Calculate date of Easter or Good Friday Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-02-28 14:06 -0800
                Re: Calculate date of Easter or Good Friday Kaz Kylheku <433-929-6894@kylheku.com> - 2024-02-28 22:20 +0000
                Re: Calculate date of Easter or Good Friday James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-02-29 13:21 -0500
              Re: Calculate date of Easter or Good Friday Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-27 22:50 +0000
                Re: Calculate date of Easter or Good Friday James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-02-27 19:41 -0500
                Re: Calculate date of Easter or Good Friday David Brown <david.brown@hesbynett.no> - 2024-02-28 13:13 +0100
    Re: Calculate date of Easter or Good Friday porkchop@invalid.foo (Mike Sanders) - 2024-02-25 01:33 +0000
      Re: Calculate date of Easter or Good Friday Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-25 06:20 +0000
    Re: Calculate date of Easter or Good Friday G <g@nowhere.invalid> - 2024-02-26 09:47 +0000
    Re: Calculate date of Easter or Good Friday Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2024-02-26 11:20 -0700
      Re: Calculate date of Easter or Good Friday David Brown <david.brown@hesbynett.no> - 2024-02-27 10:08 +0100
        Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-27 13:00 +0100
      Re: Calculate date of Easter or Good Friday Michael S <already5chosen@yahoo.com> - 2024-02-27 13:12 +0200
        Re: Calculate date of Easter or Good Friday Michael S <already5chosen@yahoo.com> - 2024-02-27 14:36 +0200
  Re: Calculate date of Easter or Good Friday Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2024-02-25 17:39 +0000
    Re: Calculate date of Easter or Good Friday porkchop@invalid.foo (Mike Sanders) - 2024-02-26 03:12 +0000
      Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-26 05:20 +0100
        Re: Calculate date of Easter or Good Friday porkchop@invalid.foo (Mike Sanders) - 2024-02-26 14:26 +0000
          Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-26 16:31 +0100
          [OT] personal things (was Re: Calculate date of Easter or Good Friday) Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-26 16:43 +0100
        Re: Calculate date of Easter or Good Friday porkchop@invalid.foo (Mike Sanders) - 2024-02-26 14:32 +0000
          [OT] Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-26 17:10 +0100
            Re: [OT] Re: Calculate date of Easter or Good Friday David Brown <david.brown@hesbynett.no> - 2024-02-26 18:26 +0100
    Re: Calculate date of Easter or Good Friday David Brown <david.brown@hesbynett.no> - 2024-02-26 11:45 +0100
      Re: Calculate date of Easter or Good Friday Ben Bacarisse <ben.usenet@bsb.me.uk> - 2024-02-26 13:04 +0000
        Re: Calculate date of Easter or Good Friday David Brown <david.brown@hesbynett.no> - 2024-02-26 15:46 +0100
          Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-26 16:17 +0100
            Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-26 17:15 +0100
      Re: Calculate date of Easter or Good Friday porkchop@invalid.foo (Mike Sanders) - 2024-02-26 14:38 +0000
        Re: Calculate date of Easter or Good Friday scott@slp53.sl.home (Scott Lurndal) - 2024-02-26 16:29 +0000
          Re: Calculate date of Easter or Good Friday porkchop@invalid.foo (Mike Sanders) - 2024-02-26 19:54 +0000
            Re: Calculate date of Easter or Good Friday scott@slp53.sl.home (Scott Lurndal) - 2024-02-26 20:06 +0000
              Re: Calculate date of Easter or Good Friday porkchop@invalid.foo (Mike Sanders) - 2024-02-26 21:18 +0000
              Re: Calculate date of Easter or Good Friday Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-27 00:59 +0000
        Re: Calculate date of Easter or Good Friday David Brown <david.brown@hesbynett.no> - 2024-02-26 18:07 +0100
      Re: Calculate date of Easter or Good Friday Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-02-26 16:09 +0100
      Re: Calculate date of Easter or Good Friday Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2024-02-26 17:26 +0000
        Re: Calculate date of Easter or Good Friday David Brown <david.brown@hesbynett.no> - 2024-02-27 10:17 +0100
        Re: Calculate date of Easter or Good Friday Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-03-03 11:05 -0800
      Re: Calculate date of Easter or Good Friday vallor <vallor@cultnix.org> - 2024-02-27 01:28 +0000
        Re: Calculate date of Easter or Good Friday Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-27 02:25 +0000
        Re: Calculate date of Easter or Good Friday Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-03-03 10:03 -0800
    Re: Calculate date of Easter or Good Friday Ben Bacarisse <ben.usenet@bsb.me.uk> - 2024-02-28 01:54 +0000
      Re: Calculate date of Easter or Good Friday Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-03-03 10:23 -0800

csiph-web