Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #160242
| Subject | Re: No, C is not a simple language |
|---|---|
| Newsgroups | comp.lang.c |
| References | (7 earlier) <87tuo2yqiq.fsf@nosuchdomain.example.com> <i7nfI.33552$2A5.24325@fx45.iad> <2HofI.289439$hcZe.74935@fx46.ams4> <HLyfI.38396$2A5.844@fx45.iad> <s5mt8o$psq$1@dont-email.me> |
| From | Richard Damon <Richard@Damon-Family.org> |
| Message-ID | <NZCfI.32461$2N3.12201@fx33.iad> (permalink) |
| Organization | Forte - www.forteinc.com |
| Date | 2021-04-20 12:06 -0400 |
On 4/20/21 11:50 AM, James Kuyper wrote: > On 4/20/21 7:17 AM, Richard Damon wrote: >> On 4/19/21 7:50 PM, Bart wrote: >>> On 19/04/2021 23:03, Richard Damon wrote: >>>> On 4/19/21 4:21 PM, Keith Thompson wrote: >>>>> Thiago Adams <thiago.adams@gmail.com> writes: > ... >>>> It isn't defined to work, because on some machines it just can't be done >>>> (especially if they are different sizes or to different memory spaces >>>> like a Harvard Machine) >>>> >>> >>> You can always make it work. On any machine where a raw function pointer >>> is very different from an object pointer (say 256 bits vs, 64 bits), >>> then a C compiler can implement such pointers via object pointers. >>> >>> In practice, for every actual function, there is an accompanying 256-bit >>> value, in data memory, containing its address. A 'function pointer' as a >>> C program will see it, is a 64-bit pointer to that 256-bit object. >>> >>> The compiler will take care of the double-dereference needed to call >>> such a function. >>> >>> However cross-language libraries would need to cooperate on such a >>> scheme to pass such function pointers via APIs. >> >> Yes, you can make it work at a cost, perhaps heavy cost, and C tries not >> to make implementation do that sort of heavy cost. >> >> Also, on some machines, like those with a Harvard Architecture, using a >> data pointer can NEVER get you the contents at the function pointer, as >> you need to use different instructions to access the memory contents in >> instruction space than in data space. And the word width might even be >> different too. > > I'm not sure why you think that's relevant. Surely C function pointers > can be implemented on such a machine? If so, then you should be able to > do what he suggests: what is a function pointer as far as C code is > concerned is implemented internally as a data pointer pointing at a > function pointer. Keep in mind that he's responding to a claim that "it > just can't be done", not a claim that "it would be excessively > inconvenient". > Yes, it CAN be done, but the Standard doesn't require an implementation to do so, as the system tools might not implement enough functionality to do so efficiently. The second comment is perhaps irrelevant, but sometimes people WILL cast a function pointer to a char* pointer to get access to the machine linguage of a function, which might just not work.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-17 19:12 +0200
Re: No, C is not a simple language silas poulson <Silas8642@hotmail.co.uk> - 2021-04-17 18:33 -0700
Re: No, C is not a simple language Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-04-18 02:10 +0000
Re: No, C is not a simple language silas poulson <Silas8642@hotmail.co.uk> - 2021-04-17 22:35 -0700
Re: No, C is not a simple language Real Troll <real.troll@trolls.com> - 2021-04-18 17:00 +0100
Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-18 21:52 +0200
Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-18 16:46 +0000
Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-18 20:30 +0200
Re: No, C is not a simple language Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-04-18 12:46 -0700
Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-18 22:53 +0200
Re: No, C is not a simple language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-04-19 04:20 -0700
Re: No, C is not a simple language Thiago Adams <thiago.adams@gmail.com> - 2021-04-19 08:29 -0700
Re: No, C is not a simple language Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-04-19 13:21 -0700
Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-19 18:03 -0400
Re: No, C is not a simple language Bart <bc@freeuk.com> - 2021-04-20 00:50 +0100
Re: No, C is not a simple language David Brown <david.brown@hesbynett.no> - 2021-04-20 08:32 +0200
Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-20 07:17 -0400
Re: No, C is not a simple language David Brown <david.brown@hesbynett.no> - 2021-04-20 14:25 +0200
Re: No, C is not a simple language Bart <bc@freeuk.com> - 2021-04-20 14:09 +0100
Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-20 10:19 -0400
Re: No, C is not a simple language James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-04-20 11:50 -0400
Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-20 12:06 -0400
Re: No, C is not a simple language James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-04-20 19:13 -0400
Re: No, C is not a simple language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-05-11 05:29 -0700
Re: No, C is not a simple language David Brown <david.brown@hesbynett.no> - 2021-05-11 14:37 +0200
Re: No, C is not a simple language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-05-11 05:18 -0700
Re: No, C is not a simple language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-05-11 05:14 -0700
Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-19 07:18 +0000
Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-19 17:15 +0200
Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-20 04:05 +0000
Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-20 18:27 +0200
Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-20 16:41 +0000
Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-20 19:44 +0200
Re: No, C is not a simple language Thiago Adams <thiago.adams@gmail.com> - 2021-04-20 11:04 -0700
Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-20 20:23 +0200
Re: No, C is not a simple language Thiago Adams <thiago.adams@gmail.com> - 2021-04-20 12:22 -0700
Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 19:37 +0000
Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 18:30 +0000
Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-20 20:47 +0200
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 13:29 -0700
Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-21 04:37 +0000
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-21 15:26 -0700
Re: No, C is not a simple language Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-04-22 05:59 -0700
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-22 11:58 -0700
Re: No, C is not a simple language Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-04-23 07:23 -0700
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-24 14:26 -0700
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-24 14:28 -0700
Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-20 14:46 -0400
Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 20:18 +0000
Re: No, C is not a simple language Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-05-11 05:31 -0700
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 13:19 -0700
Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 20:29 +0000
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 13:39 -0700
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 14:29 -0700
Re: No, C is not a simple language Ian Collins <ian-news@hotmail.com> - 2021-04-21 08:56 +1200
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 14:07 -0700
Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-23 12:10 +0200
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 12:37 -0700
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 12:38 -0700
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 12:43 -0700
Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-23 22:38 +0200
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 13:44 -0700
Re: No, C is not a simple language Ian Collins <ian-news@hotmail.com> - 2021-04-24 10:56 +1200
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 16:09 -0700
Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:30 +0000
Re: No, C is not a simple language Ian Collins <ian-news@hotmail.com> - 2021-04-30 21:11 +1200
Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-24 03:51 +0000
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-24 12:48 -0700
Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:24 +0000
Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-26 21:24 +0200
Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-27 07:26 +0000
Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:27 +0000
Re: No, C is not a simple language "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2021-04-20 19:53 +0200
Re: No, C is not a simple language Thiago Adams <thiago.adams@gmail.com> - 2021-04-20 11:04 -0700
Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:02 +0000
Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 09:43 +0000
Re: No, C is not a simple language Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-04-26 03:08 -0700
Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 10:35 +0000
Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 13:08 +0000
Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-26 09:30 -0400
Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 14:22 +0000
Re: No, C is not a simple language scott@slp53.sl.home (Scott Lurndal) - 2021-04-26 18:57 +0000
Re: No, C is not a simple language Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-04-26 06:55 -0700
Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 14:15 +0000
Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-27 04:37 +0000
Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-27 07:22 +0000
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-19 21:42 -0700
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-22 00:26 -0700
Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-28 00:02 -0700
csiph-web