Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #160147 > unrolled thread
| Started by | Manfred <noname@add.invalid> |
|---|---|
| First post | 2021-04-17 19:12 +0200 |
| Last post | 2021-04-28 00:02 -0700 |
| Articles | 20 on this page of 89 — 20 participants |
Back to article view | Back to comp.lang.c
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
Page 2 of 5 — ← Prev page 1 [2] 3 4 5 Next page →
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Date | 2021-04-20 11:50 -0400 |
| Message-ID | <s5mt8o$psq$1@dont-email.me> |
| In reply to | #160237 |
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".
[toc] | [prev] | [next] | [standalone]
| From | Richard Damon <Richard@Damon-Family.org> |
|---|---|
| Date | 2021-04-20 12:06 -0400 |
| Message-ID | <NZCfI.32461$2N3.12201@fx33.iad> |
| In reply to | #160241 |
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.
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Date | 2021-04-20 19:13 -0400 |
| Message-ID | <s5nn61$lnf$1@dont-email.me> |
| In reply to | #160242 |
On 4/20/21 12:06 PM, Richard Damon wrote: > 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. My point is that he was responding to a claim that it couldn't be done, not a claim that it was inconveniently difficult to do. For the claim he was actually responding to, his response was entirely accurate. That there were platforms where it couldn't be done was given as a reason why the standard doesn't require that it be done. The real reason is that there are platforms where it's inconveniently difficult to do.
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Date | 2021-05-11 05:29 -0700 |
| Message-ID | <86zgx1fo7m.fsf@linuxsc.com> |
| In reply to | #160232 |
Bart <bc@freeuk.com> writes: > 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: >>> >>>> [converting between object pointers and function pointers] >>> >>> C does not define the behavior of converting between object >>> pointer types and function pointer types (except for the special >>> case of a null pointer constant). I believe that's been the case >>> since C90. >>> >>> The section of the standard on pointer conversions just omits any >>> mention of conversions between object pointer types and function >>> pointer types. The section on cast operators, however, doesn't >>> say that such a conversion is a constraint violation. I find this >>> odd. (I think we had a long and inconclusive discussion about >>> this a while ago.) >>> >>> It does allow conversions of function pointer types to and from >>> integers, and integers to and from object pointer types, but the >>> results are implementation-defined in most cases. >>> >>> And yes, the rationale is that void* has to be big enough to hold >>> any object pointer value, but function pointers might be bigger >>> than object pointers (more precisely, they might not be >>> convertible without loss of information). >> >> It isn't made a constraint violation because in many cases it does >> work and being able to do it is useful. >> >> 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. This idea isn't practical due to difficulties in managing the needed resource allocation. Furthermore it isn't necessary because there are easy ways around having to do such conversions.
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2021-05-11 14:37 +0200 |
| Message-ID | <s7dtqn$aee$1@dont-email.me> |
| In reply to | #160731 |
On 11/05/2021 14:29, Tim Rentsch wrote: > Bart <bc@freeuk.com> writes: > >> 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: >>>> >>>>> [converting between object pointers and function pointers] >>>> >>>> C does not define the behavior of converting between object >>>> pointer types and function pointer types (except for the special >>>> case of a null pointer constant). I believe that's been the case >>>> since C90. >>>> >>>> The section of the standard on pointer conversions just omits any >>>> mention of conversions between object pointer types and function >>>> pointer types. The section on cast operators, however, doesn't >>>> say that such a conversion is a constraint violation. I find this >>>> odd. (I think we had a long and inconclusive discussion about >>>> this a while ago.) >>>> >>>> It does allow conversions of function pointer types to and from >>>> integers, and integers to and from object pointer types, but the >>>> results are implementation-defined in most cases. >>>> >>>> And yes, the rationale is that void* has to be big enough to hold >>>> any object pointer value, but function pointers might be bigger >>>> than object pointers (more precisely, they might not be >>>> convertible without loss of information). >>> >>> It isn't made a constraint violation because in many cases it does >>> work and being able to do it is useful. >>> >>> 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. > > This idea isn't practical due to difficulties in managing > the needed resource allocation. > > Furthermore it isn't necessary because there are easy ways around > having to do such conversions. > I am only familiar with one system where function pointers are bigger than other points - the 8-bit AVR microcontrollers, where function points can be 24 bit (for devices with larger flash) while data pointers are 16-bit. When the address of a function is taken, the compiler generates a 24-bit value in memory and uses a 16-bit pointer to that as the function pointer. Calls via a function pointer thus have this extra indirection. Not only is is practical (with no challenges about resource allocations), but it also results in simpler and more efficient code than using 24-bit function pointers directly. It is not the only way to handle such issues, but it is certainly a viable one.
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Date | 2021-05-11 05:18 -0700 |
| Message-ID | <864kf9h3ai.fsf@linuxsc.com> |
| In reply to | #160231 |
Richard Damon <Richard@Damon-Family.org> writes: > On 4/19/21 4:21 PM, Keith Thompson wrote: > >> Thiago Adams <thiago.adams@gmail.com> writes: >> >>> Last week I receive a warning in clang complaining about >>> converting void* to function pointer. Searching for this error I >>> found a explanation that C99 or C11 I don't recall makes this >>> distinction and this conversion is not guaranteed. The solution >>> proposed on stack overflow was storing a dummy function pointer >>> instead of void*, lets say void (PF)(void) and then cast this >>> dummy function pointer to the final type. I decided just ignore >>> the warning in my code. The justification was that void* could >>> have different size than function pointers. >> >> C does not define the behavior of converting between object pointer >> types and function pointer types (except for the special case of a >> null pointer constant). I believe that's been the case since C90. >> >> The section of the standard on pointer conversions just omits any >> mention of conversions between object pointer types and function >> pointer types. The section on cast operators, however, doesn't say >> that such a conversion is a constraint violation. I find this odd. >> (I think we had a long and inconclusive discussion about this a >> while ago.) >> >> It does allow conversions of function pointer types to and from >> integers, and integers to and from object pointer types, but the >> results are implementation-defined in most cases. >> >> And yes, the rationale is that void* has to be big enough to hold >> any object pointer value, but function pointers might be bigger >> than object pointers (more precisely, they might not be convertible >> without loss of information). > > It isn't made a constraint violation because in many cases it does > work and being able to do it is useful. > > 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) Also to give implementations the freedom to reject programs that contain such conversions if they choose to do so, even if there might be an obvious way to implement it.
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Date | 2021-05-11 05:14 -0700 |
| Message-ID | <868s4lh3hu.fsf@linuxsc.com> |
| In reply to | #160230 |
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: > Thiago Adams <thiago.adams@gmail.com> writes: > >> On Monday, April 19, 2021 at 8:20:31 AM UTC-3, Tim Rentsch wrote: >> >>> Keith Thompson <Keith.S.T...@gmail.com> writes: >>> >>>> Manfred <non...@add.invalid> writes: >>>> >>>>> [...] >>> >>> [discussion of opaque types using pointers to structs whose contents >>> are not defined] >>> >>>>> This is nothing new, as I wrote the entire FILE* infrastructure >>>>> works this way. >>>> >>>> Except that you *can* assign objects of type FILE (if you don't >>>> mind undefined behavior). The FILE type is opaque in the sense >>>> that the standard doesn't say what it looks like, but it has to be >>>> an object type. >>> >>> It should be noted that the term "object type" acquired a new >>> meaning in C11. Before C11, the C standard divides types into >>> function types, object types, and incomplete types, so "object >>> type" always meant a complete type and not an incomplete type. >>> Starting in C11, the C standard divides types into function types >>> and object types, with object types further divided into complete >>> object types and incomplete object types. So although it is true >>> that FILE is an object type, starting in C11 that doesn't mean it >>> is necessarily a complete object type. >> >> Last week I receive a warning in clang complaining about >> converting void* to function pointer. >> Searching for this error I found a explanation that C99 or C11 >> I don't recall makes this distinction and this conversion is >> not guaranteed. >> The solution proposed on stack overflow was storing a dummy >> function pointer instead of void*, lets say void (PF)(void) >> and then cast this dummy function pointer to the final type. >> I decided just ignore the warning in my code. >> The justification was that void* could have different size >> than function pointers. > > C does not define the behavior of converting between object > pointer types and function pointer types (except for the special > case of a null pointer constant). I believe that's been the case > since C90. Right, but the C standard doesn't just not define such conversions. There is nothing in the Standard that says they may be done. That is an important distinction. > The section of the standard on pointer conversions just omits any > mention of conversions between object pointer types and function > pointer types. The section on cast operators, however, doesn't > say that such a conversion is a constraint violation. I find this > odd. [...] To me the explanation seems straightforward. The purpose is to allow an implementation to permit such conversions if the implementation so desires, while at the same time providing grounds for rejecting any program that contains such a conversion, if the implementation would rather do that. Kind of a "super undefined behavior", if you see what I mean.
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2021-04-19 07:18 +0000 |
| Message-ID | <s5jarj$1gq6$1@gioia.aioe.org> |
| In reply to | #160198 |
In comp.lang.c++ Manfred <noname@add.invalid> wrote:
> If the struct is opaque, the compiler won't allow you to assign a STRING
> object to another, as a start. In fact it won't allow to perform /any/
> operation on the object, except through the API that you define.
I see no difference between your scheme and mine.
String str1 = String_with_cstr("hello");
String str2 = str1;
// lots of code here
String_free(str1);
String_free(str2); // oops
vs.
String* str1 = String_with_c_str("hello");
String* str2 = str1;
// lots of code here
String_free(str1);
String_free(str2); // oops
> You can still mess up with pointers, but if you want to use C, then you
> have to know better.
My point is that for a beginner it's so much simpler to be able to do:
std::string str1 = "hello";
std::string str2 = str1;
// lots of code here
// no need to even destroy those strings, they'll be destroyed
// automatically
It's also significantly easier to try to guide a beginner to create a small
project like I described.
(Sure, you can start arguing about the efficiency issues of std::string
always making a deep copy whenever it's passed around, but this is just
trying to guide a beginner to do one of his first projects. The efficiency
questions can come up much, much later in the learning process. At this
point the efficiency issues are completely irrelevant.)
[toc] | [prev] | [next] | [standalone]
| From | Manfred <noname@add.invalid> |
|---|---|
| Date | 2021-04-19 17:15 +0200 |
| Message-ID | <s5k6q6$301$1@gioia.aioe.org> |
| In reply to | #160216 |
On 4/19/2021 9:18 AM, Juha Nieminen wrote:
> In comp.lang.c++ Manfred <noname@add.invalid> wrote:
>> If the struct is opaque, the compiler won't allow you to assign a STRING
>> object to another, as a start. In fact it won't allow to perform /any/
>> operation on the object, except through the API that you define.
>
> I see no difference between your scheme and mine.
>
> String str1 = String_with_cstr("hello");
> String str2 = str1;
> // lots of code here
> String_free(str1);
> String_free(str2); // oops
>
> vs.
>
> String* str1 = String_with_c_str("hello");
> String* str2 = str1;
> // lots of code here
> String_free(str1);
> String_free(str2); // oops
I do see a difference there, and it is the tiny little '*' in
> String* str2 = str1;
Which means that you are duplicating a pointer to an object and this
should trigger extra attention wrt object lifetime (and other things for
that matter).
Would you ever write with any lightness:
FILE* f1 = fopen("foo", "r");
FILE* f2 = f1;
// ...
If you want to use C you should get trained to this kind of details.
However, I get that this is probably what you mean by C being not simple
- it is not.
My point is that if you are using C, and you are familiar with it, then
there is a difference between the two designs.
(An example where your design is perfectly OK and widely used:
typedef struct point_t
{
int x;
int y;
} POINT;
POINT p1 = {42, 42};
POINT p2 = p1;
...
But here you make sure that the type is safely (trivially) copyable, a.o.)
>
>> You can still mess up with pointers, but if you want to use C, then you
>> have to know better.
>
> My point is that for a beginner it's so much simpler to be able to do:
>
> std::string str1 = "hello";
> std::string str2 = str1;
> // lots of code here
> // no need to even destroy those strings, they'll be destroyed
> // automatically
>
> It's also significantly easier to try to guide a beginner to create a small
> project like I described.
I'd comment about the term "easy" - you still need to know how RAII and
stuff works here, even if it all happens automatically.
I'd say that the fact that it happens behind the scenes might even make
it harder for a beginner.
The code /looks/ simpler, the mechanics of it is not - C++ is not simple
either.
Considering C++ simple is a major source of mistakes, IMO.
>
> (Sure, you can start arguing about the efficiency issues of std::string
> always making a deep copy whenever it's passed around, but this is just
> trying to guide a beginner to do one of his first projects. The efficiency
> questions can come up much, much later in the learning process. At this
> point the efficiency issues are completely irrelevant.)
>
Agreed, performance has no relevance here.
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2021-04-20 04:05 +0000 |
| Message-ID | <s5lju6$v0c$2@gioia.aioe.org> |
| In reply to | #160222 |
In comp.lang.c++ Manfred <noname@add.invalid> wrote: >> My point is that for a beginner it's so much simpler to be able to do: >> >> std::string str1 = "hello"; >> std::string str2 = str1; >> // lots of code here >> // no need to even destroy those strings, they'll be destroyed >> // automatically >> >> It's also significantly easier to try to guide a beginner to create a small >> project like I described. > > I'd comment about the term "easy" - you still need to know how RAII and > stuff works here, even if it all happens automatically. > I'd say that the fact that it happens behind the scenes might even make > it harder for a beginner. Might make *what* harder for a beginner, exactly?
[toc] | [prev] | [next] | [standalone]
| From | Manfred <noname@add.invalid> |
|---|---|
| Date | 2021-04-20 18:27 +0200 |
| Message-ID | <s5mvd7$14qh$1@gioia.aioe.org> |
| In reply to | #160233 |
On 4/20/2021 6:05 AM, Juha Nieminen wrote: > In comp.lang.c++ Manfred <noname@add.invalid> wrote: >>> My point is that for a beginner it's so much simpler to be able to do: >>> >>> std::string str1 = "hello"; >>> std::string str2 = str1; >>> // lots of code here >>> // no need to even destroy those strings, they'll be destroyed >>> // automatically >>> >>> It's also significantly easier to try to guide a beginner to create a small >>> project like I described. >> >> I'd comment about the term "easy" - you still need to know how RAII and >> stuff works here, even if it all happens automatically. >> I'd say that the fact that it happens behind the scenes might even make >> it harder for a beginner. > > Might make *what* harder for a beginner, exactly? > Anything that happens behind the scenes and the compiler "does it for you" does require knowledge by the programmer about something they don't see and yet they must be aware of and know how it works. And yes, they are intended to (and actually do) make life easier for the programmer /after/ they master their mechanics, but a beginner's mistake related with such hidden features is likely to lead to somewhat shady/obscure bugs - i.e. hard for said beginner. On a different perspective, consider e.g. rvalue refs and "universal" refs (in Meyers' terms) - they make a useful feature, but good luck explaining it to said beginner.
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2021-04-20 16:41 +0000 |
| Message-ID | <s5n07m$1ijc$1@gioia.aioe.org> |
| In reply to | #160243 |
In comp.lang.c++ Manfred <noname@add.invalid> wrote: > Anything that happens behind the scenes and the compiler "does it for > you" does require knowledge by the programmer about something they don't > see and yet they must be aware of and know how it works. > And yes, they are intended to (and actually do) make life easier for the > programmer /after/ they master their mechanics, but a beginner's mistake > related with such hidden features is likely to lead to somewhat > shady/obscure bugs - i.e. hard for said beginner. The problem with C is that anything that requires manual construction and destruction will "contaminate" (can't think of a better word) anything that uses that first thing, with the same requirements. All the way down. If you have this kind of "string" object that requires manual construction and destruction, and you put it as a member of a struct, suddenly that struct "inherits" the same requirement. Use that struct in yet another struct and that, too, will "inherit" the same requirement. Moreover, suppose you have a complex hierarchy of structs as members of other structs, no dynamic memory allocation in sight so far. Then you need to add dynamic memory allocation to one of the structs (that's being used as a member of other structs etc) and suddenly all that code breaks. If there are millions of lines of code using any of those structs that have now "inherited" the need for manual construction and destruction (even though they were never designed for that initially), you'll have to go and modify those millions of lines to follow suit. The complexity can quickly grow exponentially. Not so in C++, if you design your structs/classes correctly. Even if some struct/class very deep in the dependency tree suddenly starts allocating memory dynamically, that doesn't matter. None of the other structs/classes that may be using it as their members need to be touched in any way. The struct/class automatically takes care of its own memory management. You don't need to go through the millions of lines of code to add support. > On a different perspective, consider e.g. rvalue refs and "universal" > refs (in Meyers' terms) - they make a useful feature, but good luck > explaining it to said beginner. I wouldn't teach function and array pointers as a first thing to a beginner. Likewise I wouldn't teach rvalue references as a first thing.
[toc] | [prev] | [next] | [standalone]
| From | jacobnavia <jacob@jacob.remcomp.fr> |
|---|---|
| Date | 2021-04-20 19:44 +0200 |
| Message-ID | <s5n3te$eu3$1@dont-email.me> |
| In reply to | #160244 |
Le 20/04/2021 à 18:41, Juha Nieminen a écrit : > The problem with C is that anything that requires manual construction and > destruction will "contaminate" (can't think of a better word) anything that > uses that first thing, with the same requirements. All the way down. > > If you have this kind of "string" object that requires manual construction > and destruction, and you put it as a member of a struct, suddenly that > struct "inherits" the same requirement. Use that struct in yet another > struct and that, too, will "inherit" the same requirement. No. Just have a constructotr and never free anything. Then link with Boehm's GARBAGE COLLECTOR and be done with it! I have already said this in this thread but people will go on arguing about how difficult is to keep the accounting of memory pieces right. And they are right but refuse to see the right tool for theirpurpose: just use a garbage collector and BE DONE WITH IT. I use an automatic car, no passing of gears. Recently I spoke with a taxi driver... "Don't you get bored passing gears all day?" And he acknowledged: yes, My arm hurts at the end of the day. Maybe you are right, should get an automatic... Use an automatic garbage collector and BE DONE WITH IT. And please, do not start with performance problems, in most string applications the gc is completely transparent.
[toc] | [prev] | [next] | [standalone]
| From | Thiago Adams <thiago.adams@gmail.com> |
|---|---|
| Date | 2021-04-20 11:04 -0700 |
| Message-ID | <0f6783b3-ce54-406e-ac19-83806c1345d1n@googlegroups.com> |
| In reply to | #160245 |
On Tuesday, April 20, 2021 at 2:44:25 PM UTC-3, jacobnavia wrote: > Le 20/04/2021 à 18:41, Juha Nieminen a écrit : > > The problem with C is that anything that requires manual construction and > > destruction will "contaminate" (can't think of a better word) anything that > > uses that first thing, with the same requirements. All the way down. > > > > If you have this kind of "string" object that requires manual construction > > and destruction, and you put it as a member of a struct, suddenly that > > struct "inherits" the same requirement. Use that struct in yet another > > struct and that, too, will "inherit" the same requirement. > No. > > Just have a constructotr and never free anything. Then link with Boehm's > GARBAGE COLLECTOR and be done with it! Then use C# or Go.
[toc] | [prev] | [next] | [standalone]
| From | jacobnavia <jacob@jacob.remcomp.fr> |
|---|---|
| Date | 2021-04-20 20:23 +0200 |
| Message-ID | <s5n66p$vgu$1@dont-email.me> |
| In reply to | #160248 |
Le 20/04/2021 à 20:04, Thiago Adams a écrit : > On Tuesday, April 20, 2021 at 2:44:25 PM UTC-3, jacobnavia wrote: >> Just have a constructotr and never free anything. Then link with Boehm's >> GARBAGE COLLECTOR and be done with it! > > Then use C# or Go. > ???? And why not in C? Why should I abandon C if I use a GC?
[toc] | [prev] | [next] | [standalone]
| From | Thiago Adams <thiago.adams@gmail.com> |
|---|---|
| Date | 2021-04-20 12:22 -0700 |
| Message-ID | <8843b91e-71c4-4240-b22c-3f2b5f149b44n@googlegroups.com> |
| In reply to | #160249 |
On Tuesday, April 20, 2021 at 3:23:33 PM UTC-3, jacobnavia wrote: > Le 20/04/2021 à 20:04, Thiago Adams a écrit : > > On Tuesday, April 20, 2021 at 2:44:25 PM UTC-3, jacobnavia wrote: > > >> Just have a constructotr and never free anything. Then link with Boehm's > >> GARBAGE COLLECTOR and be done with it! > > > > Then use C# or Go. > > > ???? And why not in C? > > Why should I abandon C if I use a GC? When a language decides for GC this opens the door for a huge design simplification. No memory management no pointers etc... So, if you "pay" for GC you can have a much more simple and safe language to use. Everything is inside the same bill. This is what Go language have done.
[toc] | [prev] | [next] | [standalone]
| From | Kaz Kylheku <563-365-8930@kylheku.com> |
|---|---|
| Date | 2021-04-20 19:37 +0000 |
| Message-ID | <20210420123231.918@kylheku.com> |
| In reply to | #160249 |
On 2021-04-20, jacobnavia <jacob@jacob.remcomp.fr> wrote: > Le 20/04/2021 à 20:04, Thiago Adams a écrit : >> On Tuesday, April 20, 2021 at 2:44:25 PM UTC-3, jacobnavia wrote: > >>> Just have a constructotr and never free anything. Then link with Boehm's >>> GARBAGE COLLECTOR and be done with it! >> >> Then use C# or Go. >> > > ???? And why not in C? > > Why should I abandon C if I use a GC? If you use GC in C, you should be focusing on building a clean, well-specified language. If you use GC in C while working on an application, you will actually be building an ad-hoc, ill-specified, bug-ridden language inside that application. https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
[toc] | [prev] | [next] | [standalone]
| From | Kaz Kylheku <563-365-8930@kylheku.com> |
|---|---|
| Date | 2021-04-20 18:30 +0000 |
| Message-ID | <20210420110446.451@kylheku.com> |
| In reply to | #160245 |
On 2021-04-20, jacobnavia <jacob@jacob.remcomp.fr> wrote:
> Le 20/04/2021 à 18:41, Juha Nieminen a écrit :
>> The problem with C is that anything that requires manual construction and
>> destruction will "contaminate" (can't think of a better word) anything that
>> uses that first thing, with the same requirements. All the way down.
>>
>> If you have this kind of "string" object that requires manual construction
>> and destruction, and you put it as a member of a struct, suddenly that
>> struct "inherits" the same requirement. Use that struct in yet another
>> struct and that, too, will "inherit" the same requirement.
>
> No.
>
> Just have a constructotr and never free anything. Then link with Boehm's
> GARBAGE COLLECTOR and be done with it!
You are talking about a different nuance for construction.
In high level, dynamic languages, constructing an object refers to
aggregation.
The ancient function CONS in Lisp may hgave been the first one to use
the construction terminology. If we make a CONS which contains two
strings, there is not construction of those strings going on; they are
already constructed:
(cons "abc" "def")
Juha is probably talking about C++ style construction where if we have
struct foo { string s; foo(); }, the foo::foo constructor has to
call the string::string constructor.
Juha's remarks are true when objects are put together using composition
rather than aggregation.
Because the object B is embedded in another A, and must be initialized,
then the type-B-specific initialization logic for that embedded object
has to be invoked to initialize that B-typed portion of A.
From an abstraction point of view, it's really a shit design. But the
motivation is solid: there are certain efficiencies you can gain when
you compose rather than aggregate objects. You save space by not
allocating separate objects, reducing allocator overhead, and by not
allocating a pointer to navigate from one to the other. By not chasing a
pointer, you reduce pipeline stalls due to dependent loads. Low-level,
systems programming languages benefit from being able to compose
objects.
It's not worth trying to shoehorn that paradigm into a high level
language though. Composition of objects works for simple, low-level code
that has to run fast, and requires only a simple language.
If your idea for building a web browser or word processor includes
anything like this:
class Document {
std::string documentName;
//
}
due to the immense benefit of not having to chase an extra pointer
or allocate an extra object, you must be a supreme moron, and you will
have your lunch eaten by someone working in Javascript or Python.
> I have already said this in this thread but people will go on arguing
> about how difficult is to keep the accounting of memory pieces right.
> And they are right but refuse to see the right tool for theirpurpose:
> just use a garbage collector and BE DONE WITH IT.
That should be: use a language with a garbage collector and be done
with it.
Statistically/probabilistically speaking, given that you have a genuine
reason to be using C, then conditional probability is high that garbage
collection may not be a good fit for the problem.
> I use an automatic car, no passing of gears. Recently I spoke with a
> taxi driver... "Don't you get bored passing gears all day?"
>
> And he acknowledged: yes, My arm hurts at the end of the day. Maybe you
> are right, should get an automatic...
>
> Use an automatic garbage collector and BE DONE WITH IT. And please, do
> not start with performance problems, in most string applications the gc
> is completely transparent.
GC has good performance. But not in a small space. GC needs more memory
than manual freeing in order to perform well.
Most of the speed (in terms of raw throughput) improvements in GC
revolve around the theme of allowing garbage to linger around longer, so
that garbage cycles are either less frequent (e.g. tuning a larger
heap), or smaller in scope (generational GC, visiting just a young
subset of the object graph in most GC passes).
Allowing garbage to stick around longer translates to one thing: larger
memory footprints.
Adding GC to a simple, embedded application in which manual memory
management can be done correctly with relative ease will just bloat
its footprint. If the footprint is kept very tight, GC will run often
which could degrade the performance.
In a single-process system with physical memory, you can just
do collection whenever memory is nearly exausted, which is optimal.
The memory is needed for nothing else.
In a VM system that is using all of its free memory for a buffer/file
cache, any extra slack space for GC encroaches on that cache, even if no
other applications are running. Which they usually are. VM footprints
matter.
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
[toc] | [prev] | [next] | [standalone]
| From | jacobnavia <jacob@jacob.remcomp.fr> |
|---|---|
| Date | 2021-04-20 20:47 +0200 |
| Message-ID | <s5n7k4$9i2$1@dont-email.me> |
| In reply to | #160250 |
Le 20/04/2021 à 20:30, Kaz Kylheku a écrit : > GC has good performance. But not in a small space. GC needs more memory > than manual freeing in order to perform well. > Note: malloc/free do garbage collection by consolidating free memory blocks into larger ones. This essential FACT is being overlooked here. But granted, in small embedded applications with less CPU power and less RAM GC is not the ideal solution and you do the accounting by hand. But in those environments, C++ is anyway out of the question! > Most of the speed (in terms of raw throughput) improvements in GC > revolve around the theme of allowing garbage to linger around longer, so > that garbage cycles are either less frequent (e.g. tuning a larger > heap), or smaller in scope (generational GC, visiting just a young > subset of the object graph in most GC passes). > See above. In small spaces GC is not that good. But we were talking about a TEXT EDITOR for learning C, so that is probably a PC environment where GC SHINES! > Allowing garbage to stick around longer translates to one thing: larger > memory footprints. > Yes. But you can obviate that by calling the GC explicitely from time to time. > Adding GC to a simple, embedded application in which manual memory > management can be done correctly with relative ease will just bloat > its footprint. If the footprint is kept very tight, GC will run often > which could degrade the performance. > Agreed. As I said above, for simple, embedded applications the GC is not the best solution. > In a single-process system with physical memory, you can just > do collection whenever memory is nearly exausted, which is optimal. > The memory is needed for nothing else. > > In a VM system that is using all of its free memory for a buffer/file > cache, any extra slack space for GC encroaches on that cache, even if no > other applications are running. Which they usually are. VM footprints > matter. There are MANY other solutions in C. You can do pool allocating, for instance, allocating all the related strings from a pool that is freed in a single instruction. ETC.
[toc] | [prev] | [next] | [standalone]
| From | "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> |
|---|---|
| Date | 2021-04-20 13:29 -0700 |
| Message-ID | <s5ndjf$6lo$1@gioia.aioe.org> |
| In reply to | #160252 |
On 4/20/2021 11:47 AM, jacobnavia wrote: > Le 20/04/2021 à 20:30, Kaz Kylheku a écrit : >> GC has good performance. But not in a small space. GC needs more memory >> than manual freeing in order to perform well. >> > > Note: malloc/free do garbage collection by consolidating free memory > blocks into larger ones. This essential FACT is being overlooked here. consolidating smaller blocks into larger ones has nothing to do with the conventional notion of a garbage collector. So, you saying that malloc/free do GC is very odd to me, indeed. > > But granted, in small embedded applications with less CPU power and less > RAM GC is not the ideal solution and you do the accounting by hand. But > in those environments, C++ is anyway out of the question! > >> Most of the speed (in terms of raw throughput) improvements in GC >> revolve around the theme of allowing garbage to linger around longer, so >> that garbage cycles are either less frequent (e.g. tuning a larger >> heap), or smaller in scope (generational GC, visiting just a young >> subset of the object graph in most GC passes). >> > > See above. In small spaces GC is not that good. But we were talking > about a TEXT EDITOR for learning C, so that is probably a PC environment > where GC SHINES! > >> Allowing garbage to stick around longer translates to one thing: larger >> memory footprints. >> > > Yes. But you can obviate that by calling the GC explicitely from time to > time. > >> Adding GC to a simple, embedded application in which manual memory >> management can be done correctly with relative ease will just bloat >> its footprint. If the footprint is kept very tight, GC will run often >> which could degrade the performance. >> > > Agreed. As I said above, for simple, embedded applications the GC is not > the best solution. > >> In a single-process system with physical memory, you can just >> do collection whenever memory is nearly exausted, which is optimal. >> The memory is needed for nothing else. >> >> In a VM system that is using all of its free memory for a buffer/file >> cache, any extra slack space for GC encroaches on that cache, even if no >> other applications are running. Which they usually are. VM footprints >> matter. > > There are MANY other solutions in C. You can do pool allocating, for > instance, allocating all the related strings from a pool that is freed > in a single instruction. ETC. > >
[toc] | [prev] | [next] | [standalone]
Page 2 of 5 — ← Prev page 1 [2] 3 4 5 Next page →
Back to top | Article view | comp.lang.c
csiph-web