Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #27276 > unrolled thread
| Started by | "Bill Cunningham" <billcun@suddenlink.net> |
|---|---|
| First post | 2012-10-17 17:16 -0400 |
| Last post | 2012-11-26 23:03 -0800 |
| Articles | 20 on this page of 72 — 17 participants |
Back to article view | Back to comp.lang.c
callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-17 17:16 -0400
Re: callback function John Gordon <gordon@panix.com> - 2012-10-17 21:36 +0000
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-17 17:44 -0400
Re: callback function John Gordon <gordon@panix.com> - 2012-10-17 21:51 +0000
Re: callback function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-18 00:11 +0100
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:37 -0400
Re: callback function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-19 01:16 +0100
Re: callback function Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-10-20 06:48 -0700
Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-18 10:45 +1300
Re: callback function pete <pfiland@mindspring.com> - 2012-10-19 14:49 -0400
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 16:59 -0400
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 17:04 -0400
Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-19 14:14 -0700
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 17:31 -0400
Re: callback function Keith Thompson <kst-u@mib.org> - 2012-10-19 14:54 -0700
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 18:42 -0400
Re: callback function James Kuyper <jameskuyper@verizon.net> - 2012-10-17 17:47 -0400
Re: callback function tom st denis <tom@iahu.ca> - 2012-10-19 04:44 -0700
Re: callback function James Kuyper <jameskuyper@verizon.net> - 2012-10-19 08:24 -0400
Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-17 14:39 -0700
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-17 17:50 -0400
Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-18 11:00 +1300
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:20 -0400
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:24 -0400
Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-18 22:30 -0700
Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-20 11:58 +1300
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 19:27 -0400
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 19:43 -0400
Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-19 21:09 -0700
Re: callback function Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-10-20 06:53 -0700
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-17 19:25 -0400
Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-18 13:34 +1300
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-17 20:41 -0400
Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-18 14:37 +1300
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:17 -0400
Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-20 11:54 +1300
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:54 -0400
Re: callback function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-19 01:23 +0100
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 20:32 -0400
Re: callback function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-19 02:43 +0100
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 16:56 -0400
Re: callback function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-19 22:10 +0100
Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-18 22:30 -0700
Re: callback function Kenneth Brody <kenbrody@spamcop.net> - 2012-10-19 12:37 -0400
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 16:52 -0400
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 18:44 -0400
Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-19 21:09 -0700
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-20 15:01 -0400
Re: callback function Keith Thompson <kst-u@mib.org> - 2012-10-20 12:47 -0700
Re: callback function Les Cargill <lcargill99@comcast.com> - 2012-10-20 14:51 -0500
Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-20 14:39 -0700
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-20 19:06 -0400
Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-20 22:22 -0700
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-21 14:35 -0400
Re: callback function Kenneth Brody <kenbrody@spamcop.net> - 2012-10-22 10:58 -0400
Re: callback function Bill Cunningham <billcun@suddenlink.net> - 2012-10-24 17:28 -0700
Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-21 11:32 +1300
Re: callback function Keith Thompson <kst-u@mib.org> - 2012-10-20 15:51 -0700
Re: callback function Robert Miles <milesrf@Usenet-News.net> - 2012-11-25 22:39 -0600
Re: callback function Keith Thompson <kst-u@mib.org> - 2012-10-17 17:51 -0700
Re: callback function Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-10-18 20:34 +0300
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:15 -0400
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:27 -0400
Re: callback function Keith Thompson <kst-u@mib.org> - 2012-10-18 15:47 -0700
Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:52 -0400
Re: callback function blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2012-10-25 10:01 +0000
Re: callback function Kenneth Brody <kenbrody@spamcop.net> - 2012-10-25 12:44 -0400
Re: callback function blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2012-10-26 12:48 +0000
Re: callback function Robert Miles <milesrf@Usenet-News.net> - 2012-11-25 22:13 -0600
Re: callback function Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-26 03:42 -0800
Re: callback function James Kuyper <jameskuyper@verizon.net> - 2012-11-26 06:59 -0500
Re: callback function Keith Thompson <kst-u@mib.org> - 2012-11-26 23:03 -0800
Page 3 of 4 — ← Prev page 1 2 [3] 4 Next page →
| From | "Bill Cunningham" <billcun@suddenlink.net> |
|---|---|
| Date | 2012-10-19 16:56 -0400 |
| Message-ID | <k5seqa$isk$1@speranza.aioe.org> |
| In reply to | #27331 |
Ben Bacarisse wrote:
> And I am asking why you use the word "then". You seem to think there
> is a connection between the issues of changing objects and pointers to
> const types and these two dereferences. I'm just curious to know what
> you think the connection is.
If I am understanding you right the connection between these two is what
I want to understand.
Bill
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2012-10-19 22:10 +0100 |
| Message-ID | <0.e75c99404a31e2c363cf.20121019221053BST.8762662mn6.fsf@bsb.me.uk> |
| In reply to | #27380 |
"Bill Cunningham" <billcun@suddenlink.net> writes: > Ben Bacarisse wrote: > >> And I am asking why you use the word "then". You seem to think there >> is a connection between the issues of changing objects and pointers to >> const types and these two dereferences. I'm just curious to know what >> you think the connection is. > > If I am understanding you right the connection between these two is what > I want to understand. Well, good luck with that. In the mean time, if you happen to think of an answer to my question, don't hold back! -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Barry Schwarz <schwarzb@dqel.com> |
|---|---|
| Date | 2012-10-18 22:30 -0700 |
| Message-ID | <e4p1889co1qctjdl35ne5fbsmpe9vskgps@4ax.com> |
| In reply to | #27329 |
On Thu, 18 Oct 2012 20:32:13 -0400, "Bill Cunningham" <billcun@suddenlink.net> wrote: >Ben Bacarisse wrote: >> "Bill Cunningham" <billcun@suddenlink.net> writes: >> >>> Ian Collins wrote: >>> >>>> The whole point of the parameters being const qualified is you can't >>>> change values pointed to. >>> >>> Then why >>> >>> return *pa-*pb; >> >> What's the connection with whether or not the pointers are to const- >> qualified types or not? I can't see any connection between Ian's >> remark and your reply. > >There's been some kind of posting mixup here. I asked about dereferencing in >an earlier post and changing the object pointed to. He said that is why >const was used. I am asking then why these dereferences. Because you are not interested in sorting the pointer values. You don't care if pa is >, ==, or < pb. You do want to sort the values the pointers point to. The value pa points to is *pa. Ditto for *pb. You do care if *pa is >, ++, or < *pb. Other than the possibility of overflow, *pa-*pb is a convenient way of determining that relationship and returning the result in a form qsort can use. -- Remove del for email
[toc] | [prev] | [next] | [standalone]
| From | Kenneth Brody <kenbrody@spamcop.net> |
|---|---|
| Date | 2012-10-19 12:37 -0400 |
| Message-ID | <JMudne693991HBzNnZ2dnUVZ_oGdnZ2d@bestweb.net> |
| In reply to | #27335 |
On 10/19/2012 1:30 AM, Barry Schwarz wrote: > On Thu, 18 Oct 2012 20:32:13 -0400, "Bill Cunningham" > <billcun@suddenlink.net> wrote: > >> Ben Bacarisse wrote: >>> "Bill Cunningham" <billcun@suddenlink.net> writes: >>> >>>> Ian Collins wrote: >>>> >>>>> The whole point of the parameters being const qualified is you can't >>>>> change values pointed to. >>>> >>>> Then why >>>> >>>> return *pa-*pb; [...] > Because you are not interested in sorting the pointer values. You > don't care if pa is >, ==, or < pb. > > You do want to sort the values the pointers point to. The value pa > points to is *pa. Ditto for *pb. You do care if *pa is >, ++, or < > *pb. Other than the possibility of overflow, *pa-*pb is a convenient > way of determining that relationship and returning the result in a > form qsort can use. Consider this: You have a bunch of bins, each a different color, full of toys. You want to sort them by the age group for the toys in each. You don't compare "green bin" to "blue bin", but rather you need to compare what's *in* the bins. That's (sort of) the equivalent of dereferencing a pointer -- you don't compare "pa" and "pb", but rather what's "in" them. Yes, it's a lame analogy, but I think it's about the right level of simplicity for the OP. -- Kenneth Brody
[toc] | [prev] | [next] | [standalone]
| From | "Bill Cunningham" <billcun@suddenlink.net> |
|---|---|
| Date | 2012-10-19 16:52 -0400 |
| Message-ID | <k5seis$icm$1@speranza.aioe.org> |
| In reply to | #27369 |
Kenneth Brody wrote:
> On 10/19/2012 1:30 AM, Barry Schwarz wrote:
>> On Thu, 18 Oct 2012 20:32:13 -0400, "Bill Cunningham"
>> <billcun@suddenlink.net> wrote:
>>
>>> Ben Bacarisse wrote:
>>>> "Bill Cunningham" <billcun@suddenlink.net> writes:
>>>>
>>>>> Ian Collins wrote:
>>>>>
>>>>>> The whole point of the parameters being const qualified is you
>>>>>> can't change values pointed to.
>>>>>
>>>>> Then why
>>>>>
>>>>> return *pa-*pb;
> [...]
>> Because you are not interested in sorting the pointer values. You
>> don't care if pa is >, ==, or < pb.
>>
>> You do want to sort the values the pointers point to. The value pa
>> points to is *pa. Ditto for *pb. You do care if *pa is >, ++, or <
>> *pb. Other than the possibility of overflow, *pa-*pb is a convenient
>> way of determining that relationship and returning the result in a
>> form qsort can use.
>
> Consider this:
>
> You have a bunch of bins, each a different color, full of toys. You
> want to sort them by the age group for the toys in each. You don't
> compare "green bin" to "blue bin", but rather you need to compare
> what's *in* the bins. That's (sort of) the equivalent of
> dereferencing a pointer -- you don't compare "pa" and "pb", but
> rather what's "in" them.
> Yes, it's a lame analogy, but I think it's about the right level of
> simplicity for the OP.
That helps Kenneth thanks.
Bill
[toc] | [prev] | [next] | [standalone]
| From | "Bill Cunningham" <billcun@suddenlink.net> |
|---|---|
| Date | 2012-10-19 18:44 -0400 |
| Message-ID | <k5sl4u$re$1@speranza.aioe.org> |
| In reply to | #27278 |
Barry Schwarz wrote:
> On Wed, 17 Oct 2012 17:16:51 -0400, "Bill Cunningham"
> <billcun@suddenlink.net> wrote:
>
>> I have these 3 functions and before I compile I am going to ask
>> about them. This is for qsort. I tried to tackle this once and
>> couldn't get it I think I get it now. I don't like const's. They are
>> a nuisance. You can't directly pass string literals to them you want
>> to change. Maybe that's just the way C is though.
>
> Since changing a string literal is prohibited, you are doomed before
> you start.
[snip]
Then why use const char * ? FWIW IMO they should remove the const qualifier
from the standard. Something isn't just going to change use there's code to
change it. Why use const?
Bill
[toc] | [prev] | [next] | [standalone]
| From | Barry Schwarz <schwarzb@dqel.com> |
|---|---|
| Date | 2012-10-19 21:09 -0700 |
| Message-ID | <6f84885kvafnr4vmb12o1a4o0tgl9u628p@4ax.com> |
| In reply to | #27392 |
On Fri, 19 Oct 2012 18:44:46 -0400, "Bill Cunningham" <billcun@suddenlink.net> wrote: >Barry Schwarz wrote: >> On Wed, 17 Oct 2012 17:16:51 -0400, "Bill Cunningham" >> <billcun@suddenlink.net> wrote: >> >>> I have these 3 functions and before I compile I am going to ask >>> about them. This is for qsort. I tried to tackle this once and >>> couldn't get it I think I get it now. I don't like const's. They are >>> a nuisance. You can't directly pass string literals to them you want >>> to change. Maybe that's just the way C is though. >> >> Since changing a string literal is prohibited, you are doomed before >> you start. > > [snip] > >Then why use const char * ? FWIW IMO they should remove the const qualifier >from the standard. Something isn't just going to change use there's code to >change it. Why use const? Do you really think the standard should be changed because your limited understanding of the language does not provide you an obvious use of the qualifier? -- Remove del for email
[toc] | [prev] | [next] | [standalone]
| From | "Bill Cunningham" <billcun@suddenlink.net> |
|---|---|
| Date | 2012-10-20 15:01 -0400 |
| Message-ID | <k5usd7$s6r$1@speranza.aioe.org> |
| In reply to | #27402 |
Barry Schwarz wrote:
> Do you really think the standard should be changed because your
> limited understanding of the language does not provide you an obvious
> use of the qualifier?
No not if its that useful. It's because of my limited understanding of C
that I make this statement. Can you give me a good example of when const is
good to use. I've never needed it?
Bill
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2012-10-20 12:47 -0700 |
| Message-ID | <lnhappgc3k.fsf@nuthaus.mib.org> |
| In reply to | #27420 |
"Bill Cunningham" <billcun@suddenlink.net> writes:
> Barry Schwarz wrote:
>> Do you really think the standard should be changed because your
>> limited understanding of the language does not provide you an obvious
>> use of the qualifier?
>
> No not if its that useful. It's because of my limited understanding of C
> that I make this statement. Can you give me a good example of when const is
> good to use. I've never needed it?
The "const" keyword really means "read-only". It's used whenever you
want to assert that a given object's value will not be modified, and
you want the compiler to enforce this for you.
For example, if you have a function whose declaration looks like this:
void func(char *s);
and you call it like this:
char s[] = "Hello, world";
func(s);
then it's possible that the call could change the contents of s.
Sometimes, of course, that's exactly what you want -- but sometimes it
isn't.
For example, given the above declaration you can't safely call the
function with a string literal:
func("Hello, world"); /* dangerous! */
because if func attempts to modify the contents of the string, the
program's behavior is undefined (a crash is likely).
On the other hand, adding a "const" keyword to the declaration:
void func(const char *s);
(nearly) guarantees that func will not attempt to modify the contents of
the string whose address you pass to it. (The "const" applies to what s
points to, not to s itself.)
A good example of this is the standard strlen() function, which computes
the length of a string. It's declared as:
size_t strlen(const char *s);
There's no reason for strlen() to want to modify the string, and good
reasons to guarantee that it won't. And it's perfectly safe to call it
with a string literal:
strlen("Hello, world") /* returns 12 */
My own preference is to declare things as "const" unless there's a
specific need to modify them. For example, suppose I have a function
that takes a char* argument that points to a string, and I want to store
the length of the string in a local object so I don't have to recompute
it:
void frobnicate(char *s) {
const size_t len = strlen(s);
/* ... */
}
If I have some particular need to modify the value of len later on,
obviously I'll omit the "const". But if it's going to retain the
same value, I'll add the "const" keyword, so someone reading the
code and seeing a reference to "len" 42 lines farther down doesn't
have to wonder what its value is at that point -- it's the same
value it had when it was initialized.
Anything you can do with "const", you can do without it. If you took
an entire body of working C code (including the standard library) and
removed every occurrence of "const", it would probably continue to
work correctly. But it would then be very easy to introduce errors,
modifying objects that shouldn't be modified; with "const", the
compiler will catch many such programming errors. "const" is a way
of giving the compiler extra information about your code, information
that can help the compiler help you keep the code correct.
(If I were designing a new language from scratch, I'd make "const"
or "read-only" the default for declared objects; you'd need an
extra keyword, perhaps "var", to indicate that an object's value
can be changed. But that wouldn't be C.)
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Les Cargill <lcargill99@comcast.com> |
|---|---|
| Date | 2012-10-20 14:51 -0500 |
| Message-ID | <k5uvc1$3p8$1@dont-email.me> |
| In reply to | #27420 |
Bill Cunningham wrote: > Barry Schwarz wrote: > >> Do you really think the standard should be changed because your >> limited understanding of the language does not provide you an obvious >> use of the qualifier? > > No not if its that useful. It's because of my limited understanding of C > that I make this statement. Can you give me a good example of when const is > good to use. I've never needed it? > > Bill > > One (incomplete) metaphor to use with the const keyword is - it is like opening the write protect tab on a floppy. One philosophy is "everything is const, except when it cannot be." That forces you to think through the mutability of *all* objects, with the aid of diagnostic messages from the compiler. This is tedious. After a while, you'll get the rhythm of it and you can begin to shortcut things. It's a way to "drill" on the subject. The other thing to learn is how to manage 'thing pointed to is const' and 'pointer is const' declarations. -- Les Cargill
[toc] | [prev] | [next] | [standalone]
| From | Barry Schwarz <schwarzb@dqel.com> |
|---|---|
| Date | 2012-10-20 14:39 -0700 |
| Message-ID | <re56889tlmivf62oijj5hdoiiggks1ush4@4ax.com> |
| In reply to | #27420 |
On Sat, 20 Oct 2012 15:01:02 -0400, "Bill Cunningham" <billcun@suddenlink.net> wrote: >Barry Schwarz wrote: > >> Do you really think the standard should be changed because your >> limited understanding of the language does not provide you an obvious >> use of the qualifier? > > No not if its that useful. It's because of my limited understanding of C That's not what you said >>Then why use const char * ? FWIW IMO they should remove the const qualifier >>from the standard. >that I make this statement. Can you give me a good example of when const is >good to use. I've never needed it? No I can't. What is a good example to me might not be a good example to you. But the people who mostly volunteer their time to try to define a usable and useful product have by consensus decided that const has enough merit to justify its inclusion in the standard. I'm willing to bet you have never needed the 22 functions declared in complex.h, at least 3 of the functions declared in ctype.h, the 11 functions declared in fenv.h and the associated pragma, the 4 functions declared in inttypes.h, the 2 functions declared in locale.h, along with several hundred other features of the language. The C standard would be a lot smaller and simpler if they just consulted you before putting in all this useless to you junk. The correct response to your post should have been "It's worth nothing." -- Remove del for email
[toc] | [prev] | [next] | [standalone]
| From | "Bill Cunningham" <billcun@suddenlink.net> |
|---|---|
| Date | 2012-10-20 19:06 -0400 |
| Message-ID | <k5vaph$u55$1@speranza.aioe.org> |
| In reply to | #27429 |
Barry Schwarz wrote:
[snip]
> No I can't. What is a good example to me might not be a good example
> to you. But the people who mostly volunteer their time to try to
> define a usable and useful product have by consensus decided that
> const has enough merit to justify its inclusion in the standard.
>
> I'm willing to bet you have never needed the 22 functions declared in
> complex.h,
No. Never used complex.h
at least 3 of the functions declared in ctype.h,
Bet I have.
the 11
> functions declared in fenv.h
Never heard of fenv.h
and the associated pragma, the 4
> functions declared in inttypes.h,
Sure I have.
the 2 functions declared in
> locale.h,
No I've never use locale.h
along with several hundred other features of the language.
> The C standard would be a lot smaller and simpler if they just
> consulted you before putting in all this useless to you junk.
>
> The correct response to your post should have been "It's worth
> nothing."
I've used stdint.h too.
Bill
[toc] | [prev] | [next] | [standalone]
| From | Barry Schwarz <schwarzb@dqel.com> |
|---|---|
| Date | 2012-10-20 22:22 -0700 |
| Message-ID | <3a17889uhiiqj8disb3iuqsla9oighmnd0@4ax.com> |
| In reply to | #27433 |
On Sat, 20 Oct 2012 19:06:29 -0400, "Bill Cunningham" <billcun@suddenlink.net> wrote: >Barry Schwarz wrote: > >[snip] > >> No I can't. What is a good example to me might not be a good example >> to you. But the people who mostly volunteer their time to try to >> define a usable and useful product have by consensus decided that >> const has enough merit to justify its inclusion in the standard. >> >> I'm willing to bet you have never needed the 22 functions declared in >> complex.h, > >No. Never used complex.h > >at least 3 of the functions declared in ctype.h, > >Bet I have. Would you care to show us the code you wrote that uses iscntrl(), isgraph(), or ispunct()? > the 11 >> functions declared in fenv.h > > Never heard of fenv.h > >and the associated pragma, the 4 >> functions declared in inttypes.h, > > Sure I have. How about the code that use imaxabs(), imaxdiv(), strtoimax(), wcstoimax(), or wcstoumax()? Yes, there are five, I miscounted. >the 2 functions declared in >> locale.h, > >No I've never use locale.h > >along with several hundred other features of the language. >> The C standard would be a lot smaller and simpler if they just >> consulted you before putting in all this useless to you junk. >> >> The correct response to your post should have been "It's worth >> nothing." > > I've used stdint.h too. Since stdint.h doesn't declare any functions so your response is a non-sequitur. -- Remove del for email
[toc] | [prev] | [next] | [standalone]
| From | "Bill Cunningham" <billcun@suddenlink.net> |
|---|---|
| Date | 2012-10-21 14:35 -0400 |
| Message-ID | <k61f8k$kat$1@speranza.aioe.org> |
| In reply to | #27434 |
Barry Schwarz wrote:
> On Sat, 20 Oct 2012 19:06:29 -0400, "Bill Cunningham"
> <billcun@suddenlink.net> wrote:
>
>> Barry Schwarz wrote:
>>
>> [snip]
>>
>>> No I can't. What is a good example to me might not be a good
>>> example to you. But the people who mostly volunteer their time to
>>> try to define a usable and useful product have by consensus decided
>>> that const has enough merit to justify its inclusion in the
>>> standard.
>>>
>>> I'm willing to bet you have never needed the 22 functions declared
>>> in complex.h,
>>
>> No. Never used complex.h
>>
>> at least 3 of the functions declared in ctype.h,
>>
>> Bet I have.
>
> Would you care to show us the code you wrote that uses iscntrl(),
> isgraph(), or ispunct()?
I don't have the code but it was isalph() isnum() and that's all I
remember.
>> the 11
>>> functions declared in fenv.h
>>
>> Never heard of fenv.h
>>
>> and the associated pragma, the 4
>>> functions declared in inttypes.h,
>>
>> Sure I have.
>
> How about the code that use imaxabs(), imaxdiv(), strtoimax(),
> wcstoimax(), or wcstoumax()? Yes, there are five, I miscounted.
Not my code but it involved inmaxdiv(). I've used more than any
functions types like uin64_t or uint32_t. That's why I used stdint.h.
>> the 2 functions declared in
>>> locale.h,
>>
>> No I've never use locale.h
>>
>> along with several hundred other features of the language.
>>> The C standard would be a lot smaller and simpler if they just
>>> consulted you before putting in all this useless to you junk.
>>>
>>> The correct response to your post should have been "It's worth
>>> nothing."
>>
>> I've used stdint.h too.
>
> Since stdint.h doesn't declare any functions so your response is a
> non-sequitur.
[toc] | [prev] | [next] | [standalone]
| From | Kenneth Brody <kenbrody@spamcop.net> |
|---|---|
| Date | 2012-10-22 10:58 -0400 |
| Message-ID | <YMOdnZNKg_y3whjNnZ2dnUVZ_gmdnZ2d@bestweb.net> |
| In reply to | #27434 |
On 10/21/2012 1:22 AM, Barry Schwarz wrote: > On Sat, 20 Oct 2012 19:06:29 -0400, "Bill Cunningham" > <billcun@suddenlink.net> wrote: > >> Barry Schwarz wrote: [...] >>> I'm willing to bet you have never needed the 22 functions declared in >>> complex.h, >> >> No. Never used complex.h >> >> at least 3 of the functions declared in ctype.h, >> >> Bet I have. > > Would you care to show us the code you wrote that uses iscntrl(), > isgraph(), or ispunct()? [...] Well, to be fair, your statement could be interpreted as to betting that he has used no more than 2 of the functions declared in ctype.h, rather than that there are at least 3 that he hasn't used. And, to be fair, in my nearly 30 years of C programming, I don't believe that I have ever had the need for complex.h, iscntrl(), or ispunct(). (Of course, I would never say "I don't need it, therefore it's not useful, and should be removed from the language.) -- Kenneth Brody
[toc] | [prev] | [next] | [standalone]
| From | Bill Cunningham <billcun@suddenlink.net> |
|---|---|
| Date | 2012-10-24 17:28 -0700 |
| Message-ID | <d21d343d-e99c-43e1-9140-780d0548edcd@googlegroups.com> |
| In reply to | #27433 |
On Saturday, October 20, 2012 7:06:27 PM UTC-4, Bill Cunningham wrote: > Barry Schwarz wrote: [snip] > No I can't. What is a good example to me might not be a good example > to you. But the people who mostly volunteer their time to try to > define a usable and useful product have by consensus decided that > const has enough merit to justify its inclusion in the standard. > > I'm willing to bet you have never needed the 22 functions declared in > complex.h, No. Never used complex.h at least 3 of the functions declared in ctype.h, Bet I have. the 11 > functions declared in fenv.h Never heard of fenv.h and the associated pragma, the 4 > functions declared in inttypes.h, Sure I have. the 2 functions declared in > locale.h, No I've never use locale.h along with several hundred other features of the language. > The C standard would be a lot smaller and simpler if they just > consulted you before putting in all this useless to you junk. > > The correct response to your post should have been "It's worth > nothing." I've used stdint.h too. Bill I have not used wchar.h and I don't believe stddef.h either. Or the header that works with variable lists.
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2012-10-21 11:32 +1300 |
| Message-ID | <aegn3qFnpi3U17@mid.individual.net> |
| In reply to | #27420 |
On 10/21/12 08:01, Bill Cunningham wrote:
> Barry Schwarz wrote:
>
>> Do you really think the standard should be changed because your
>> limited understanding of the language does not provide you an obvious
>> use of the qualifier?
>
> No not if its that useful. It's because of my limited understanding of C
> that I make this statement. Can you give me a good example of when const is
> good to use. I've never needed it?
Those of us from an embedded background probably use const more than
others. If something is declared cont, the compiler can place it in
read only memory which is typically more plentiful in embedded systems.
So given
const int stuff[] = { 1,2,3,4,5,6,7};
stuff will end up in ROM. Any attempt to modify it will either fail or
cause a crash. So stuff can only be safely passed to a function with a
const qualified parameter.
If you write
void f( int* p );
f( stuff );
and your compiler doesn't at least emit a warning, dump it.
--
Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2012-10-20 15:51 -0700 |
| Message-ID | <lnd30chi4c.fsf@nuthaus.mib.org> |
| In reply to | #27430 |
Ian Collins <ian-news@hotmail.com> writes:
> On 10/21/12 08:01, Bill Cunningham wrote:
>> Barry Schwarz wrote:
>>
>>> Do you really think the standard should be changed because your
>>> limited understanding of the language does not provide you an obvious
>>> use of the qualifier?
>>
>> No not if its that useful. It's because of my limited
>> understanding of C that I make this statement. Can you give me a good
>> example of when const is good to use. I've never needed it?
>
> Those of us from an embedded background probably use const more than
> others. If something is declared cont, the compiler can place it in
> read only memory which is typically more plentiful in embedded systems.
> So given
>
> const int stuff[] = { 1,2,3,4,5,6,7};
>
> stuff will end up in ROM. Any attempt to modify it will either fail or
> cause a crash. So stuff can only be safely passed to a function with a
> const qualified parameter.
That's true in that case, but not in all cases. For example, this:
const int r = rand();
is perfectly legal, but r can't be placed in ROM.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Robert Miles <milesrf@Usenet-News.net> |
|---|---|
| Date | 2012-11-25 22:39 -0600 |
| Message-ID | <50b2f36d$0$9772$882e7ee2@usenet-news.net> |
| In reply to | #27392 |
On 10/19/2012 5:44 PM, Bill Cunningham wrote: > Barry Schwarz wrote: >> On Wed, 17 Oct 2012 17:16:51 -0400, "Bill Cunningham" >> <billcun@suddenlink.net> wrote: >> >>> I have these 3 functions and before I compile I am going to ask >>> about them. This is for qsort. I tried to tackle this once and >>> couldn't get it I think I get it now. I don't like const's. They are >>> a nuisance. You can't directly pass string literals to them you want >>> to change. Maybe that's just the way C is though. >> >> Since changing a string literal is prohibited, you are doomed before >> you start. > > [snip] > > Then why use const char * ? FWIW IMO they should remove the const qualifier > from the standard. Something isn't just going to change use there's code to > change it. Why use const? > > Bill Correct C code will not try to change it. Do you want to remove the ability of the C compiler to find and report incorrect C code that does try to change it?
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2012-10-17 17:51 -0700 |
| Message-ID | <ln6268k3fi.fsf@nuthaus.mib.org> |
| In reply to | #27276 |
"Bill Cunningham" <billcun@suddenlink.net> writes:
> I have these 3 functions and before I compile I am going to ask about
> them.
[...]
You're posting code that you haven't even tried to compile?
Please don't waste our time.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
Page 3 of 4 — ← Prev page 1 2 [3] 4 Next page →
Back to top | Article view | comp.lang.c
csiph-web