Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

economizing with functions that do the same thing

0 views
Skip to first unread message

Your Uncle

unread,
Jun 23, 2006, 7:34:00 PM6/23/06
to
About a month ago, Heathfield posted the peudosource for random permuting
from TAOCP. It was all of maybe five lines. You needed to be able to do
two things: be able to get a random number in a range and swap. I
remembered that Dan Pop taught me to write the swap as a macro. With forum
improvements, this became:
#define SWAP(m, n) (tmp = (m), (m) = (n), (n) = tmp)
The random number comes, again with forum improvements:
int rand_in_range(int m, int n)
{
/*seed srand in main */
/* [m, n] is range */
int roll_again_threshold, divisor, result, tmp, offset, num_results;

if (m>n) SWAP(m, n);
offset = m;
num_results = n - m + 1;

if (num_results == 1) {
return m;
}


roll_again_threshold = RAND_MAX - RAND_MAX%num_results;
divisor = roll_again_threshold/num_results;

do {
result = rand();
} while (result >= roll_again_threshold);
result /= divisor;
return offset + result;
}
But then I starting thinking, and that is, of course, where the trouble
began. I posted elsewhere, and I don't think you need much of a language
background to get the gist of it:
Ich habe zwei Funktionen bei file scope erklaert:
void permute_string(char * m, int n);
void permute_int(int * m, int n);
Sie tun das genau Gleiche, allerdings erstere mit chars und letztere mit
ints. Wie werden diese Funktionen Eine?
Basically, how do I take 2 functions that differ only in the type they
operate on, and make them one? I was advised to use:
void permute (void *data, int n, size_t elsize);
that could be called for an array a with
permute(a, sizeof a / sizeof a[0], sizeof a[0]);
Is this going to work? If it isn't, then the idea is mine. If it will then
it's Erich Fruehstueck's. cheers, furunculus

Dann Corbit

unread,
Jun 23, 2006, 7:48:30 PM6/23/06
to
"Your Uncle" <inv...@crippled.net> wrote in message
news:449c7966$0$31542$ec3e...@news.usenetmonster.com...

Use a template. Oh, wait. That's C++.
;-)

The problem with the void pointer thingy is that the function taking the
void pointer will not know what is being passed in. So you are stuck with a
whole bunch of callback functions.

If I understand what you want to do, that is.


Richard Heathfield

unread,
Jun 23, 2006, 8:14:59 PM6/23/06
to
Your Uncle said:

> About a month ago, Heathfield posted the peudosource for random permuting
> from TAOCP.

No, I didn't. I did, however, post some shuffling pseudocode and source,
just a few days ago, which was not taken from TAOCP.

> It was all of maybe five lines. You needed to be able to do
> two things: be able to get a random number in a range and swap.

Yes.

> I
> remembered that Dan Pop taught me to write the swap as a macro.

I find that surprising. I'd have thought Dan Pop would have more sense.

> With
> forum improvements, this became:
> #define SWAP(m, n) (tmp = (m), (m) = (n), (n) = tmp)

That's fine as far as it goes, provided tmp exists and is of the appropriate
type.

> The random number comes, again with forum improvements:
> int rand_in_range(int m, int n)
> {
> /*seed srand in main */
> /* [m, n] is range */
> int roll_again_threshold, divisor, result, tmp, offset, num_results;
>
> if (m>n) SWAP(m, n);
> offset = m;
> num_results = n - m + 1;
>
> if (num_results == 1) {
> return m;
> }
>
>
> roll_again_threshold = RAND_MAX - RAND_MAX%num_results;
> divisor = roll_again_threshold/num_results;
>
> do {
> result = rand();
> } while (result >= roll_again_threshold);
> result /= divisor;
> return offset + result;
> }

That's ghastly, but I can see what you're doing. Presumably this bit works
fine, so let's move on.

> But then I starting thinking, and that is, of course, where the trouble
> began. I posted elsewhere, and I don't think you need much of a language
> background to get the gist of it:
> Ich habe zwei Funktionen bei file scope erklaert:

"I explained two functions with file scope", according to Babelfish.

> void permute_string(char * m, int n);
> void permute_int(int * m, int n);
> Sie tun das genau Gleiche, allerdings erstere mit chars und letztere mit
> ints. Wie werden diese Funktionen Eine?

"They do that exactly resemble, however first with chars and the latters
with ints. How do these functions become one?"

> Basically, how do I take 2 functions that differ only in the type they
> operate on, and make them one? I was advised to use:
> void permute (void *data, int n, size_t elsize);
> that could be called for an array a with
> permute(a, sizeof a / sizeof a[0], sizeof a[0]);
> Is this going to work?

It can be made to work.

> If it isn't, then the idea is mine. If it will
> then it's Erich Fruehstueck's.

I doubt whether it's either your idea or Erich Fruehstueck's.

Incidentally, this isn't really permuting. It's shuffling.

Here is a generic swapping function:

void swap(void *s, void *t, size_t len)
{
unsigned char *u = s;
unsigned char *v = t;
unsigned char tmp;
while(len--)
{
tmp = *u;
*u++ = *v;
*v++ = tmp;
}
}

Here is a generic shuffling function:

void shuffle(void *s, size_t size, size_t len)
{
unsigned char *t = s;
unsigned char *u = s;
size_t i = 0;
size_t r = 0;
for(i = 0; i < len; i++)
{
r = (len - i) * rand() / (RAND_MAX + 1.0);
swap(t + size * i, u + size * r, size);
}
}

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)

Your Uncle

unread,
Jun 23, 2006, 8:24:14 PM6/23/06
to

"Dann Corbit" <dco...@connx.com> wrote in message
news:e7hucf$bkf$1...@nntp.aioe.org...
I'm on thin ice with topicality, so I better condemn this outrageous
suggestion.


> The problem with the void pointer thingy is that the function taking the
> void pointer will not know what is being passed in. So you are stuck with
> a whole bunch of callback functions.

I'm not sure what that means. Maybe we could make a better trivial example:

void print_a_char(char);
void print_an_int(int);
would be definitions and then
print_a_char(char g){ printf(" %c\n", g) }
print_an_int(int g){ printf(" %d\n", g) }
Does that clarify, obfuscate, or just bore? cheers, f


Ian Collins

unread,
Jun 23, 2006, 8:29:27 PM6/23/06
to
Your Uncle wrote:
> "Dann Corbit" <dco...@connx.com> wrote in message
> news:e7hucf$bkf$1...@nntp.aioe.org...
>
>>The problem with the void pointer thingy is that the function taking the
>>void pointer will not know what is being passed in. So you are stuck with
>>a whole bunch of callback functions.
>
> I'm not sure what that means. Maybe we could make a better trivial example:
>
> void print_a_char(char);
> void print_an_int(int);
> would be definitions and then
> print_a_char(char g){ printf(" %c\n", g) }
> print_an_int(int g){ printf(" %d\n", g) }
> Does that clarify, obfuscate, or just bore? cheers, f
>
For a trivial example, the overhead would outweigh the benifit of a
generic function.

For a more complex example, you are stuck with the function not knowing
the type passed in and the compiler not being able to check whether the
passed types are supported.

--
Ian Collins.

Your Uncle

unread,
Jun 23, 2006, 8:44:53 PM6/23/06
to

"Richard Heathfield" <inv...@invalid.invalid> wrote in message
news:hvWdnY1MJaB...@bt.com...

> Your Uncle said:
>
>> About a month ago, Heathfield posted the peudosource for random permuting
>> from TAOCP.
>
> No, I didn't. I did, however, post some shuffling pseudocode and source,
> just a few days ago, which was not taken from TAOCP.
I'm experiencing a wonderful time-dilation while rehabbing an injury. Why
doesn't time drag when you're golfing?

>> It was all of maybe five lines. You needed to be able to do
>> two things: be able to get a random number in a range and swap.
>
> Yes.
>
>> I
>> remembered that Dan Pop taught me to write the swap as a macro.
>
> I find that surprising. I'd have thought Dan Pop would have more sense.

He does, but you have to remember he was talking to me.

>> With
>> forum improvements, this became:
>> #define SWAP(m, n) (tmp = (m), (m) = (n), (n) = tmp)
>
> That's fine as far as it goes, provided tmp exists and is of the
> appropriate
> type.

I'm surprised at how often this has caused me trouble.

If I fail, will a possible reason for this be that it was ill-advised to do
so as opposed to just having two awfully similar functions?


>> If it isn't, then the idea is mine. If it will
>> then it's Erich Fruehstueck's.
>
> I doubt whether it's either your idea or Erich Fruehstueck's.
>
> Incidentally, this isn't really permuting. It's shuffling.
>
> Here is a generic swapping function:
>
> void swap(void *s, void *t, size_t len)
> {
> unsigned char *u = s;
> unsigned char *v = t;
> unsigned char tmp;
> while(len--)
> {
> tmp = *u;
> *u++ = *v;
> *v++ = tmp;
> }
> }

I'll just snipe this wholesale, thank you.

> Here is a generic shuffling function:
>
> void shuffle(void *s, size_t size, size_t len)
> {
> unsigned char *t = s;
> unsigned char *u = s;
> size_t i = 0;
> size_t r = 0;
> for(i = 0; i < len; i++)
> {
> r = (len - i) * rand() / (RAND_MAX + 1.0);
> swap(t + size * i, u + size * r, size);
> }
> }

I'll need to take a closer look at this. Thanks and cheers, f


Richard Heathfield

unread,
Jun 23, 2006, 9:12:42 PM6/23/06
to
Your Uncle said:

>
> "Richard Heathfield" <inv...@invalid.invalid> wrote in message
> news:hvWdnY1MJaB...@bt.com...
>> Your Uncle said:
>>
>>> Is this going to work?
>>
>> It can be made to work.
> If I fail, will a possible reason for this be that it was ill-advised to
> do so as opposed to just having two awfully similar functions?

No. If you fail, it will be because you didn't manage to copy and paste the
code I gave you. :-)

Keith Thompson

unread,
Jun 23, 2006, 9:40:37 PM6/23/06
to
"Your Uncle" <inv...@crippled.net> writes:
[snip]

I've recently seen (or thought I saw) evidence that "Your Uncle",
"Frederick Gotham", and "Joe Smith" are the same person, posting under
different aliases. I recently asked you about this in the "wit's end"
thread, and you never answered.

Are "Your Uncle", "Frederick Gotham", and "Joe Smith" (or any two of
them) in fact the same person? If so, I ask you to pick a single
handle and stick with it. I don't care whether it's your real name or
not; pseudonyms are perfectly acceptable. But if you keep changing
identities, it makes the discussion more difficult to follow, with no
benefit.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.

pete

unread,
Jun 23, 2006, 10:15:04 PM6/23/06
to
Your Uncle wrote:
>
> "Richard Heathfield" <inv...@invalid.invalid> wrote in message
> news:hvWdnY1MJaB...@bt.com...
> > Your Uncle said:

> >> I
> >> remembered that Dan Pop taught me to write the swap as a macro.
> >
> > I find that surprising.
> > I'd have thought Dan Pop would have more sense.
> He does, but you have to remember he was talking to me.
>
> >> With
> >> forum improvements, this became:
> >> #define SWAP(m, n) (tmp = (m), (m) = (n), (n) = tmp)
> >
> > That's fine as far as it goes, provided tmp exists and is of the
> > appropriate
> > type.
> I'm surprised at how often this has caused me trouble.

This is what I use:

#define SWAP(A, B, T) \
((void)(*(T) = *(A), *(A) = *(B), *(B) = *(T)))


--
pete

Michael Mair

unread,
Jun 24, 2006, 6:16:04 AM6/24/06
to
Richard Heathfield schrieb:

> Your Uncle said:
>>I
>>remembered that Dan Pop taught me to write the swap as a macro.
>
> I find that surprising. I'd have thought Dan Pop would have more sense.

It is a matter of context:
http://groups.google.de/group/comp.lang.c/browse_frm/thread/63c5271ccb9149a/
somewhere around message 70 in the tree view; starting at
<2uf41aF...@uni-berlin.de> may suffice.
"Merrill & Michele" was the name the OP went by back then.

Dan Pop IIRC mainly argued against my suggestions of how to
"fix" the macro and pointed out how they fell short -- in
the light of that, the original swap macro was a better
solution for him.
Disclaimer: It is easily possible that I misremember -- I
just tracked down the thread but did not read it.


<snip>


>>#define SWAP(m, n) (tmp = (m), (m) = (n), (n) = tmp)

<snip>


Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.

Your Uncle

unread,
Jun 25, 2006, 5:59:36 PM6/25/06
to

"Richard Heathfield"

> Your Uncle said:
>> "Richard Heathfield"
>>> Your Uncle said:

>>>> Is this going to work?
>>> It can be made to work.
>> If I fail, will a possible reason for this be that it was ill-advised to
>> do so as opposed to just having two awfully similar functions?
> No. If you fail, it will be because you didn't manage to copy and paste
> the
> code I gave you. :-)

It doesn't do me a lick of good to snipe source, germane to what I know,
which I do not understand. You had a generic swap posted, and I frankly
can't quite remember what else, but in response to the what else, I wrote:
/* pruefer.c */
# include "big four.h"
#define MILL (.001)
int fu(int, int);
int main(void)
{# include <stdio.h>
unsigned long g, un_long_dummy, r = s = 0;
int m = 3, n = 17000, mean_less_one, t;
printf("taunt::continue: Y/N");
if (getchar == 'N') break;
mean_less_one = (n - m) / 2;
/* you wonder why Reiner einer
mistrusts syntax here until you reaun_long_dummyze
every time I read a unix jerk my
'\''s and '/''s switch */
/* control */
for (un_long_dummy = 0; un_long_dummy < g; ++ un_long_dummy)
{
t = fu(m, n);
if (t <= mean_less_one) ++ r;
else ++ s;
}
printf("r is %ul while s is %ul\n", r, s);
return 0;
}
int fu(int m, int n)
{
return n;
}
/* end .c begin .h */
/* bigfour.h */
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <time.h>
/* end bigfour.h */
Does this look like C? The question is meant to proceed along two lines:
q1) If I approach my compiler with this, will cl.exe give me
errors/warnings. q2) I conjecture that "bigfour.h" is not included in the c
standard. Given that the possibly non-standard header includes ONLY
standard headers, what can a person say about it? cheers, furunculus


Your Uncle

unread,
Jun 25, 2006, 6:05:52 PM6/25/06
to
/* pruefer.c */
# include "big four.h"
#define MILL (.001)
int fu(int, int);
int main(void)
{
unsigned long g, un_long_dummy, r = s = 0;
int m = 3, n = 17000, mean_less_one, t;
printf("taunt::continue: Y/N");
if (getchar == 'N') break;
mean_less_one = (n - m) / 2;

/* control */


for (un_long_dummy = 0; un_long_dummy < g; ++

un_long_dummy)
{
t = fu(m, n);
if (t <= mean_less_one) ++ r;
else ++ s;
}
printf("r is %ul while s is %ul\n", r, s);
return 0;
}
int fu(int m, int n)
{
return n;
}

/* repost pruefer.c */


Frederick Gotham

unread,
Jun 25, 2006, 7:06:10 PM6/25/06
to
Keith Thompson posted:


> I've recently seen (or thought I saw) evidence that "Your Uncle",
> "Frederick Gotham", and "Joe Smith" are the same person, posting under
> different aliases. I recently asked you about this in the "wit's end"
> thread, and you never answered.
>
> Are "Your Uncle", "Frederick Gotham", and "Joe Smith" (or any two of
> them) in fact the same person? If so, I ask you to pick a single
> handle and stick with it. I don't care whether it's your real name or
> not; pseudonyms are perfectly acceptable. But if you keep changing
> identities, it makes the discussion more difficult to follow, with no
> benefit.


I only post to this newsgroup as "Frederick Gotham".

If you like my posts, then that's brilliant -- I enjoy posting here, and
it's a great hobby for me. If you don't like my posts, or if you suspect I
am posting under other aliases, I don't care to discuss the topic.


--

Frederick Gotham

Your Uncle

unread,
Jun 25, 2006, 7:18:09 PM6/25/06
to

"Keith Thompson"
> "Your Uncle"

> I've recently seen (or thought I saw) evidence that "Your Uncle",
> "Frederick Gotham", and "Joe Smith" are the same person, posting under
> different aliases. I recently asked you about this in the "wit's end"
> thread, and you never answered.
>
> Are "Your Uncle", "Frederick Gotham", and "Joe Smith" (or any two of
> them) in fact the same person? If so, I ask you to pick a single
> handle and stick with it. I don't care whether it's your real name or
> not; pseudonyms are perfectly acceptable. But if you keep changing
> identities, it makes the discussion more difficult to follow, with no
> benefit.

I think this topic could be reasonably addressed in the full-contact
arena: comp.std.c . I believe it addresses the normative underpinnings of
the C programming language. I know it affects the way this island is
perceived. Perception is important.
I am not a sufficiently strong voice to do much right now. It interrupts
my perception that I'm a guy on my back. I am not one lick sarcastic here.
Think of how much clc says "dont toppost" as opposed to "your source is
compost" .
Keith, my newsreaders have a lot more to say about my identity than do I.
gruss, furunculus


pete

unread,
Jun 25, 2006, 8:12:30 PM6/25/06
to
Frederick Gotham wrote:
>
> Keith Thompson posted:

> > Are "Your Uncle", "Frederick Gotham", and "Joe Smith" (or any two of
> > them) in fact the same person?

> I only post to this newsgroup as "Frederick Gotham".

It was Frank Silvermann who's been sock puppeting.

http://groups.google.com/group/comp.lang.c/msg/a7295f3a382f1fbd

--
pete

Keith Thompson

unread,
Jun 25, 2006, 9:32:16 PM6/25/06
to
"Your Uncle" <inv...@crippled.net> writes:
> "Keith Thompson"

All right, then.

"Your Uncle"
"Frederick Gotham"
"Joe Smith"

A recommendation for the killfiles of those who use them.

Kenny McCormack

unread,
Jun 25, 2006, 9:43:59 PM6/25/06
to
In article <lnsllsw...@nuthaus.mib.org>,

Keith Thompson <ks...@mib.org> wrote:
>"Your Uncle" <inv...@crippled.net> writes:
>> "Keith Thompson"
>>> I've recently seen (or thought I saw) evidence that "Your Uncle",
>>> "Frederick Gotham", and "Joe Smith" are the same person, posting under
>>> different aliases. I recently asked you about this in the "wit's end"
>>> thread, and you never answered.
>>>
>>> Are "Your Uncle", "Frederick Gotham", and "Joe Smith" (or any two of
>>> them) in fact the same person? If so, I ask you to pick a single
>>> handle and stick with it. I don't care whether it's your real name or
>>> not; pseudonyms are perfectly acceptable. But if you keep changing
>>> identities, it makes the discussion more difficult to follow, with no
>>> benefit.
>> I think this topic could be reasonably addressed in the full-contact
>> arena: comp.std.c . I believe it addresses the normative underpinnings of
>> the C programming language. I know it affects the way this island is
>> perceived. Perception is important.
>> I am not a sufficiently strong voice to do much right now. It
>> interrupts my perception that I'm a guy on my back. I am not one
>> lick sarcastic here. Think of how much clc says "dont toppost" as
>> opposed to "your source is compost" . Keith, my newsreaders have
>> a lot more to say about my identity than do I. gruss, furunculus
>
>All right, then.
>
>"Your Uncle" "Frederick Gotham"

ITYM, Frank (Not Fred, he used to work for CBS) Silvermann

>"Joe Smith"
>
>A recommendation for the killfiles of those who use them.

You are a man on a mission from God, aren't you?

I have to ask, in all seriousness, what's the percentage/what's the
psychic benefit you get from slamming people you don't understand?

pete

unread,
Jun 25, 2006, 9:44:52 PM6/25/06
to
Keith Thompson wrote:

> "Your Uncle"
> "Frederick Gotham"

ITYM "Frank Silvermann"
http://groups.google.com/group/comp.lang.c/msg/a7295f3a382f1fbd

> "Joe Smith"
>
> A recommendation for the killfiles of those who use them.

--
pete

pete

unread,
Jun 25, 2006, 9:46:51 PM6/25/06
to
Kenny McCormack wrote:

> I have to ask, in all seriousness, what's the percentage/what's the
> psychic benefit you get from slamming people you don't understand?

Slamming people you don't understand,
is your entire purpose on this newsgroup,
isn't it?

--
pete

Frederick Gotham

unread,
Jun 25, 2006, 9:48:08 PM6/25/06
to
Keith Thompson posted:


> All right, then.
>
> "Your Uncle"
> "Frederick Gotham"
> "Joe Smith"
>
> A recommendation for the killfiles of those who use them.


Hey hey hey what's all this about?!

I post under one name and one name only.

If you're THAT certain that I have an affiliation with the others you
have mentioned... then PROVE IT, rather than sabotaging the enjoyable
experience a sincere poster has on this newsgroup.

I expect an apology from you once you have confirmed my innocence --
anything less would portray you as a malicious, inhospitable person.

You make a great contribution to the group, Keith, and I regularly find
your posts interesting -- but your elevated status on this group does not
warrant the malicious behaviour you have displayed.


--

Frederick Gotham

Keith Thompson

unread,
Jun 25, 2006, 9:56:38 PM6/25/06
to

I think you're right. A quick look through the archives doesn't show
any indication that Frederick Gotham is the same person as "Joe Smith"
or "Your Uncle". I just confused the names somehow.

I apologize.

Since I appear to have messed this up, and I'm no longer sure who is
who, I withdraw my recommendation for people's killfiles. Everyone
should, as always, use his or her own judgement.

pete

unread,
Jun 25, 2006, 10:10:06 PM6/25/06
to
Keith Thompson wrote:
>
> pete <pfi...@mindspring.com> writes:
> > Keith Thompson wrote:

> >> "Frederick Gotham"
> >
> > ITYM "Frank Silvermann"

> I think you're right. A quick look through the archives doesn't show


> any indication that Frederick Gotham is the same person as "Joe Smith"
> or "Your Uncle". I just confused the names somehow.

Well you know, Frank starts with an Fr and ends with a k,
just like Frederick.
Silvermann ends with an a followed by two n's,
kind of looks like an m.

;)

--
pete

Your Uncle

unread,
Jun 26, 2006, 1:57:25 AM6/26/06
to

>>"Your Uncle" "Frederick Gotham"
>
> ITYM, Frank (Not Fred, he used to work for CBS) Silvermann
>
>>"Joe Smith"

> "large, jelly-filled donuts"
>>
>>A recommendation for the killfiles from God, aren't you?


>
> I have to ask, in all seriousness, what's the percentage/what's the
> psychic benefit you get from slamming people you don't understand?

I go out to the pub. I come back. Can someone explain to me what killfile
means in the context of the C programming language. By someone, I do not
mean a parochial American. getchar() f


Your Uncle

unread,
Jun 26, 2006, 2:36:55 AM6/26/06
to

"Michael Mair" <Michae...@invalid.invalid> wrote in message
news:4g4hlpF...@individual.net...

> Richard Heathfield schrieb:
>> Your Uncle said:
>>>I
>>>remembered that Dan Pop taught me to write the swap as a macro.
>>
>> I find that surprising. I'd have thought Dan Pop would have more sense.
Where's Dan ?

>
<witz>


> solution for him.
> Disclaimer: It is easily possible that I misremember -- I
> just tracked down the thread but did not read it.
>
>
> <snip>
>>>#define SWAP(m, n) (tmp = (m), (m) = (n), (n) = tmp)
> <snip>

Wir sollten auf Deutsch. Ich bliebe lieber auf "Sie." Bitte informiere
mich wie ich Sie beleidigt habe? Kenneth Ford


Richard Heathfield

unread,
Jun 26, 2006, 3:09:21 AM6/26/06
to
Your Uncle said:

>
> "Richard Heathfield"
>> Your Uncle said:
>>> "Richard Heathfield"
>>>> Your Uncle said:
>
>>>>> Is this going to work?
>>>> It can be made to work.
>>> If I fail, will a possible reason for this be that it was ill-advised to
>>> do so as opposed to just having two awfully similar functions?
>> No. If you fail, it will be because you didn't manage to copy and paste
>> the
>> code I gave you. :-)
> It doesn't do me a lick of good to snipe source, germane to what I know,
> which I do not understand.

Truly.

> You had a generic swap posted

...which, if you do not understand it, you should ask questions about.

> and I frankly
> can't quite remember what else, but in response to the what else, I wrote:
> /* pruefer.c */
> # include "big four.h"

<rather bizarre program snipped>

> /* bigfour.h */
> # include <stdio.h>
> # include <stdlib.h>
> # include <math.h>
> # include <time.h>
> /* end bigfour.h */
> Does this look like C?

The program didn't. The header does (although I prefer not to mask standard
headers in that way, it is certainly legal to do it).

> The question is meant to proceed along two lines:
> q1) If I approach my compiler with this, will cl.exe give me
> errors/warnings.

Yes.

> q2) I conjecture that "bigfour.h" is not included in the c
> standard.

You are correct.

> Given that the possibly non-standard header includes ONLY
> standard headers, what can a person say about it?

That either the comment is not describing the filename accurately, or the
#include directive in your C file is wrong.

Richard Heathfield

unread,
Jun 26, 2006, 3:22:13 AM6/26/06
to
Frederick Gotham said:

<snip>


>
> I expect an apology from you once you have confirmed my innocence --

For the record, he has already done so (elsethread). He got you mixed up
with someone else.


> anything less would portray you as a malicious, inhospitable person.
>
> You make a great contribution to the group, Keith, and I regularly find
> your posts interesting -- but your elevated status on this group does not
> warrant the malicious behaviour you have displayed.

Keith hasn't displayed any malicious behaviour. He's just pointing out a
kook's multiple IDs for the benefit of anyone who hasn't spotted them yet,
and he accidentally caught your name up in the middle of it, for which, as
I say, he has already apologised.

If Keith has an "elevated status" on this group, it is because he is a
helpful, intelligent subscriber who is knowledgeable about the C language.
But he is not perfect. He makes mistakes, as we all do.

Twice to my knowledge, you have over-reacted to being corrected. This time,
you have over-reacted to a case of mistaken identity - with, it must be
said, rather more justification this time.

But in your own interests, you might want to consider dialing your
touchiness back to about 2 or 3. Right now, it's so high it's annoying the
neighbours.

av

unread,
Jun 26, 2006, 4:29:00 AM6/26/06
to
On Sun, 25 Jun 2006 18:05:52 -0400, "Your Uncle"
<inv...@crippled.net> wrote:

>/* pruefer.c */
># include "big four.h"
>#define MILL (.001)
>int fu(int, int);
>int main(void)
>{
>unsigned long g, un_long_dummy, r = s = 0;
>int m = 3, n = 17000, mean_less_one, t;
>printf("taunt::continue: Y/N");
>if (getchar == 'N') break;

getchar should be a function
so you here would compare the address of function getchar and (int)'N'

i advise you it is better to read and *follow* and resolve the
exercises on K&R2

this for me should be
int c;
label:;


printf("taunt::continue: Y/N > ");

while((c=getchar())==' ');
if(c=='N' || c=='n' || c=='\n') return 0;
else if(c!='Y') goto label;
if(c!='\n') // for flush the line of input
while((c=getchar())!='\n');

i don't understand the remain but pc can understand better than me

Keith Thompson

unread,
Jun 26, 2006, 6:30:56 AM6/26/06
to

Frederick, please accept my apologies.

I had no malicious intent (and I'm not sure why you assumed that I
did). It was an honest mistake, and I'll be careful not to repeat it.

Frederick Gotham

unread,
Jun 26, 2006, 9:42:55 AM6/26/06
to
Keith Thompson posted:

> Frederick Gotham <fgot...@SPAM.com> writes:
>> Keith Thompson posted:
>>> All right, then.
>>>
>>> "Your Uncle"
>>> "Frederick Gotham"
>>> "Joe Smith"
>>>
>>> A recommendation for the killfiles of those who use them.
>>
>>
>> Hey hey hey what's all this about?!
>>
>> I post under one name and one name only.
>>
>> If you're THAT certain that I have an affiliation with the others you
>> have mentioned... then PROVE IT, rather than sabotaging the enjoyable
>> experience a sincere poster has on this newsgroup.
>>
>> I expect an apology from you once you have confirmed my innocence --
>> anything less would portray you as a malicious, inhospitable person.
>>
>> You make a great contribution to the group, Keith, and I regularly
>> find your posts interesting -- but your elevated status on this group
>> does not warrant the malicious behaviour you have displayed.
>
> Frederick, please accept my apologies.
>
> I had no malicious intent (and I'm not sure why you assumed that I
> did). It was an honest mistake, and I'll be careful not to repeat it.

Thank you.


Back to C!


--

Frederick Gotham

Frederick Gotham

unread,
Jun 26, 2006, 9:49:49 AM6/26/06
to
Richard Heathfield posted:

> Frederick Gotham said:
>
><snip>
>>
>> I expect an apology from you once you have confirmed my innocence --
>
> For the record, he has already done so (elsethread). He got you mixed
> up with someone else.


I had posted before he posted his subsequent post.


> Keith hasn't displayed any malicious behaviour. He's just pointing out
> a kook's multiple IDs for the benefit of anyone who hasn't spotted
> them yet, and he accidentally caught your name up in the middle of it,
> for which, as I say, he has already apologised.


Yes, I now accept that it was nothing more than an accident. However, in
life in general, I can't presume that everything ill-deed toward me is an
accident, which is why I presumed malice was involved rather than
accidental actions.

I had no intention of engaging in the conversation until I was
recommended for a kill file.


> If Keith has an "elevated status" on this group, it is because he is a
> helpful, intelligent subscriber who is knowledgeable about the C
> language. But he is not perfect. He makes mistakes, as we all do.


Of course exactly. Calculate the precentage of posts here which are by
him, then take their quality into account, and you're left with a very
great contribution.


However perhaps you can appreciate my "inappreciation" at being
recommended for a kill file, when I all I aim to do here is engage in
interesting and enjoyable conversation pertaining to the C programming
language.


> Twice to my knowledge, you have over-reacted to being corrected. This
> time, you have over-reacted to a case of mistaken identity - with, it
> must be said, rather more justification this time.
>
> But in your own interests, you might want to consider dialing your
> touchiness back to about 2 or 3. Right now, it's so high it's annoying
> the neighbours.


Back to the C programming language.


--

Frederick Gotham

Richard Heathfield

unread,
Jun 26, 2006, 9:52:53 AM6/26/06
to
Frederick Gotham said:

> Yes, I now accept that it was nothing more than an accident. However, in
> life in general, I can't presume that everything ill-deed toward me is an
> accident, which is why I presumed malice was involved rather than
> accidental actions.

Never forget to shave with Hanlon's Razor! :-)

Ref: <http://www.catb.org/jargon/html/H/Hanlons-Razor.html>

Keith Thompson

unread,
Jun 26, 2006, 4:16:23 PM6/26/06
to

You probably posted this before you saw my apology in the original
thread.

I welcome the opportunity to reiterate that I was mistaken in
including Frederick Gotham's name in the list.

Your Uncle

unread,
Jun 27, 2006, 3:52:59 AM6/27/06
to

"Richard Heathfield" <inv...@invalid.invalid> wrote in message
news:jp6dnd8QJ5C...@bt.com...

> Your Uncle said:
>
>>
>> "Richard Heathfield"
>>> Your Uncle said:
>>>> "Richard Heathfield"
>>>>> Your Uncle said:
>>
>>>>>> Is this going to work?
>>>>> It can be made to work.
>>>> If I fail, will a possible reason for this be that it was ill-advised
>>>> to
>>>> do so as opposed to just having two awfully similar functions?
>>> No. If you fail, it will be because you didn't manage to copy and paste
>>> the
>>> code I gave you. :-)
>> It doesn't do me a lick of good to snipe source, germane to what I know,
>> which I do not understand.
>
> Truly.
>
>> You had a generic swap posted
>
> ...which, if you do not understand it, you should ask questions about.
>
>> and I frankly
>> can't quite remember what else, but in response to the what else, I
>> wrote:
>> /* pruefer.c */
>> # include "big four.h"
>
> <rather bizarre program snipped>
No, bizarre is when grown men speak of kill and file, without a handle on
either.

>> /* bigfour.h */
>> # include <stdio.h>
>> # include <stdlib.h>
>> # include <math.h>
>> # include <time.h>
>> /* end bigfour.h */
>> Does this look like C?
>
> The program didn't. The header does (although I prefer not to mask
> standard
> headers in that way, it is certainly legal to do it).
>
>> The question is meant to proceed along two lines:
>> q1) If I approach my compiler with this, will cl.exe give me
>> errors/warnings.
>
> Yes.

They will be such that I can deal with them.

>
>> q2) I conjecture that "bigfour.h" is not included in the c
>> standard.
>
> You are correct.
>
>> Given that the possibly non-standard header includes ONLY
>> standard headers, what can a person say about it?
>
> That either the comment is not describing the filename accurately, or the
> #include directive in your C file is wrong.

Let me be more specific. A source text includes it's own header: fu.h whose
text is # include <stdio.h> . My question goes to c linkage. Indeed, when
linkage is the issue I think the terms c++ linkage or c linkage need a
terminology update. This question is to .c - c linkage. cheers, furunculus


Nick Keighley

unread,
Jun 27, 2006, 5:30:54 AM6/27/06
to
[I *think* I got the attributions right]

Your Uncle wrote:
> > ITYM, Frank (Not Fred, he used to work for CBS) Silvermann

> >>A recommendation for the killfiles from God, aren't you?

<snip>

> I go out to the pub. I come back. Can someone explain to me what killfile
> means

a killfile is a file used by some news reraders containing list of
people
whose posts you don't want to see. Hence to "killfile" someone is to
add
them to your killfile, because they are annoying or uninteresting or
whatever.

Posting under multiple aliases is irritating. Kenny is irritating.

> [...]in the context of the C programming language.

it's to do with news groups rather than the C language

> By someone, I do not mean a parochial American.

I find much of what you say quite incomprehensible. Are things like
this jokes?

> getchar() f

??


--
Nick keighley

Kenny McCormack

unread,
Jun 27, 2006, 8:22:09 AM6/27/06
to
In article <1151400654.5...@x69g2000cwx.googlegroups.com>,
Nick Keighley <nick_keigh...@hotmail.com> wrote:
...

>I find much of what you say quite incomprehensible. Are things like
>this jokes?

Or maybe you're just stupid.

Kenny McCormack

unread,
Jun 27, 2006, 8:25:51 AM6/27/06
to
In article <44a0e2ce$0$30720$ec3e...@news.usenetmonster.com>,
Your Uncle <inv...@crippled.net> wrote:
...

>> <rather bizarre program snipped>
>No, bizarre is when grown men speak of kill and file, without a handle on
>either.

What makes you think they are "grown".

From what I can tell, they are all just frustrated high school kids
(inside).

Chris Dollin

unread,
Jun 27, 2006, 8:25:13 AM6/27/06
to
Kenny McCormack wrote:

(D. N. F. T. T.)

--
Chris Dollin
"Life is full of mysteries. Consider this one of them." Sinclair, /Babylon 5/

Your Uncle

unread,
Jun 27, 2006, 11:30:05 PM6/27/06
to
I appreciate your Einsatz and never forget a kindness. I've hit day's end
with my compiler:
/* Text1.c */
# include "Text2.h"

#define MILL (.001)
int fu(int, int);
int main(void)
{
unsigned long g = 15, un_long_dummy, r = 0, s = 0;

int m = 3, n = 17000, mean_less_one, t;
srand(time(NULL));

mean_less_one = (n - m) / 2;
printf("mu is %d\n" , mean_less_one);

for (un_long_dummy = 0; un_long_dummy < g; ++ un_long_dummy)
{
t = fu(m, n);

/* printf("tja"); */


if (t <= mean_less_one) ++ r;
else ++ s;
}
printf("r is %ul while s is %ul\n", r, s);
return 0;
}
int fu(int m, int n)
{

int t;
t = rand();
/* printf("tja"); */
return t;
}
/* end .c */
I don't see why r and s do not add to g here. I could talk about it but it
would only reveal the thickheadedness that motivates the question. I know
that there was some talk about unsigned longs and zero. I would certainly
hope that Mr. Ritchie had the foresight to include the additive identity of
the ring of integers in the datatype. So, I'm forced to believe that I'm
cross-eyed. gruss, furunculus


Your Uncle

unread,
Jun 27, 2006, 11:48:44 PM6/27/06
to

"Ian Collins" <ian-...@hotmail.com> wrote in message
news:4g3fb7F...@individual.net...
> Your Uncle wrote:
>> "Dann Corbit" <dco...@connx.com> wrote in message
>> news:e7hucf$bkf$1...@nntp.aioe.org...
>>
>>>The problem with the void pointer thingy is that the function taking the
>>>void pointer will not know what is being passed in. So you are stuck
>>>with
>>>a whole bunch of callback functions.
>>
>> I'm not sure what that means. Maybe we could make a better trivial
>> example:
>>
>> void print_a_char(char);
>> void print_an_int(int);
>> would be definitions and then
>> print_a_char(char g){ printf(" %c\n", g) }
>> print_an_int(int g){ printf(" %d\n", g) }
>> Does that clarify, obfuscate, or just bore? cheers, f
>>
> For a trivial example, the overhead would outweigh the benifit of a
> generic function.
>
> For a more complex example, you are stuck with the function not knowing
> the type passed in and the compiler not being able to check whether the
> passed types are supported.
And that's what he meant with "callback functions?" I can't get my head
around it. cheers, f


Ian Collins

unread,
Jun 28, 2006, 12:34:50 AM6/28/06
to
Dan might have been referring to functions you would have to pass along
with the type to do whatever the action is.

For example in you print_a_something case, you would have to pass in the
something and a function to return the the appropriate format string.
If the something was more complex than a POD, a function to do the
printing would be required.

--
Ian Collins.

Your Uncle

unread,
Jun 28, 2006, 6:58:17 PM6/28/06
to

"Ian Collins" <ian-...@hotmail.com> wrote in message
news:4gef7aF...@individual.net...
He's thinking down the hall. Since Keith Thompson shit all over my thread,
and no one wants to cross him, I think I'm looking for the exit sign. I use
aliases to protect both the innocent and not-so-very. This was a big issue
for me until I satisfied the statue in <limits.h> . My good friend Carl is
my attorney bernie, with whose friends I'm impressed. My brother is
Thunderfist, a former federal agent whose backyard is San Diego (diligence).
Since my c endeavors have ground to a halt at least for lack of comment and
a sore clickerfinger, I'll gear up for next month for when he comes to town
to lose a basketball game and query how to boost my projects. Black Ford


Ian Collins

unread,
Jun 28, 2006, 7:06:33 PM6/28/06
to
Your Uncle wrote:
> "Ian Collins" <ian-...@hotmail.com> wrote in message
> news:4gef7aF...@individual.net...

>
>>Dan might have been referring to functions you would have to pass along
>>with the type to do whatever the action is.
>>
>>For example in you print_a_something case, you would have to pass in the
>>something and a function to return the the appropriate format string.
>>If the something was more complex than a POD, a function to do the
>>printing would be required.
>
> He's thinking down the hall.

[drivel snipped]

>
What relevance did that drivel have to my response?

--
Ian Collins.

pete

unread,
Jun 28, 2006, 7:37:24 PM6/28/06
to
Ian Collins wrote:

>
> Your Uncle wrote:

> [drivel snipped]
>
> >
> What relevance did that drivel have to my response?

I think the point that Frank was trying to make,
is that he's insane.

--
pete

Keith Thompson

unread,
Jun 28, 2006, 7:53:17 PM6/28/06
to
"Your Uncle" <inv...@crippled.net> writes:
[...]

> He's thinking down the hall. Since Keith Thompson shit all over my thread,
> and no one wants to cross him, I think I'm looking for the exit sign. I use
> aliases to protect both the innocent and not-so-very. This was a big issue
> for me until I satisfied the statue in <limits.h> . My good friend Carl is
> my attorney bernie, with whose friends I'm impressed. My brother is
> Thunderfist, a former federal agent whose backyard is San Diego (diligence).
> Since my c endeavors have ground to a halt at least for lack of comment and
> a sore clickerfinger, I'll gear up for next month for when he comes to town
> to lose a basketball game and query how to boost my projects. Black Ford

I'm responding to this only because you mentioned my name.

I have no clue what you're talking about. Fortunately, I don't care.

This is not your thread. The fact that you posted the original
article doesn't give you any kind of ownership. I don't know what you
think I did to this thread. If you'd care to explain without being
incoherent or offensive, I'll read what you have to say about it. (If
you're referring to the error I made in listing someone else's name as
one of your pseudonyms, I've already acknowledged that, and you
weren't the victim of my mistake anyway.)

I have no idea why you're telling us about your friend Carl or your
brother. We discuss the C programming language here. If you insist
on talking about whatever the hell you're talking about, I encourage
you to do it elsewhere. Nobody else cares.

I've already explained why your use of multiple pseudonyms is a
problem, and I have nothing to add to that.

The exit sign is easy to find. If you want to leave, all you have to
do is stop posting.

I doubt that I'll bother responding to you again.

Richard Heathfield

unread,
Jun 28, 2006, 8:11:50 PM6/28/06
to
Keith Thompson said:

<snip>



> I doubt that I'll bother responding to you again.

I gave up on him some days ago.

Barry Schwarz

unread,
Jun 28, 2006, 10:12:09 PM6/28/06
to

What do you think %ul means? What is the correct format conversion
for unsigned long? This probably wouldn't have confused you if ell
didn't look so much like one.


Remove del for email

Default User

unread,
Jun 29, 2006, 1:02:19 PM6/29/06
to
Richard Heathfield wrote:

> Keith Thompson said:
>
> <snip>
>
> > I doubt that I'll bother responding to you again.
>
> I gave up on him some days ago.

I've come to that conclusion as well, all his various personalities are
heading for the bozo bin.


Brian

0 new messages