Thursday, April 8, 2010

comp.lang.c - 25 new messages in 8 topics - digest

comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en

comp.lang.c@googlegroups.com

Today's topics:

* lvalues and rvalues - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/0bcad112a3ad97f0?hl=en
* C the complete nonsense - 7 messages, 5 authors
http://groups.google.com/group/comp.lang.c/t/fee08dfa5e4cbaaa?hl=en
* 'sizeof' in defensve programming - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.c/t/e9a378626cd7a329?hl=en
* Line drawing with Bresenham more than one pixel thick - 2 messages, 2
authors
http://groups.google.com/group/comp.lang.c/t/a26c26d92f082ac7?hl=en
* Pausing screen? - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/8b8e7943a28d1f6c?hl=en
* Bill Cunningham and sockets for the past six years - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/d619226f82f56065?hl=en
* Generic linked list with internal storage? - 5 messages, 4 authors
http://groups.google.com/group/comp.lang.c/t/d36ff63bef634bcc?hl=en
* In the Matter of Herb Schildt: a Detailed Analysis of "C: The Complete
Nonsense" - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/caf17fab4e7d8530?hl=en

==============================================================================
TOPIC: lvalues and rvalues
http://groups.google.com/group/comp.lang.c/t/0bcad112a3ad97f0?hl=en
==============================================================================

== 1 of 3 ==
Date: Thurs, Apr 8 2010 12:22 am
From: Phil Carmody


Keith Thompson <kst-u@mib.org> writes:
> Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
>> Keith Thompson <kst-u@mib.org> writes:
>>> Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
>>>> Keith Thompson <kst-u@mib.org> writes:
>>>>> Nicklas Karlsson <karlsson.nicklas@gmail.com> writes:
>>>>>> "I'd say "address" rather than "starting address". In C, an address
>>>>>> is typed. It doesn't point to the beginning of an object, it points
>>>>>> to the object."
>>>>>>
>>>>>> So since an address is typed, int* for example, one says that it
>>>>>> points to the entire object? It points to an "int", but nevertheless
>>>>>> it still points to the first allocated byte of size(int) bytes
>>>>>> allocated for an int
>>>>>
>>>>> Well, that's one way to look at it, but I find it clearer to think of
>>>>> an address (pointer value) as pointing to the entire object. It's one
>>>>> way in which a C pointer value is conceptually different, and at a
>>>>> higher level, than a machine address.
>>>>
>>>> Yeah, but no, but yeah, but no, but most architectures have some
>>>> kind of indexed indirect addressing mode; so an address register
>>>> could be numerically equal to the address of the start of an object,
>>>> but used to access the whole object.
>>>
>>> And an address register might very well contain something that looks
>>> like, and can be operated on as, an integer.
>>>
>>> A C pointer value, conceptually at least, does not.
>>
>> I don't see how that addresses my point. A machine's address
>> register can be used to refer to more than just an atomic
>> entity at a single address.
>
> I'm not sure exactly what your point is. Can you clarify? C doesn't
> describe pointers in terms of the behavior of a machine's address
> register.

Nor do I imply that it does, in fact quite the opposite, as we were
in the context of your contrast:

>>>>> a C pointer value is conceptually different, and at a
>>>>> higher level, than a machine address.

Which is what we agree on. However where we diverge is this part:

>>>>> I find it clearer to think of
>>>>> an address (pointer value) as pointing to the entire object.

where that is being contrasted to machine addresses.

Whenever I write assembly language, I never think of the addresses
and address registers as being untyped. If they are addresses of
structs, then there always be a range of meaningful offsets (which
I will have symbolic names for) off which I can index them, and if
they are addresses of elements of an array, there's always just one
meaningful delta to increment or decrement them by (which again I
will have a symbolic name for). The language doesn't enforce this,
but you were talking about the conceptual level, and conceptually
it appears I view assembly language as being at a higher level than
you. A6 may be the address of the first byte of an object, but it's
also the address of the object, and usually I'd prefer to keep that
latter abstraction in mind than the former.

> A machine address register typically contains, say, 32 or 64
> bits of data that usually refer to some location in memory.
> The meaning of those 32 or 64 (or whatever) bits of data depends
> on what instructions are used to manipulate them. (Some machines
> don't have address registers; they just store addresses in general
> purpose registers.)
>
> A C address / pointer value, on the other hand, has a type associated
> with it (though this association probably exists only in the source
> code and at compile time).

A full enough assembly language can also support such an abstract
approach, even if it doesn't enforce it. Where in C I'd see a
pointer to type thingy, in assembly I see an address of a thingy,
not just a raw abstract address.

I've seen a lot of assembly language for a lot of different
architectures, and I appear to be in a minority, but quite often
I see assembly language code where I can see an almost direct
mapping onto C. (This is typically the 'scare' assembly - "it
needs to be fast so we must write it in assembly!", where all
they do is what they could have done in C anyway, and don't
necessarily end up with anything better than what a good C
compiler could have done.)

> If you have an array of structures, then a pointer to the entire
> array, a pointer to the first element of the array, and a pointer
> to the first member of the first element of the array are likely
> to have the same representation, but I don't think that implies
> that a pointer doesn't (conceptually) point to the entire object.

Where do you get the impression I think otherwise? I just don't
think that's a contrast with assembly language, I think that in
assembly languge they may (conceptually) point to the entire
object too.

Call me a high level assembler (but not HLA) programmer, if you will.
Actually, don't. Because I find that I can saturate pipelines in C,
and never need to resort to assembly language unless writing something
hardware-specific (and that will typically just be one or two
instructions), preferring something with a modicum of portability any
day.

Phil
--
I find the easiest thing to do is to k/f myself and just troll away
-- David Melville on r.a.s.f1


== 2 of 3 ==
Date: Thurs, Apr 8 2010 12:42 am
From: Phil Carmody


Seebs <usenet-nospam@seebs.net> writes:
> On 2010-04-07, Keith Thompson <kst-u@mib.org> wrote:
>> If you have an array of structures, then a pointer to the entire
>> array, a pointer to the first element of the array, and a pointer
>> to the first member of the first element of the array are likely
>> to have the same representation, but I don't think that implies
>> that a pointer doesn't (conceptually) point to the entire object.
>
> In particular, you can have three pointers which, converted to (void *),
> compare equal, but which point to different objects. One could point
> to the array, one to the first structure in that array, and one to the
> first element in that structure.

... and if that first element is an array ...

> More interestingly, so far as I can tell, the three pointers could have
> different logical bounds, such that a bounds-checking implementation could
> react differently to attempts to memcpy a large number of bytes from or
> to them, even though the pointers compare equal.

Do such fat pointer implementations really exist, check a significant
proportion of the accesses, and compile real world code into something
that works? I can't see how a pointer to a single object in an array
would be distinguished from a pointer to the rest of the elements of
the array from that single object onwards.

You (the caller) don't want fblag(FILE*fp,...) accessing fp[1], but
you don't mind strstuff(char*s,...) accesing s[1], s[2], ... . How
do you make that distinction?

Phil
--
I find the easiest thing to do is to k/f myself and just troll away
-- David Melville on r.a.s.f1


== 3 of 3 ==
Date: Thurs, Apr 8 2010 12:54 am
From: Seebs


On 2010-04-08, Phil Carmody <thefatphil_demunged@yahoo.co.uk> wrote:
> Do such fat pointer implementations really exist, check a significant
> proportion of the accesses, and compile real world code into something
> that works? I can't see how a pointer to a single object in an array
> would be distinguished from a pointer to the rest of the elements of
> the array from that single object onwards.

I am told that such implementations exist, basically as extremely
elaborate instrumentation of code. It is certainly possible to make one
that correctly checks absolutely all accesses -- and even to make it
tolerably efficient by static analysis so you don't have to keep rechecking
things.

> You (the caller) don't want fblag(FILE*fp,...) accessing fp[1], but
> you don't mind strstuff(char*s,...) accesing s[1], s[2], ... . How
> do you make that distinction?

When fp was returned from fopen, it was already tagged with the information
that it pointed to a single FILE. When you pass s in to strstuff(), it's
an existing pointer which was somehow derived from an object, or allocated,
or something. So we know its bounds.

Basically, you can't get a pointer without the compiler at some point having
known what it pointed to. Therefore, you can check bounds.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!

==============================================================================
TOPIC: C the complete nonsense
http://groups.google.com/group/comp.lang.c/t/fee08dfa5e4cbaaa?hl=en
==============================================================================

== 1 of 7 ==
Date: Thurs, Apr 8 2010 12:25 am
From: Nick Keighley


On 7 Apr, 20:28, spinoza1111 <spinoza1...@yahoo.com> wrote:

> This is the basic problem. You define what it is you want to work with
> and you don't play well with others. In fact, my research has
> confirmed that you have a problem working with others in general. I
> won't go into any detail on this in order to respect your privacy in a
> way mine has not been respected by you; suffice it to say I have
> examined material in the public view only.
>
> You believe that using Linux makes you special. This is in fact a form
> of white racism which has infected computing because the dirty little
> secret is that by staying away from Windows you stay away from Windows
> users, who are increasingly and in a global sense nonwhite, while
> Linux's affiliation with universities codes this in your mind as a
> "white" system.

isn't Linux widely used by non-white people? Isn't Linux's I18N on a
par with Windows'?


> You also demand a "white" privilege of defining the rules of success.

<snip>

aren't you white?


== 2 of 7 ==
Date: Thurs, Apr 8 2010 12:21 am
From: Seebs


On 2010-04-08, Nick Keighley <nick_keighley_nospam@hotmail.com> wrote:
> On 8 Apr, 05:03, spinoza1111 <spinoza1...@yahoo.com> wrote:
>> Yes. There were 20 and 14 were incorrect. For the past ten years, the
>> document has described the wrong edition.

This is, as always, wrong.

1. There is nothing "wrong" about describing the edition that was out
when the document was written. No claim was made that the document was
about the most recent edition.
2. We still haven't seen Nilges apologize for the outright lie of claiming
that the page was based on the first edition.
3. He *dislikes* 14 out of 20 -- he hasn't shown that they're wrong. But
wait! Even if they were, that would still be six severe, fundamental, errors
in Schildt's book, none of which should have ever been made by someone
competent to write such a book.

> I'm talking about the "pick a random page and list the errors" game
> that various people have been playing on these threads. I notice you
> ignore most of them. is that because they are correct?

I think he ignores them because they aren't opportunities to flame me. :)

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!


== 3 of 7 ==
Date: Thurs, Apr 8 2010 12:49 am
From: Seebs


On 2010-04-08, Nick Keighley <nick_keighley_nospam@hotmail.com> wrote:
> On 7 Apr, 20:28, spinoza1111 <spinoza1...@yahoo.com> wrote:
>> You believe that using Linux makes you special. This is in fact a form
>> of white racism which has infected computing because the dirty little
>> secret is that by staying away from Windows you stay away from Windows
>> users, who are increasingly and in a global sense nonwhite, while
>> Linux's affiliation with universities codes this in your mind as a
>> "white" system.

> isn't Linux widely used by non-white people? Isn't Linux's I18N on a
> par with Windows'?

No offense, but is there any point in responding to a rant that illucid
with factual points? I have no idea where Nilges gets the idea that I
think using Linux makes me special. I don't even particularly like Linux.

But the pure noise component really dominates any kind of argumentation here.
What does "in a global sense" mean? It means that Nilges has access to a
keyboard, and not much else.

>> You also demand a "white" privilege of defining the rules of success.

><snip>

> aren't you white?

Well, to be fair, doesn't he consistently demand the privilege of defining
the rules of success? So I guess that's at least consistent with his other
behavior.

Me, I have no interest in "defining the rules of success". I am a
descriptive, not a prescriptive, student of programming. If something really
does work, I don't care whether it matches any particular theory. (Contrast
with Nilges, whose cover story for not knowing how switch() works is that it's
not properly "structured".) When I criticize non-portability, it's not
because I have any particular preference for portability *in and of itself*;
it's because my experience has taught me that portability offers a very
substantial return on time and effort invested in it, and in particular,
that writing for portability from the beginning is much cheaper than trying
to bolt it on later.

The rules of success are that if what you're doing works and allows you to
be successful, apparently that's a way of succeeding. No interest in defining
that; it strikes me as a ludicrous effort. It's like demanding the privilege
of defining the laws of physics. You don't get a vote; physics is out there,
and you can cope or not.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!


== 4 of 7 ==
Date: Thurs, Apr 8 2010 12:56 am
From: Ian Collins


On 04/ 8/10 07:25 PM, Nick Keighley wrote:
> On 7 Apr, 20:28, spinoza1111<spinoza1...@yahoo.com> wrote:
>
>> This is the basic problem. You define what it is you want to work with
>> and you don't play well with others. In fact, my research has
>> confirmed that you have a problem working with others in general. I
>> won't go into any detail on this in order to respect your privacy in a
>> way mine has not been respected by you; suffice it to say I have
>> examined material in the public view only.
>>
>> You believe that using Linux makes you special. This is in fact a form
>> of white racism which has infected computing because the dirty little
>> secret is that by staying away from Windows you stay away from Windows
>> users, who are increasingly and in a global sense nonwhite, while
>> Linux's affiliation with universities codes this in your mind as a
>> "white" system.
>
> isn't Linux widely used by non-white people? Isn't Linux's I18N on a
> par with Windows'?

Thanks for exposing that one Nick, it's a classic of its kind.

I wonder if the plonker knows where the first government drive to
replace Windows with Linux happened?

<BBC mode>
By the way, other opensource operating systems are available.
</BBC mode>

--
Ian Collins


== 5 of 7 ==
Date: Thurs, Apr 8 2010 1:35 am
From: Nick Keighley


On 6 Apr, 16:54, ImpalerCore <jadil...@gmail.com> wrote:
> On Apr 5, 4:58 pm, jacob navia <ja...@jacob.remcomp.fr> wrote:

[naviaisms]

> This is not the kind of attitude that will lead people to want to use
> your container library.

it seems an odd way to judge software. Do you only buy software from
people you like. presumably the success of the open source movement is
down entirely to Stallman's wit and charm.

== 6 of 7 ==
Date: Thurs, Apr 8 2010 1:37 am
From: Tim Streater


In article <slrnhrr2ku.s73.usenet-nospam@guild.seebs.net>,
Seebs <usenet-nospam@seebs.net> wrote:

> The rules of success are that if what you're doing works and allows you to
> be successful, apparently that's a way of succeeding. No interest in defining
> that; it strikes me as a ludicrous effort. It's like demanding the privilege
> of defining the laws of physics. You don't get a vote; physics is out there,
> and you can cope or not.

In short: Spinny is unable to deal with reality.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689


== 7 of 7 ==
Date: Thurs, Apr 8 2010 3:30 am
From: spinoza1111


On Apr 8, 3:56 pm, Ian Collins <ian-n...@hotmail.com> wrote:
> On 04/ 8/10 07:25 PM, Nick Keighley wrote:
>
>
>
>
>
> > On 7 Apr, 20:28,spinoza1111<spinoza1...@yahoo.com>  wrote:
>
> >> This is the basic problem. You define what it is you want to work with
> >> and you don't play well with others. In fact, my research has
> >> confirmed that you have a problem working with others in general. I
> >> won't go into any detail on this in order to respect your privacy in a
> >> way mine has not been respected by you; suffice it to say I have
> >> examined material in the public view only.
>
> >> You believe that using Linux makes you special. This is in fact a form
> >> of white racism which has infected computing because the dirty little
> >> secret is that by staying away from Windows you stay away from Windows
> >> users, who are increasingly and in a global sense nonwhite, while
> >> Linux's affiliation with universities codes this in your mind as a
> >> "white" system.
>
> > isn't Linux widely used by non-white people? Isn't Linux's I18N on a
> > par with Windows'?
>
> Thanks for exposing that one Nick, it's a classic of its kind.
>
> I wonder if the plonker knows where the first government drive to
> replace Windows with Linux happened?

Uh, when IBM realized that it could steal Linux from The Santa Cruz
Operation circa 1995, and use its lawyers to get away with the theft
of intellectual property and intellectual production?
>
> <BBC mode>
> By the way, other opensource operating systems are available.
> </BBC mode>
>
> --
> Ian Collins


==============================================================================
TOPIC: 'sizeof' in defensve programming
http://groups.google.com/group/comp.lang.c/t/e9a378626cd7a329?hl=en
==============================================================================

== 1 of 4 ==
Date: Thurs, Apr 8 2010 1:16 am
From: "Mark"


I once heard that use of 'sizeof' operator is frowned upon by the followers
of defensive programming. I understand that it's not safe to rely on. for
example, 'sizeof(short)' or similar, because these values may differ on
different platforms. But are there other reasons stopping from using sizeof
in everyday's code?

--
Mark

== 2 of 4 ==
Date: Thurs, Apr 8 2010 1:55 am
From: Ian Collins


On 04/ 8/10 08:16 PM, Mark wrote:
> I once heard that use of 'sizeof' operator is frowned upon by the
> followers of defensive programming.

From whom?

> I understand that it's not safe to
> rely on. for example, 'sizeof(short)' or similar, because these values
> may differ on different platforms.

Isn't that a reason *too* use sizeof?

> But are there other reasons stopping from using sizeof in everyday's code?

No

--
Ian Collins


== 3 of 4 ==
Date: Thurs, Apr 8 2010 2:15 am
From: Nick Keighley


On 8 Apr, 09:16, "Mark" <mark_cruzNOTFORS...@hotmail.com> wrote:

> I once heard that use of 'sizeof' operator is frowned upon by the followers
> of defensive programming.

sounds like some sort of cult. Presumably they surround their code
with little pointy sticks.


> I understand that it's not safe to rely on.

it reliably evaluates to the size of its argument. In what way is this
unreliable?

> for
> example, 'sizeof(short)' or similar, because these values may differ on
> different platforms.

sizeof(short) may yeild different values on different platforms. In
what way would it be better to use a fixed but incorrect value?


> But are there other reasons stopping from using sizeof
> in everyday's code?

I haven't heard a reason not to use it non-everyday code (feast day
code?) yet


== 4 of 4 ==
Date: Thurs, Apr 8 2010 2:58 am
From: Malcolm McLean


On 8 Apr, 09:16, "Mark" <mark_cruzNOTFORS...@hotmail.com> wrote:
> I once heard that use of 'sizeof' operator is frowned upon by the followers
> of defensive programming. I understand that it's not safe to rely on. for
> example, 'sizeof(short)' or similar, because these values may differ on
> different platforms. But are there other reasons stopping from using sizeof
> in everyday's code?
>
You've got the wrong end of the stick.

printf("%d\n", (int) sizeof(short) );

will usually print out the digit '2'. Occasionally you will get a '1'
or a '4', and other numbers are theoreticaly possible.
Just occasionally a difference like this will break programs.

However if you want an array of, say, 20 shorts in dynamic memory

ptr = malloc(20 * sizeof(short));

will get you a memory buffer of the right size. You don't care whether
it is 20 bytes, 40 bytes or 80 bytes. All you care is that it can hold
20 shorts. You might say "I want a 16-bit integer, not a short".
Generally, you don't. If short isn't 16 bits, then there will be a
good reason for it, eg the computer has oceans of memory, and 32 bit
reads are faster than 16 bit reads.

==============================================================================
TOPIC: Line drawing with Bresenham more than one pixel thick
http://groups.google.com/group/comp.lang.c/t/a26c26d92f082ac7?hl=en
==============================================================================

== 1 of 2 ==
Date: Thurs, Apr 8 2010 1:35 am
From: Gazza


Hello,

I am using the Bresenham algorithm to draw single pixel lines with no
problems. However I would like to draw some lines which are more than
one pixel thick. Is there a modification to this algorithm that I can
use or can anyone point me to an algorithm or resource that I can use
to investigate / achieve this?

Many thanks in advance

Gary


== 2 of 2 ==
Date: Thurs, Apr 8 2010 1:56 am
From: Ian Collins


On 04/ 8/10 08:35 PM, Gazza wrote:
> Hello,
>
> I am using the Bresenham algorithm to draw single pixel lines with no
> problems. However I would like to draw some lines which are more than
> one pixel thick. Is there a modification to this algorithm that I can
> use or can anyone point me to an algorithm or resource that I can use
> to investigate / achieve this?

Do you have a C question? You appear to posted to the wrong group.

--
Ian Collins

==============================================================================
TOPIC: Pausing screen?
http://groups.google.com/group/comp.lang.c/t/8b8e7943a28d1f6c?hl=en
==============================================================================

== 1 of 2 ==
Date: Thurs, Apr 8 2010 1:57 am
From: Nick Keighley


On 6 Apr, 07:28, Seebs <usenet-nos...@seebs.net> wrote:
> On 2010-04-06, Bill Reid <hormelf...@gmail.com> wrote:

> > To who?  The programmer?  Are you, the programmer, using
> > something like printf() as a poor (read: "stupid") man's
> > debugger, thus you want to see output that you, the programmer,
> > never intends the user to see?
>
> Having done both debugger-debugging and printf-debugging, I find them
> suited to very different kinds of tasks.
>
> For sporadic failures, comprehensive logging can be a lot more useful
> than trying to step through things.  If nothing else, it can give me
> a very clear picture of where to start looking.  I really like being
> able to look at a log after the fact, without having to know in advance
> that I want to run under the debugger.

yes. But I tend to write such logs to files rather thant he console.
Even knowing the last thing the program wes doing before it crashed
can be helpful. Some programs are supposed to run for days or weeks or
even longer.


== 2 of 2 ==
Date: Thurs, Apr 8 2010 2:07 am
From: Nick Keighley


On 2 Apr, 21:05, Kenneth Brody <kenbr...@spamcop.net> wrote:
> On 3/30/2010 10:51 AM, Bill Reid wrote:

> >> There is no "MS-DOS command prompt" since windows-95 -and
> >> windows98- are no longer supported since several years.
>
> > I originally stated that they've changed the name of
> > the "Command Prompt" over the years...a wilted rose by
> > any other name, eh?
>
> Do you call a Linux console windows an "MS-DOS command prompt"?  If not, why
> do you insist on calling a Windows console window an "MS-DOS command prompt"?

does a linux console window have a superficial resemblance to a MS-DOS
prompt window? Does linux support a DOS-like shell? (knowing linux,
probably yes!)

==============================================================================
TOPIC: Bill Cunningham and sockets for the past six years
http://groups.google.com/group/comp.lang.c/t/d619226f82f56065?hl=en
==============================================================================

== 1 of 1 ==
Date: Thurs, Apr 8 2010 2:22 am
From: Jonathan de Boyne Pollard


Given that M. Margolin hasn't done the Googling, yet:

>> Don't fall for it. See what Jens Thoms Toerring wrote in the last
>> Bill Cunningham and sockets thread.
>>
> I usually don't respond to these types of messages but you need to at
> least be truthfull. I have only begun studying sockets. [...]
>
The truth is that you were "studying sockets" six years ago in
comp.os.ms-windows.programmer.win32 and
microsoft.public.win32.programmer.ole, where you were asking Win32
programmers WinSock-flavoured versions of the questions that you are now
asking Unix programmers. Your postings would have the world think that
you have made zero progress in learning how to compile even basic C
programs in eight years, when you first started talking about how you
were using DJGPP and mingw. Indeed you are trying to convince people
that you have less grasp of things now than you did when you were
talking about recompiling gcc in comp.os.linux.development.apps in 2005,
or about the Standard C library in kernel-mode code in comp.lang.c back
in 2003, or about microkernels in comp.os.linux.development.system in
2002, or about how to use DJGPP in comp.os.linux in 2002, or about Win32
API programming in comp.programming in 2002.

More and more people are not going to fall for this any more. Jens
Thoms Toerring has sussed you. santosh and Mark McIntyre sussed you in
2005. They'll all no doubt be disappointed to learn that it took them
longer than Eric Tomson, who sussed you in 2002 when you asked Linus
Torvalds silly questions on the IETF mailing list.


==============================================================================
TOPIC: Generic linked list with internal storage?
http://groups.google.com/group/comp.lang.c/t/d36ff63bef634bcc?hl=en
==============================================================================

== 1 of 5 ==
Date: Thurs, Apr 8 2010 3:20 am
From: Jef Driesen


Hi,

A typical (double) linked list is implemented with these two data
structures:

typedef struct node_t {
node_t *prev;
node_t *next;
void *data;
} node_t;

typedef struct list_t {
node_t *head;
node_t *tail;
} list_t;

typedef struct mydata_t {
...
} mydata_t;

The major disadvantage of this approach is that the data contents of the
list needs to be stored outside of the list data structures. Thus if you
want to store some user defined data in the list, you end up with two
memory allocations per node: one for the node_t structure, and one for
the user defined mydata_t structure.

Is there a way to avoid this additional allocation, but without loosing
the ability to store custom data? Thus I don't want to tie my list to
the mydata_t structure like this:

typedef struct node_t {
node_t *prev;
node_t *next;
mydata_t data;
} node_t;

Maybe allocate storage for the node_t and the mydata_t structure in a
single block. Something like this:

node_t *node = malloc (sizeof (node_t) + sizeof (mydata_t));
mydata_t *data = node + sizeof (node_t);

But I think this might cause trouble due to alignment issues?

Thanks,

Jef


== 2 of 5 ==
Date: Thurs, Apr 8 2010 3:36 am
From: Malcolm McLean


On 8 Apr, 11:20, Jef Driesen <jefdrie...@hotmail.com.invalid> wrote:
>
> node_t *node = malloc (sizeof (node_t) + sizeof (mydata_t));
> mydata_t *data = node + sizeof (node_t);
>
> But I think this might cause trouble due to alignment issues?
>
Yes. In practice it's unlikely that a structure consisting only of
pointers would break alignment, and even less likely that a couplet of
two pointers would do so. But it is possible and allowed by the
standard.
You can still store and extract the data by treating it as raw bytes,
but that's not very efficient.

== 3 of 5 ==
Date: Thurs, Apr 8 2010 3:48 am
From: MaciekL <__nospam__maclab@o2.pl>


Hi,

> A typical (double) linked list is implemented with these two data
> structures:
>
> typedef struct node_t {
> node_t *prev;
> node_t *next;
> void *data;
> } node_t;
>
> typedef struct list_t {
> node_t *head;
> node_t *tail;
> } list_t;
>
> typedef struct mydata_t {
> ...
> } mydata_t;

You can ommit aligment issue with follwowing example:

typedef struct node_mydata_t {
node_t node;
mydata_t mydata;
};

void function(void)
{
node_mydata_t * node_mydata = malloc(sizeof(*node_mydata));
node_t * node = &(node_mydata->node); /* same address as
node_mydata - node is a first element in structure */
node->data = &(node_mydata->mydata)
...
}

Best Regards

--
Maciek


== 4 of 5 ==
Date: Thurs, Apr 8 2010 3:53 am
From: MaciekL <__nospam__maclab@o2.pl>


On 2010-04-08 12:48, MaciekL wrote:

Invalid declaration:
> typedef struct node_mydata_t {
> node_t node;
> mydata_t mydata;
> };

fixed:
typedef struct node_mydata_t {
node_t node;
mydata_t mydata;
} node_mydata_t;

--
Maciek


== 5 of 5 ==
Date: Thurs, Apr 8 2010 3:57 am
From: jacob navia


Jef Driesen a écrit :
> Hi,
>
> A typical (double) linked list is implemented with these two data
> structures:
>
> typedef struct node_t {
> node_t *prev;
> node_t *next;
> void *data;
> } node_t;
>
> typedef struct list_t {
> node_t *head;
> node_t *tail;
> } list_t;
>
> typedef struct mydata_t {
> ...
> } mydata_t;
>
> The major disadvantage of this approach is that the data contents of the
> list needs to be stored outside of the list data structures. Thus if you
> want to store some user defined data in the list, you end up with two
> memory allocations per node: one for the node_t structure, and one for
> the user defined mydata_t structure.
>
> Is there a way to avoid this additional allocation, but without loosing
> the ability to store custom data? Thus I don't want to tie my list to
> the mydata_t structure like this:
>
> typedef struct node_t {
> node_t *prev;
> node_t *next;
> mydata_t data;
> } node_t;
>
> Maybe allocate storage for the node_t and the mydata_t structure in a
> single block. Something like this:
>
> node_t *node = malloc (sizeof (node_t) + sizeof (mydata_t));
> mydata_t *data = node + sizeof (node_t);
>
> But I think this might cause trouble due to alignment issues?
>
> Thanks,
>
> Jef

In the containers library I am working I added a field "ElementSize" to
the list header (your list_t), and when I allocate a node I allocate with:

node_t *n = malloc(sizeof(node)+list->ElementSize);

To assign the data I do:

memcpy(node->data,object,list->ElementSize);

The node structure is declared exactly like yours but at the end I
differ with:

typedef struct node_t {
node_t *prev;
node_t *next;
char data[];
} node_t;

Note that this is using C99.

==============================================================================
TOPIC: In the Matter of Herb Schildt: a Detailed Analysis of "C: The Complete
Nonsense"
http://groups.google.com/group/comp.lang.c/t/caf17fab4e7d8530?hl=en
==============================================================================

== 1 of 1 ==
Date: Thurs, Apr 8 2010 3:23 am
From: spinoza1111


On Apr 7, 8:24 pm, blm...@myrealbox.com <blm...@myrealbox.com> wrote:
snippety snip
>
> (*) The function to obtain the time of day with (fairly) high
> resolution doesn't even try to be portable.  But as far as I
> know it's not possible to write such a function in portable C,
> and the comments are pretty clear about this code needing to be
> reviewed for platforms other than the one I developed on.

I need a full link; this has ellipses. I look forward, quite
seriously, to reading your code.


snipola
>
> I don't know C#, but the same thing is true in Java -- but the
> ints are *NOT* a subset of the floats in Java.  

That is correct. But I'd hasard they are a subset of the doubles. Most
competent C Sharp programmers, who use a mental model derived
independently of the mistakes of geeks, prefer doubles to floats for
this reason.

> > Truly competent programmers WANT to program in the best languages
> > available, and do not think using an inferior language is a mark of
> > genius. When I used machine language, I wanted an assembler. When I
> > got assembler (later on in my first computer science class) I debugged
> > a Fortran compiler in machine language. When I got Fortran and later
> > Cobol, I wanted Pascal. When I got Pascal, I wanted C in order to
> > short-circuit. And when I got C I realized I needed OO, so I got OO
> > VB .Net. When I got that, I wanted a C like syntax and so I got C
> > Sharp and Java. In other words, I don't sit around with my head up my
> > ass.
>
> In my opinion, truly competent programmers try to choose the best
> tool for the job, where "best" is determined by a number of factors.

No, "best" is determined by correctness, the programming manifestation
of truth. Whereas "a number of factors" usually includes peer group
and management pressure to conform to a normalized deviance. The
pretense is that this is a form of engineering, but if it is, it's
self-reflexive, which means that the "skilled" programmer in such a
milieu is the least ethical, and the most willing to act in ways that
are either self-destructive (as in the frequent phenomenon of
excessive hours) or destructive to others (as in the case of Peter
Seebach, who manages to lie about people, frequently).


>
> I do.  You say you do.  Beginners often don't, and the evidence

Snide, as always, in the passive aggressive corporate register. This
just in, honey. In a "civil" conversation, phrases which imply
dishonesty (such as "you say you do") cross the line, and are an
invitation, sugar, to end the civil, Habermasian conversation. As
such, they are far worse than the usual corporate suspects, such as
"sexism", babe.

>
> The difficulty here is not that one has finitely many bits to work
> with.  People who don't know what the real problem is are apt to
> think that representing currency amounts as doubles is a good idea.
> Perhaps you wouldn't make this mistake, but many people do.

(Sigh) (Eye roll) (Crotch grab)

> I don't understand what distinction you're making here; to me it
> seems obvious that one cannot claim to be a competent programmer
> without understanding that most (all?) tools have limitations,
> and a prudent programmer informs himself, or herself ....

I'm tired of the tool metaphor, and paraprogrammers who rise out of
the mechanical sort and who overuse the "software as tool" or
"computer as car" metaphor. These people shouldn't do serious
development and shouldn't waste my time.

If I were in charge of the world, and ain'tcha glad I am not, my
examination for prospective programmers would resemble the Imperial
(Chinese) civil service examination. I would expect the candidates to
be able to write poetry. I get more and more serious and less and less
humorous about this as the years go by.
>
> Not in so many words, no.  If I misunderstood you -- ah well.

Shit happens, right, doll?
>
> You seem to be saying that one should not bother to write code as
> portably as possible.  I don't agree.  But even if I did -- again,

Quite the opposite, I'd say. Why code for Linux all the time? It's
basically (cf Lanier's book) just a copy of unix, based on the work of
an author other than the millionaire Torvaldys whose work was stolen
by Torvaldys much as MS-DOS was stolen. The same sleaze and inferior
praxis occurs in both communities.

> Oh, and that comment about writing code for embedded systems --
> aren't there different rules (about the signature of main()) for
> free-standing and hosted implementations anyway?

Which means, of course, that the Linux expectation should not control,
get it yet?
>
> I don't agree.  It's one more thing that would have to be changed if
> one ever wanted to port the code to a platform on which the return
> value mattered.

Which exposes the main() return bullshit for what it is (why is it not
permitted on the Internet to say "fuck" and "shit" but it's ok to make
a foul, if misspelled, word out of Herb's patronym? Have human beings
ceased to matter? Fuck me if I know.)

It is the false belief, powered in fact by a corporation which remains
one of the most powerful, if most obscure, forces on the planet: good
old IBM, which continues to maintain control of computers that really,
really matter (vast server farms and secret data bases), that we can,
after all, force all the technopeasants into one tribe dominated by
Linux and wikipedia.

Back to 1984...

<snip>

> Why?  Isn't it more polite to take your word for it that you got it
> right at wordpress, even though you got it wrong here?

Point taken.

<snip>
>
> It's not so much that it's an error as that it's one you seem to make
> often, hence an additional clue that this might be quoted text.

Is it an error? And, of course, orthography and pronunciation, as
opposed to grammar and style, are the usual refuge of the half-
literate.

>
> Again -- I really don't care that much about spelling errors, though
> I usually do notice them.  I've explained elsethread why I initially
> mentioned yours.

You care enough to keep bothering me.
>
> The thing that's amusing here, or ironic, or something, is that
> for me the fact that your writing is for the most part free of the
> more obvious kinds of errors lends it a credibility it otherwise
> might not have.

The meaning of my literacy is that more more intelligent and more
decent than most people here. In fact, this has been pointed out in
numerous "performance reviews" in which the subtle message was that my
intelligence was out of scale in the dumbed-down corporate world, as
was my outspokenness and even decency. My female coworker at Bell
Northern Research was told that she was "too good" for the "dog eat
dog corporate world".

<snip>
>
> Well, you never know.  One thing I figured out a long time ago is
> that some people come across as being smarter than they actually
> are, by virtue of being articulate and self-confident, while others
> who are actually very bright fly under the radar, so to speak.

This is an urban legend. In fact, Dijkstra's test for programming
competence included a degree of literacy which most Americans, even
formally educated ones, no longer have. Corporations, however, select
for low but acceptable literacy because highly literate people tend to
get uppity.

You can't be mute and unsung, and a Milton, all your life. Sooner or
later, it's time to fuck or walk. I'd be the first to applaud Peter if
he ever said anything truly intelligent.

> Which group I'm in -- oh, I think it's all relative anyway.
> Certainly I've worked with people who are intellectually out of my
> league, and with others who are probably no smarter but somehow get
> more done.  I've also on occasion worked with people about whom I
> think "how is it possible for anyone to be this dim?"  <shrug>
>
> I do find it amusing to speculate about what you would make of my
> educational and other credentials, given that you seem to regard
> your good grades and Schildt's degrees as reliable indicators of --
> something.  But since I'm not willing to post them here, for reasons
> that seem good to me, it's a moot point, I guess.

In the absence of other information, "good grades" and Schildt's MSCS
are in fact all that separates us from the barbarism of *les ancien
regimes*, in which careers were not open to talents, and in which
people were beaten for even thinking of speaking out. I've had it up
to here with the Populism of claiming that one's own poor grades
indicate in themselves that it is "the system" which is at fault,
because white programmers like Seebach use poor school performance or
the absence of coursework so consistently paradoxically as to make
their gesture meaningless. They mean that they are of the race
expected to do well and that any information or any failure to the
contrary is a conspiracy against their Genius.

As a result, a new *ancien regime* is formed of people with money and
their henchmen selected according to class background and race by
"human resources" departments, and careers are once more closed to
talents.

If Seebach manifested Ben Bacarisse's talent, I would be the first to
waive my expectations as an MA was waived on my behalf in 1973 and I
taught logic at university level. But he does not, and this realigns
the evidence against him.

<snip>

>
> > I'm not making this shit up, luv.
>
> Again with the patronizing forms of address ....  Knock it off,
> would you?

Not until you start showing more solidarity with the victims of the
cybernetic mobs that so frequently form in this newsgroup owing to
enabling language expressed in dulcet tones, hon.

"Patronizing forms of address" are not a matter of syntax, but of
intent, and it is a form of fashionable autism to judge another's
sexism by means of keywords alone. I refuse to allow you to make any
inferences about my sexism for essentially the same reason I refuse to
allow Seebach to make inferences about what Schildt knows based on his
own, very limited and very biased, knowledge.

Language, in this and many other newsgroups, is used so often
ironically by chattering ape-men who in a truly bizarre fashion have a
cargo cult theory that words mean single things. They use it to lie
and then they hold others to the truth.

My sexism is ironic. Real malice, of the sort shown Kenny, Navia,
Schildt, Chinese visitors and myself, as well as competent female
programmers, is my concern here.

>
> > The New York Times did a followup circa 1997 of the Princeton computer
> > science fe-male
>
> Okay, I guess I'm going to ask -- why the hyphen?

A deliberate affectation.
>
> > contingent class of '87 to find that all of them had
> > been driven by the pressure of working with assholes like Seebach and
> > Heathfield, into teaching and other skirt occupations.
>
> The _Times_ mentioned Seebach and Heathfield?  Wow.  (Yes, yes, you
> almost surely didn't mean to imply that -- or at least not that they
> did so by name.)

Finding Dumb and Dumber interpretations as a way of critiquing writing
is a poor way of improving anyone's writing.

>
> I can believe that things have gotten worse in the years since I
> left "industry" to pursue an advanced degree.  For what it's worth,
> my decision to do that had nothing to do with the kind of people
> I was working with at the time, though -- they were almost without
> exception both capable and collegial.  Again, it's probable that I
> was lucky in that regard.  Just sayin', maybe.  As for why I took
> a teaching job rather than going back to industry -- I thought I'd
> enjoy teaching, and the academic-job lifestyle, and on the whole
> I have.

I am not saying that Seebach at his worksite is not collegial and
capable in proportion to expectations which have been dumbed-down. In
fact, he has a nice blogpost on how not to be an asshole at work.

The problem is that "work" is so obviously a laager, which is marked
off, and that outside this line (as in my examples elsethread of what
happens to the laid-off, and Seebach's somewhat Ted Bundy like
persona) the artificial constraints on expression at work issue in
deviance, here out of control bullying.

<snip>

> > Tu quoque is the favorite argument of criminals,
>
> I don't agree that I'm making a "tu quoque" argument; I'm making
> a point about what I perceive as -- oh, "hypocrisy" is too strong
> a word, I suppose, but I can't think of a milder one.

Well how about "I like making tu quoque arguments?"

>
<snip>


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c?hl=en

To unsubscribe from this group, send email to comp.lang.c+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate