comp.lang.c - 25 new messages in 9 topics - digest
comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en
Today's topics:
* Idiotic programming style edicts - 8 messages, 5 authors
http://groups.google.com/group/comp.lang.c/t/99bc3aa427fc7518?hl=en
* Has thought been given given to a cleaned up C? Possibly called C+. - 3
messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/5954dc70a43f9f8e?hl=en
* Container library (continued) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/3763649cc890efcc?hl=en
* 2010 Hot sale Shox R3.R4, Shox TZ Nike Air Max 90 Air Max TN,Air Force One
For Both men and women (www.vipchinatrade.com) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/c9583fc9cbd4aa72?hl=en
* §§§ 2010 Cheap wholesale ED Hardy Suit, Baby Suit, Lacoste Suit ect at www.
rijing-trade.com <Paypal Payment> - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/e1292334d5a83b26?hl=en
* STUDY ABOUT "C" AND GET PLACEMENT - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/a7401ab50fc89123?hl=en
* Two is Enough: Breeder pleasing mostly - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/af609bb81eccfad8?hl=en
* Is it good to use char instead of int to save memory? - 5 messages, 5
authors
http://groups.google.com/group/comp.lang.c/t/40bfc7048b74630b?hl=en
* Letter sent to Apress with concerns about Peter Seebach's online behavior -
3 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/482b38643777da3c?hl=en
==============================================================================
TOPIC: Idiotic programming style edicts
http://groups.google.com/group/comp.lang.c/t/99bc3aa427fc7518?hl=en
==============================================================================
== 1 of 8 ==
Date: Wed, Mar 17 2010 11:46 pm
From: Jonathan de Boyne Pollard
>
>
> Agreed. But note that the "its value" and "plus" comments aren't
> properly terminated, so the "/*" on the "its value" line introduces a
> comment that isn't terminated until the "*/" on the "one" line. The
> net result is "x = x;"
>
Hooray! At last! Well spotted. I've been waiting to see how long it
took and how many would do so.
So not only does the mandatory comment on every line not match the
apparent code, but the apparent code isn't the actual code, as a direct
consequence of the mandatory comments.
I'm assuming that M. Shanahan either spotted this too, or would have
done so.
== 2 of 8 ==
Date: Thurs, Mar 18 2010 12:38 am
From: gazelle@shell.xmission.com (Kenny McCormack)
In article <IU.D20100318.T064845.P11663.Q2@J.de.Boyne.Pollard.localhost>,
Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.COM> wrote:
...
>As has been finally spotted, there was a subtler point in there, too.
We could play the "Who subtler now?" game until the cows come home.
The point I was making was that that's what we do in CLC.
The standard CLC thing is to pounce upon something stupid, like the
upper/lower case thing, and totally ignore real issues. It's the whole
"prototyping main()" thing, that we do so well.
--
(This discussion group is about C, ...)
Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...
== 3 of 8 ==
Date: Thurs, Mar 18 2010 12:49 am
From: Nick Keighley
On 17 Mar, 15:33, Keith Thompson <ks...@mib.org> wrote:
> "jackassp...@gmail.com" <jackassp...@gmail.com> writes:
> >> > What *is* it written in?
>
> >> [...]
>
> >> I don't recognize the language, but it was originally posted only
> >> to alt.folklore.computers. Somebody decided to add a cross-post
> >> to comp.programming and comp.lang.c and didn't bother to mention it.
>
> > pascal uses := as an assignment operator
>
> But it doesn't use ; to introduce a comment.
>
> Of course, the code could have been incorrect.
scheme uses ; as a comment- but of course doesn't look anything like
the above
== 4 of 8 ==
Date: Thurs, Mar 18 2010 12:46 am
From: Jonathan de Boyne Pollard
>
>>
>> Such edicts make one want to write code in the form
>>
>> x /* The variable x */
>> = /* is assigned */
>> x /* its value * /
>> + /* plus * /
>> 2 /* one */
>> ; /* . */
>>
> This sort of thing is one of the strongest arguments for *always*
> editing and viewing code in an editor with syntax highlighting for the
> source language. The problem and the reason why the compiler would
> accept the code both become glaringly obvious.
>
That's a good point. And there's more of it. Had I posted this to
several places other than Usenet, that syntax colouring would have been
right there in the posting itself. Had I written it, for example, on a
MediaWiki wiki (with the appropriate extensions), simply placing the
code within a <syntaxhighlight> HTML element (with the language set to C
or C++) would have revealed the problem. One can envisage a future
extension to HTML where the <code> element causes browser-side syntax
colouring. There are already places where it causes server-side syntax
colouring. Stack Overflow is one such. Again, had I posted the snippet
in a Stack Overflow Q&A thread, within a <code> element, it would have
been automatically coloured, showing the extent of the comment.
A text/plain bodypart in a Usenet posting doesn't have such a
capability, of course.
We're probably all aware of the extra problems that posting to Usenet
introduces into code, including posting mechanisms that introduce
mandatory line wrap, some of which (Step forward, Google Groups.) not
only provide no mechanism for inhibiting line wrapping but don't even
let the poster know ahead of time where the line wrapping will actually
be, which can play havoc with "C++-style" comments. This is a case of
posting to Usenet helping to make a problem more difficult to spot than
it would be in (some) editors, on (some) wikis, and on some WWW
programming discussion fora.
== 5 of 8 ==
Date: Thurs, Mar 18 2010 12:49 am
From: Ahem A Rivet's Shot
On 17 Mar 2010 18:58:00 GMT
scott@slp53.sl.home (Scott Lurndal) wrote:
> Eric Chomko <pne.chomko@comcast.net> writes:
> >On Mar 17, 9:33=A0am, Ahem A Rivet's Shot <ste...@eircom.net> wrote:
> >> On Wed, 17 Mar 2010 07:03:43 -0500
> >>
> >> jmfbahciv <jmfbahciv@aol> wrote:
> >> > Jonathan de Boyne Pollard wrote:
> >> > > Such edicts make one want to write code in the form
> >>
> >> > > =A0 =A0 x =A0/* The variable x */
> >> > > =A0 =A0 =3D =A0/* is assigned */
> >> > > =A0 =A0 x =A0/* its value * /
> >> > > =A0 =A0 + =A0/* plus * /
> >> > > =A0 =A0 2 =A0/* one */
> >> > > =A0 =A0 ; =A0 /* . */
> >>
> >> > And would make all tapes spill over to two magtapes.
> >>
> >> > Fortunately, your code would produce many detected errors.
> >>
> >> =A0 =A0 =A0 =A0 Nope that's perfectly valid C code - provided that x
> >> is d=
> >eclared in
> >> scope.
> >>
> >
> >Isn't "in scope" redundant here? I mean scope only applies to binding
> >time, no? Locals vs. globals vs. non-locals which are not global,
> >etc. But I agree the code is fine from the stand point of the
> >compiler.
>
> except for the two occurances of '* /' instead of '*/'.
They don't stop it from being fine from the point of view of the
compiler - they just add another dimension of the comments being wrong.
--
Steve O'Hara-Smith | Directable Mirror Arrays
C:>WIN | A better way to focus the sun
The computer obeys and wins. | licences available see
You lose and Bill collects. | http://www.sohara.org/
== 6 of 8 ==
Date: Thurs, Mar 18 2010 12:47 am
From: Ahem A Rivet's Shot
On Wed, 17 Mar 2010 07:14:43 -0700
Patricia Shanahan <pats@acm.org> wrote:
> Ahem A Rivet's Shot wrote:
> > On Wed, 17 Mar 2010 07:03:43 -0500
> > jmfbahciv <jmfbahciv@aol> wrote:
> >
> >> Jonathan de Boyne Pollard wrote:
> >
> >>> Such edicts make one want to write code in the form
> >>>
> >>> x /* The variable x */
> >>> = /* is assigned */
> >>> x /* its value * /
> >>> + /* plus * /
> >>> 2 /* one */
> >>> ; /* . */
> >>>
> >> And would make all tapes spill over to two magtapes.
> >>
> >> Fortunately, your code would produce many detected errors.
> >
> > Nope that's perfectly valid C code - provided that x is
> > declared in scope.
> >
>
> This sort of thing is one of the strongest arguments for *always*
> editing and viewing code in an editor with syntax highlighting for the
> source language.
I do.
> The problem and the reason why the compiler would
> accept the code both become glaringly obvious.
The spaces between the * and / in two carefully selected spaces ?
They're not problems they're part of the charm of the example.
--
Steve O'Hara-Smith | Directable Mirror Arrays
C:>WIN | A better way to focus the sun
The computer obeys and wins. | licences available see
You lose and Bill collects. | http://www.sohara.org/
== 7 of 8 ==
Date: Thurs, Mar 18 2010 5:27 am
From: jmfbahciv
Jonathan de Boyne Pollard wrote:
>>
>>>>
>>>> In our shop, those appeared when we got the idiotic edict that each
>>>> line had to have a comment.
>>>>
>>> Such edicts make one want to write code in the form
>>>
>>> x /* The variable x */
>>> = /* is assigned */
>>> x /* its value * /
>>> + /* plus * /
>>> 2 /* one */
>>> ; /* . */
>>>
>> And would make all tapes spill over to two magtapes.
>>
>> Fortunately, your code would produce many detected errors.
>>
> You might think that, but the reality appears to be that that is untrue.
>
<grin> My language is MACRO-10. JMF was always tickled whenever he
assembled some code because MACRO would report a "successful"
assembly with the comment "No errors detected". Think about it. ;-)
/BAH
== 8 of 8 ==
Date: Thurs, Mar 18 2010 5:28 am
From: jmfbahciv
Nick Keighley wrote:
> On 17 Mar, 12:07, jmfbahciv <jmfbahciv@aol> wrote:
>> Nick Keighley wrote:
>>> On 16 Mar, 18:13, gaze...@shell.xmission.com (Kenny McCormack) wrote:
>>>> In article <IU.D20100316.T165150.P1185...@J.de.Boyne.Pollard.localhost>,
>>>> Jonathan de Boyne Pollard <J.deBoynePollard-newsgro...@NTLWorld.COM> wrote:
>>>>>>> If an obscure technique is being employed, then a comment to that
>>>>>>> effect is a helpful pointer but I have seen _REALLY USEFUL_ comments
>>>>>>> along the following lines ...
>>>>>>> x := X + 1 ; increment x
>>>> A true CLC pedantic would point out that the above does not increment x
>>>> (unless x and X have the same value).
>>> it plainly isn't C. Perhaps in whatever-it-is-written-in cares about
>>> case.
>
> doh!
> ///doesn't care about case///
>
>
>>> What *is* it written in?
>>>>>>> ... which only serve to increase the noise floor.
>>>>>> In our shop, those appeared when we got the idiotic edict that each
>>>>>> line had to have a comment.
>>>>> Such edicts make one want to write code in the form
>>>>> x /* The variable x */
>>>>> = /* is assigned */
>>>>> x /* its value * /
>>>>> + /* plus * /
>>>>> 2 /* two */
>>>>> ; /* . */
>>>> Correction applied. HTH.
>>> #include "crlzyzz.h" /* obvious meaning */
>>> if it's obvious, why did you comment it?
>> Now that one may have usefulness :-). If it's not
>> obvious to the reader, then a search for the author
>> or his/her specs is in order.
>
> to beat him about the head and shoulders with
>
>
Before you do that, finding out the intent of the code is
valuable.
/BAH
==============================================================================
TOPIC: Has thought been given given to a cleaned up C? Possibly called C+.
http://groups.google.com/group/comp.lang.c/t/5954dc70a43f9f8e?hl=en
==============================================================================
== 1 of 3 ==
Date: Thurs, Mar 18 2010 1:07 am
From: Nick Keighley
On 16 Mar, 22:22, "Bartc" <ba...@freeuk.com> wrote:
> Keith Thompson wrote:
> > "Rod Pemberton" <do_not_h...@havenone.cmm> writes:
> >> Binary only works well, IMO.
binary and text mode work fine if you apply them appropriately
> > Unless you need to handle text, of course. And no, manually handling
> > the '\r' and '\n' characters is not a good solution, especially if
> > your code might ever be ported to a system with a different text file
> > format.
you've got a problem whatever mode you use if you port text files
between platforms.
> Even considering only systems using CR, CR/LF, or LF, C's text mode can go
> wrong: reading in a file created on a computer with a different newline
> sequence, or writing a text file on this computer and reading it on one
> using a different sequence.
so you convert it... Binary mode doesn't solve the problem.
> And then there are hybrid files which are mainly binary data, but also
> contain embedded text that can include newline characters.
not a text file. You'll have to have some way of detecting the text
bits and then writing your own parser.
> Which means that
> binary data that looks like CR/LF gets converted to LF (and the entire file
> shrinks in size by one byte), or vice versa.
and?
> I suspect people who advocate text mode tend to use machines with a single
> character newline, and simply don't see the problems it creates when newline
> is multiple characters.
I'd have thought the opposite. Its the unix people who don't really
understand text mode (becasue they don't need it). Its the DOS people
who understand text mode (because the do need it). You are aware that
C's i/o library hides the double character EOL sequence from the
application?
== 2 of 3 ==
Date: Thurs, Mar 18 2010 2:57 am
From: "bartc"
Nick Keighley wrote:
> On 16 Mar, 22:22, "Bartc" <ba...@freeuk.com> wrote:
>> Keith Thompson wrote:
>>> "Rod Pemberton" <do_not_h...@havenone.cmm> writes:
>
>>>> Binary only works well, IMO.
>
> binary and text mode work fine
I know binary does.
> if you apply them appropriately
Oh I see: if you work around the problems...
>> Even considering only systems using CR, CR/LF, or LF, C's text mode
>> can go wrong: reading in a file created on a computer with a
> so you convert it... Binary mode doesn't solve the problem.
I haven't figured out how to do that, without a detailed knowledge of either
source or destination format.
And if I knew how (and when), I wouldn't need to convert...
>> I suspect people who advocate text mode tend to use machines with a
>> single character newline, and simply don't see the problems it
>> creates when newline is multiple characters.
>
> I'd have thought the opposite. Its the unix people who don't really
> understand text mode (becasue they don't need it).
I was suggesting the advocates were mainly using the newline=LF systems, in
other words, text mode = binary mode. Ie. in line with your comment.
> You are aware that C's i/o library hides the double character EOL sequence
> from the
> application?
I was aware it doesn't do a good job. Although if files are only ever
processed serially, a character at a time, then it's workable.
I had a problem once where I was outputting a string containing embedded
CRLF sequences via printf(). The output became CRLFLF (on my machine). When
redirected to a file, it caused some programs to go wrong.
(Why was CRLF embedded? I was calling C's printf() from a language which
chose not to abstract away the machine's newline sequence. Now maybe C's
printf() should only be called from actual C source code, but C is popular
for helping build other languages on top of it. Why should these languages
then have C's quirks with newline imposed on them too?
To solve this, I had to call some function or other which set stdout to
binary mode.)
--
Bartc
== 3 of 3 ==
Date: Thurs, Mar 18 2010 3:57 am
From: "bartc"
Keith Thompson wrote:
> "Bartc" <bartc@freeuk.com> writes:
>> Keith Thompson wrote:
>>> In your hypothetical C without "function forward declarations", how
>> Many here seem to be confusing forward declarations, with external
>> declarations.
> That's why I asked Richard D to explain just what *he's* proposing.
I think *I* may have been confused by the fact that forward declarations,
and external declarations, look exactly identical in C.
I touched on this in "Name Spaces" in my post on eyebrow-raisers elsewhere
this thread.
Apparently this is how declarations at filescope (ie. outside functions)
work in C:
int fn(int);
EITHER: If fn() is defined later on: this is a Global function
which is exported from this module, and visible to all others.
OR: if fn() is not defined here, this is a Global function which
is imported from another module.
int abc;
Global variable, ie. shared across all modules.If this happens to
be already in use, at filescope in another module about which
you might know nothing about, then it will clash!
And if the variable is initialised, you can't initialise it in a shared
header, because then each module will attempt to initialise it's
copy.
static int fn(int);
Local function declared later in this module
static int abc;
Variable directly visible only in this module.
typedefs, structs, enums, #defines
Are always local to this module. To share across modules, duplicate
in those other modules. Then the other modules will think they are
local to *them*. Since no runtime resources are involved, this doesn't
matter.
To summarise, I would say that to an outsider, it looks a bit of a mess.
--
Bartc
==============================================================================
TOPIC: Container library (continued)
http://groups.google.com/group/comp.lang.c/t/3763649cc890efcc?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Mar 18 2010 1:26 am
From: Nick Keighley
On 17 Mar, 15:36, Seebs <usenet-nos...@seebs.net> wrote:
> On 2010-03-17, jacob navia <ja...@nospam.org> wrote:
> > You misunderstand. I am not trying to invent a new way of doing
> >those things. I am trying to invent a generalized standard way
> >of doing that in C. This has never been done before for C.
>
> It's been done repeatedly, except for the "standard" part.
>
> I honestly don't think that generalizing to "container" is going to be
> useful in C. In a language that doesn't have meaningful inheritance,
> it's very unusual for this kind of approach to get widespread adoption.
> I think you'd do better to make a list library and a hash library,
> for instance.
C++ doesn't use inheritance in its container classes. Having seen
inheritance based conatiner classes I tend to think its the wrong
mechanism.
==============================================================================
TOPIC: 2010 Hot sale Shox R3.R4, Shox TZ Nike Air Max 90 Air Max TN,Air Force
One For Both men and women (www.vipchinatrade.com)
http://groups.google.com/group/comp.lang.c/t/c9583fc9cbd4aa72?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Mar 18 2010 1:47 am
From: tradenow
Cheap Wholesale Shox NZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox OZ <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox R2 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R3 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R3+R4 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R4 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R5 <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox Reverie lover
Cheap Wholesale Shox RZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox TL <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox Torch <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox TZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Nike Air Max 87 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 89 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 90 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 91 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 92 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 93 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 95 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 97 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 180 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 2006 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 2009 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max Clssic BW <www.vipchinatrade.com> free
shipping
Cheap Wholesale Nike Air Max LTD <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max Skyline <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max STAB <www.vipchinatrade.com> free
shipping
Cheap Wholesale Nike Air Max Tailwind <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max TN <www.vipchinatrade.com> paypal
payment
Air Force one <www.vipchinatrade.com> paypal payment
Cheap Wholesale Air Force One Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One M&W <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one 25 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One 25 Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One Kid <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Mid Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Mid Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Hight Women <www.vipchinatrade.com>
paypal payment
==============================================================================
TOPIC: §§§ 2010 Cheap wholesale ED Hardy Suit, Baby Suit, Lacoste Suit ect at
www.rijing-trade.com <Paypal Payment>
http://groups.google.com/group/comp.lang.c/t/e1292334d5a83b26?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Mar 18 2010 1:49 am
From: "www.fjrjtrade.com"
§§§ 2010 Cheap wholesale ED Hardy Suit, Baby Suit, Lacoste Suit ect at
www.rijing-trade.com <Paypal Payment>
Cheap wholesale Suite
Cheap wholesale Baby Suit
Cheap wholesale Puma Suit
Cheap wholesale Adidas Suit
Cheap wholesale ED Hardy Suit
Cheap wholesale Juicy Women Suit
Cheap wholesale Lacoste Man Suit
Cheap wholesale NBA Man Suit
Cheap wholesale Nike Man Suit
More details at website:
http://www.rijing-trade.com
==============================================================================
TOPIC: STUDY ABOUT "C" AND GET PLACEMENT
http://groups.google.com/group/comp.lang.c/t/a7401ab50fc89123?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Mar 18 2010 2:57 am
From: lal <3ennel.0569@gmail.com>
http://123maza.com/75/expressions
== 2 of 2 ==
Date: Thurs, Mar 18 2010 2:58 am
From: lal <3ennel.0569@gmail.com>
http://123maza.com/75/expressions
==============================================================================
TOPIC: Two is Enough: Breeder pleasing mostly
http://groups.google.com/group/comp.lang.c/t/af609bb81eccfad8?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Mar 18 2010 4:30 am
From: gazelle@shell.xmission.com (Kenny McCormack)
In article <bb1a1477-9e8b-42e5-8722-e18c76bc623d@k17g2000yqb.googlegroups.com>,
Pirate Queen <crumsypirates@yahoo.com> wrote:
>On Mar 17, 3:00 pm, gaze...@shell.xmission.com (Kenny McCormack)
>wrote:
>
>> (This discussion group is about C, ...)
>>
>> Wrong. It is only OCCASIONALLY a discussion group
>> about C; mostly, like most "discussion" groups, it is
>> off-topic Rorsharch revelations of the childhood
>> traumas of the participants...
>
>HAW! That's probably one of the most brilliant comments that I have
>heard in a damn long while.
>Kudos to you, Mr. McCormack.
Why, thank you.
CLC is, indeed, a very funny newsgroup, that actually pretends to be
about C. You should check it out.
--
(This discussion group is about C, ...)
Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...
==============================================================================
TOPIC: Is it good to use char instead of int to save memory?
http://groups.google.com/group/comp.lang.c/t/40bfc7048b74630b?hl=en
==============================================================================
== 1 of 5 ==
Date: Thurs, Mar 18 2010 4:40 am
From: dspfun
Hi,
Is it recommended to use char instead of int for variables that you
know never will contain a value larger than 255? A small example
follows:
#include <stdio.h>
int main(void)
{
//int i = 1;
char i = 1; //is this better than previous line?
printf("i=%d\n",i);
return 0;
}
What are the pros and cons of using char instead of int when values
will not exceed 255?
Brs,
Markus
== 2 of 5 ==
Date: Thurs, Mar 18 2010 4:50 am
From: Marc Boyer
Le 18-03-2010, dspfun <dspfun@hotmail.com> a écrit :
> Is it recommended to use char instead of int for variables that you
> know never will contain a value larger than 255? A small example
> follows:
>
> #include <stdio.h>
> int main(void)
> {
> //int i = 1;
> char i = 1; //is this better than previous line?
> printf("i=%d\n",i);
> return 0;
> }
>
> What are the pros and cons of using char instead of int when values
> will not exceed 255?
First, you have to use signed char or unsigned char to get portable
code, because char can be signed or not.
Second, well, it depends... On modern PC CPU, there are alignment constraints
leading common compilers to use the same amount of memory for a single
variable char and a single variable int.
But, it could be different in other contexts. For example, some collegue of
me have worked on a DSP where int and char are both 32bits values.
This is different with arrays.
int vali[1024];
char valc[1024];
In this case, valc will use less memory than vali (the ratio beeing
sizeof(char) ).
Marc Boyer
== 3 of 5 ==
Date: Thurs, Mar 18 2010 5:51 am
From: pete
dspfun wrote:
>
> Hi,
>
> Is it recommended to use char instead of int for variables that you
> know never will contain a value larger than 255? A small example
> follows:
>
> #include <stdio.h>
> int main(void)
> {
> //int i = 1;
> char i = 1; //is this better than previous line?
> printf("i=%d\n",i);
> return 0;
> }
>
> What are the pros and cons of using char instead of int when values
> will not exceed 255?
I wouldn't use types lower ranking than int,
unless they were in an array.
It is possible though not guaranteed
that operations on char types might be slower than int.
It is also possible though not guaranteed
that char type objects might be aligned on int boundaries,
meaning that the few bytes after a char type object
might not be useable.
--
pete
== 4 of 5 ==
Date: Thurs, Mar 18 2010 5:28 am
From: Dr Malcolm McLean
On 18 Mar, 11:40, dspfun <dsp...@hotmail.com> wrote:
>
> What are the pros and cons of using char instead of int when values
> will not exceed 255?
>
As others have said, you need to specify signed char or unsigned char.
Plain chars are for actual characters.
It's rare that memory is so tight that declaring a single variable as
"char" is a saving worth having, and the operation on a char might
well be slower. int is meant to be the natural integer representation
for the machine.
However if you have a large array, char might save significnat space.
The obvious example is a raster buffer for image data. Usually we
allow 8 bits per rgb channel. So an array of unsigned chars is the
obvious representation.
== 5 of 5 ==
Date: Thurs, Mar 18 2010 5:34 am
From: spinoza1111
On Mar 18, 7:40 pm, dspfun <dsp...@hotmail.com> wrote:
> Hi,
>
> Is it recommended to use char instead of int for variables that you
> know never will contain a value larger than 255? A small example
> follows:
>
> #include <stdio.h>
> int main(void)
> {
> //int i = 1;
> char i = 1; //is this better than previous line?
> printf("i=%d\n",i);
> return 0;
>
> }
>
> What are the pros and cons of using char instead of int when values
> will not exceed 255?
>
> Brs,
> Markus
I'm sure one of the regulars will be all agog to remind you that chars
don't necessarily range between 0 and 255.
Pro:
* Memory saved
* Speed IF your "digital signal processor" has hardwired character
arithmetic
* Everyone will think you're smart
Con:
* Memory lost when your "digital signal processor" does char arith by
transforming the char into an integer
* Speed in the same scenario
* Negative numbers?
* Everyone will think you're an idiot
Decision:
When all else fails, program on purpose
When the wind is out of your sails, code what you mean
A char actor is not a number, and one would suppose
That arithmetic doesn't happen between consenting chars, jellybean.
Don't get cute, don't show off:
The urge to grandstand should be blown off.
If it's a natural number be a regular guy
And use int, say I with a sigh.
==============================================================================
TOPIC: Letter sent to Apress with concerns about Peter Seebach's online
behavior
http://groups.google.com/group/comp.lang.c/t/482b38643777da3c?hl=en
==============================================================================
== 1 of 3 ==
Date: Thurs, Mar 18 2010 5:08 am
From: spinoza1111
On Mar 18, 11:57 am, Seebs <usenet-nos...@seebs.net> wrote:
> On 2010-03-18, Walter Banks <wal...@bytecraft.com> wrote:
>
> >spinoza1111wrote:
> >> But what's most troubling is your apparent record of educational
> >> failure.
> > Didn't you say that you too dropped out of University.
>
> What's interesting to me is that he assumes that there was educational
> "failure" involved. I think I failed two classes ever -- trigonometry
> (couldn't memorize things; I could never do trig until I learned enough
> calculus to derive it) and a chemistry class that was scheduled at 7:45
> AM, which I think I attended a good three or four times.
That's failure, Peter. What I find utterly reprehensible is that such
a level of failure receives "zero tolerance" in inner city high
schools yet is excused in white schools.
>
> It says a lot more about Nilges than about me that he'd assume that there
> was any kind of failure involved. I didn't say I flunked out of high
> school, only that I didn't continue taking high school classes. Similarly,
> I never said I failed college, only that I didn't do CS... Because I
> was busy doing math, philosophy, and psychology. ;)
Fine. Many early programmers had that background.
However, those early programmers:
* Developed Fortran compilers with one trip do loops
* Failed to deliver OS for the 360 on time
* Developed software for the SAGE air defense system which never,
ever worked: the Russians believed it worked, and that was used in
negotiation
* Developed what's now the content of CS classes
If you, as it appears, were born in 1970, there was no excuse for not
learning from their mistakes.
And there was less reason for you to write CTCN. You had no standing.
>
> -s
> --
> Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.nethttp://www.seebs.net/log/<-- lawsuits, religion, and funny pictureshttp://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
== 2 of 3 ==
Date: Thurs, Mar 18 2010 5:12 am
From: spinoza1111
On Mar 18, 12:17 pm, Walter Banks <wal...@bytecraft.com> wrote:
> spinoza1111wrote:
> > On Mar 18, 11:40 am, Walter Banks <wal...@bytecraft.com> wrote:
> > > spinoza1111wrote:
> > > > But what's most troubling is your apparent record of educational
> > > > failure.
>
> > > Didn't you say that you too dropped out of University.
>
> > I completed a BA and most of the work towards MSCS, but left the
> > latter program after completing most of the work with an A average. I
> > had family responsibilities.
>
> Dropout
Name calling doesn't change the facts. The fact is that like most
younger white people, Peter has benefited from the real affirmative
action of American society, which is second chances and mega tolerance
for white failure, and zero tolerance for everyone else. This becomes
contempt for teachers and authors.
And fathers, which I was when I decided to "drop out". I was working,
asshole, for a company that had a minimum work week of 45 hours and a
norm of 100. I was also teaching at adjunct level. If you want to call
this "dropping out", you can shove it up your ass.
>
> --- news://freenews.netfront.net/ - complaints: n...@netfront.net ---
== 3 of 3 ==
Date: Thurs, Mar 18 2010 5:24 am
From: spinoza1111
On Mar 18, 11:55 am, Seebs <usenet-nos...@seebs.net> wrote:
> On 2010-03-18, ImpalerCore <jadil...@gmail.com> wrote:
>
> > While you may not have finished high school or college,
>
> Oh, I finished college. I have a degree in psychology. :)
>
> > Were you pretty much self-taught, or did you have a mentor of some
> > kind? As a college guy myself, I'm curious about people who found
> > their way as a programmer through paths less traveled.
>
> I never studied CS in college, but I had the good fortune to run into
> a fairly good programmer sort (one of the authors of GNU grep, as
> it happens, more recently a CPU designer), who decided that it would be
> interesting to try to teach me how to think about computers. It appears
> to have taken.
>
> I don't know why I never took CS courses; I think it simply hadn't
> occurred to me, and anyway it was mostly obvious.
Again, how would you know? It wasn't obvious to you several years ago
that the heap is NOT a "DOS term", and that using a stack is a common
way to explain and implement a C runtime. And yo' ass don't improve
with age like a fine wine. Last month, you showed that you CANNOT
simulate strlen in an acceptable way or write a simple filter. While
such tasks do not form part of computer science theory, studying the
theory gives one skill in avoiding these types of errors.
Whereas in computer science at the level of graduate school, I did a
lot of programming which enhanced my skills:
* Polynomial arithmetic: my insight being that I could use the same
type of Cobol algorithm used in "matching and merging" two or more
sequential files (something unmastered by many Cobol programmers now
mooted by data base join operations) in matching exponents
* Writing the microcode for a DEC PDP-8 machine, which in 1978 I
carefully typed using a manual typewriter, astonishing the department
chair
* Simulating a Turing machine on a programmable calculator
* Etc.
My discovery at the time was that there was indeed a two way feedback
between my Cobol mainframe job and computer science. While I was in
grad school, my company needed someone who could match, not two, but
an arbitrary number of sequential files.
I'd fixed any number of buggy solutions written at a time when many
Cobol programmers had, relative to business programming (which
Dijkstra pointed out is not "simple"), no skill in writing such code
for two, let alone n, files, leaving any number of "off by one" and
"doesn't do the job but who gives a shit" solutions like Peter's code.
I wrote an n way match in Cobol using my experience writing the
polynomial solution.
I also discovered that stacks were not only useful at American
Re(insurance): in reinsurance they are essential. I also realized that
to properly bill customers from telecom files that recorded only
atomic events that the Cobol program needed only to simulate the
switch.
It was then I was aggressively recruited to write compilers in Silicon
Valley, and was relocated at my new employers' expense.
Peter, can you give us a better feel for some real accomplishments
beyond backstabbing?
Oh, and by the way. I also studied math, philosophy and psychology.
>
> -s
> --
> Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.nethttp://www.seebs.net/log/<-- lawsuits, religion, and funny pictureshttp://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
==============================================================================
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