Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #384820
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Partial function types |
| Date | 2024-05-21 23:27 -0700 |
| Organization | None to speak of |
| Message-ID | <87ttiq5pkm.fsf@nosuchdomain.example.com> (permalink) |
| References | (3 earlier) <v2eada$3p6sk$1@raubtier-asyl.eternal-september.org> <v2edbr$3pl2i$1@dont-email.me> <eaa0ef93ca03f744edc4fbcf6e79fc730805cce9.camel@gmail.com> <87v837kinv.fsf@nosuchdomain.example.com> <86zfsiv345.fsf_-_@linuxsc.com> |
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> [I am responding to a post in comp.lang.c++, but the subject is
> C, so the response is directed to comp.lang.c.]
>
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>
>> wij <wyniijj5@gmail.com> writes:
>> [...]
>>
>>> typedef int (*ptr)(); // ptr is pointer to int function
>>> int H(ptr x, ptr y);
>>> int D(ptr x)
>>> {
>>> int Halt_Status = H(x, x);
>>> if (Halt_Status)
>>> HERE: goto HERE;
>>> return Halt_Status;
>>> }
>>>
>>> int main()
>>> {
>>> H(D,D);
>>> return 0;
>>> }
>>>
>>> The code above does not compile:
>>
>> Yes, it does (as you acknowledge in a later post).
>>
>> This:
>> typedef int (*ptr)();
>> defines "ptr" as an alias for a type that can be described in English
>> as "pointer to function returning int". The empty parentheses
>> indicate that the function takes an unspecified but fixed number
>> and type(s) of arguments; this is an old-style declaration. [...]
>>
>> The function H is declared but not defined. [...]
>
>> I'll note that the code (declares and) defines the function D,
>> but never calls it. The address of D is passed to H, but without
>> a definition of H we can't guess what it does with that address.
>
> All good up to this point.
>
>> It's possible to rewrite the code to (a) avoid the use of old-style
>> function declarations [...]
>
> Not without radically altering the code. Because D is passed
> as an argument to H, and because of how H and D are declared,
> the type of (the address of) D has to match the type of D's
> first parameter. It isn't possible to do this in C without
> resorting to a partial function type somewhere (because the
> type of D is infinitely recursive).
What I had in mind, though I didn't take the time to dig into it,
was to define a "generic" pointer-to-function type and use casts
where necessary.
But I don't understand the intended semantics well enough to be sure
of how to rewrite it. (I don't consider this lack of understanding
to be a problem.)
> There are other ways to work around this problem, for example
> involving having a pointer-to-function member in a struct,
> but that would entail changing either the declarations or
> the call of H() with D as an argument, which seems to be
> stretching the bounds of "rewrite the code".
>
>> The code as presented is a valid C *translation unit*, but it
>> is not a valid *program*,
>
> It might be better to say it's a valid partial program, but not
> a complete program.
I don't see how that's better.
>> and it has no behavior.
>
> It doesn't have behavior in the sense that it doesn't do anything.
> It does have behavior in the sense that the C standard prescribes
> a meaning for the declarations and definitions given. I believe
> the C standard uses the term "behavior" in both of those senses.
I believe it does not. N1570 3.4 defines "behavior" as "external
appearance or action". Behavior does not occur until execution time.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-18 16:40 -0500
Re: Can someone please verify the execution trace of this? Richard Damon <richard@damon-family.org> - 2024-05-18 18:33 -0400
Re: Can someone please verify the execution trace of this? Sam <sam@email-scan.com> - 2024-05-18 21:12 -0400
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-18 22:16 -0500
Re: Can someone please verify the execution trace of this? jak <nospam@please.ty> - 2024-05-19 06:24 +0200
Re: Can someone please verify the execution trace of this? Rosario19 <Ros@invalid.invalid> - 2024-05-19 06:25 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-18 23:58 -0500
Re: Can someone please verify the execution trace of this? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-19 20:08 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-19 14:00 -0500
Re: Can someone please verify the execution trace of this? Richard Damon <richard@damon-family.org> - 2024-05-19 15:24 -0400
Re: Can someone please verify the execution trace of this? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-20 03:52 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-19 21:43 -0500
Re: Can someone please verify the execution trace of this? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-20 07:09 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 00:38 -0500
Re: Can someone please verify the execution trace of this? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-20 08:41 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 09:47 -0500
Re: Can someone please verify the execution trace of this? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-20 17:16 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 11:01 -0500
Re: Can someone please verify the execution trace of this? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-20 19:15 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 12:20 -0500
Re: Can someone please verify the execution trace of this? Richard Harnden <richard.nospam@gmail.invalid> - 2024-05-20 19:26 +0100
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 14:09 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 11:35 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 14:15 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:23 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 14:28 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:30 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 14:34 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:35 -0700
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:36 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 14:38 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:42 -0700
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:38 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 14:40 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:44 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 14:48 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:50 -0700
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:52 -0700
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:32 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 14:37 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:41 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 14:45 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 12:47 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 14:53 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 13:04 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 15:10 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 13:19 -0700
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 13:21 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 15:30 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 13:31 -0700
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 13:32 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 15:36 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 13:38 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 15:52 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 14:05 -0700
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 14:09 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 16:27 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 13:48 -0700
Re: Can someone please verify the execution trace of this? "Fred. Zwarts" <F.Zwarts@HetNet.nl> - 2024-05-20 10:10 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 09:51 -0500
Re: Can someone please verify the execution trace of this? Paavo Helde <eesnimi@osa.pri.ee> - 2024-05-20 18:05 +0300
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 10:11 -0500
Re: Can someone please verify the execution trace of this? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-20 17:17 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 11:07 -0500
Re: Can someone please verify the execution trace of this? "Fred. Zwarts" <F.Zwarts@HetNet.nl> - 2024-05-21 00:14 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 17:23 -0500
Re: Can someone please verify the execution trace of this? Sam <sam@email-scan.com> - 2024-05-20 18:59 -0400
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 18:07 -0500
Re: Can someone please verify the execution trace of this? Sam <sam@email-scan.com> - 2024-05-20 19:21 -0400
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 18:27 -0500
Re: Can someone please verify the execution trace of this? Sam <sam@email-scan.com> - 2024-05-21 07:48 -0400
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-21 08:37 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-21 12:03 -0700
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-21 14:21 -0500
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-21 14:39 -0700
Re: Can someone please verify the execution trace of this? Sam <sam@email-scan.com> - 2024-05-21 17:55 -0400
Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 17:09 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-21 15:18 -0700
Re: Can D correctly simulated by H reach its own line 06 and halt? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-21 15:20 -0700
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 17:29 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-21 15:34 -0700
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 18:07 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-21 16:54 -0700
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 19:05 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? Sam <sam@email-scan.com> - 2024-05-21 21:31 -0400
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 20:43 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? Sam <sam@email-scan.com> - 2024-05-21 22:10 -0400
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 21:17 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? Sam <sam@email-scan.com> - 2024-05-21 22:20 -0400
Re: Can D correctly simulated by H reach its own line 06 and halt? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-05-21 21:23 -0700
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 21:22 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 23:03 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? tTh <tth@none.invalid> - 2024-05-22 06:45 +0200
Re: Can D correctly simulated by H reach its own line 06 and halt? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-22 13:47 -0700
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-22 08:53 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? Sam <sam@email-scan.com> - 2024-05-22 13:10 -0400
Re: Can D correctly simulated by H reach its own line 06 and halt? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-22 13:50 -0700
Re: Can D correctly simulated by H reach its own line 06 and halt? Sam <sam@email-scan.com> - 2024-05-22 07:01 -0400
Re: Can D correctly simulated by H reach its own line 06 and halt? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-22 13:50 +0200
Re: Can someone please verify the execution trace of this? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-20 21:00 -0700
Can D simulated by any H possibly reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-20 23:22 -0500
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 22:58 -0500
Re: Can someone please verify the execution trace of this? "Fred. Zwarts" <F.Zwarts@HetNet.nl> - 2024-05-21 09:39 +0200
Re: Can someone please verify the execution trace of this? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-21 09:55 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-21 08:31 -0500
Re: Can someone please verify the execution trace of this? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-21 15:56 +0200
Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 09:09 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-21 20:01 +0200
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 13:09 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-21 20:13 +0200
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 13:24 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-21 20:39 +0200
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 13:48 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? bart <bc@freeuk.com> - 2024-05-21 22:34 +0100
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 16:56 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? David Brown <david.brown@hesbynett.no> - 2024-05-22 10:54 +0200
D correctly simulated by H remains stuck in recursive simulation olcott <polcott333@gmail.com> - 2024-05-22 10:44 -0500
Re: D correctly simulated by H remains stuck in recursive simulation "Fred. Zwarts" <F.Zwarts@HetNet.nl> - 2024-05-22 18:27 +0200
Re: D correctly simulated by H remains stuck in recursive simulation [good attempt] olcott <polcott333@gmail.com> - 2024-05-22 15:04 -0500
Re: D correctly simulated by H remains stuck in recursive simulation [good attempt] wij <wyniijj5@gmail.com> - 2024-05-23 04:59 +0800
Re: D correctly simulated by H remains stuck in recursive simulation [good attempt] olcott <polcott333@gmail.com> - 2024-05-22 16:26 -0500
Re: D correctly simulated by H remains stuck in recursive simulation olcott <polcott333@gmail.com> - 2024-05-22 16:56 -0500
Re: D correctly simulated by H remains stuck in recursive simulation "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-22 15:36 -0700
Re: D correctly simulated by H remains stuck in recursive simulation olcott <polcott333@gmail.com> - 2024-05-22 17:52 -0500
Re: D correctly simulated by H remains stuck in recursive simulation "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-22 18:33 -0700
Re: Can D correctly simulated by H reach its own line 06 and halt? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-22 06:40 +0200
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 23:46 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-22 18:29 +0200
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-22 08:52 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-22 12:01 +0200
Re: Can D correctly simulated by H reach its own line 06 and halt? olcott <polcott333@gmail.com> - 2024-05-21 23:37 -0500
Re: Can D correctly simulated by H reach its own line 06 and halt? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-22 06:29 +0200
Partial function types Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-05-21 22:15 -0700
Re: Partial function types Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-05-21 23:27 -0700
Re: Can someone please verify the execution trace of this? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2024-05-20 15:14 +0200
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 10:10 -0500
Re: Can someone please verify the execution trace of this? olcott <polcott333@gmail.com> - 2024-05-20 10:13 -0500
csiph-web