473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Are C pitfalls the mistake of standard or that of implementations ?

Hi,
We see that C is a bit liberal towards non-standard syntax,
for e.g. when i tried
<printf("string1", "string2 %d", v1);> in Dev-C++, it printed string1
and no error was raised, is this the mistake of standard or the
implementation (Dev-C++).
I was under the impression that the implementations could have been
better by implementing proper rules and adhering to the standard (ANSI
C) at the same time, for e.g., in the above case i was assuming that
the standard would have specified something like "an implementation
MUST provide printf("string where % is special char..", var1,..);". Now
a good implementor could have implemented this along with an error chek
to see the user code strictly adheres to that format and raise an error
if not (my e.g., above).
But, many implementations, even popular ones don't seem to do this.
What do u opine? People who have read the actual Standard can throw
some light on the specification in the standard.

Greenhorn.

Nov 14 '05 #1
41 1896

Greenhorn wrote:
Hi,
We see that C is a bit liberal towards non-standard syntax,
for e.g. when i tried
<printf("string1", "string2 %d", v1);> in Dev-C++, it printed string1
and no error was raised, is this the mistake of standard or the
implementation (Dev-C++).
I was under the impression that the implementations could have been
better by implementing proper rules and adhering to the standard (ANSI C) at the same time, for e.g., in the above case i was assuming that
the standard would have specified something like "an implementation
MUST provide printf("string where % is special char..", var1,..);". Now a good implementor could have implemented this along with an error chek to see the user code strictly adheres to that format and raise an error if not (my e.g., above).
But, many implementations, even popular ones don't seem to do this.
What do u opine? People who have read the actual Standard can throw
some light on the specification in the standard.

Greenhorn.

If you invoke undefined behaviour, any implementation can do anything
with your program. In others words "if you don't follow the rules,
anything can happen, and this 'anything' can be different for any
implementation"

Nov 14 '05 #2
In article <11**********************@f14g2000cwb.googlegroups .com>,
Greenhorn <te************@yahoo.com> wrote:
: We see that C is a bit liberal towards non-standard syntax,
:for e.g. when i tried
:<printf("string1", "string2 %d", v1);> in Dev-C++, it printed string1
:and no error was raised, is this the mistake of standard or the
:implementation (Dev-C++).

Neither. There is no requirement in the definition of printf()
that all of the value arguments need to be "consumed" by the printf().

:I was under the impression that the implementations could have been
:better by implementing proper rules and adhering to the standard (ANSI
:C) at the same time, for e.g., in the above case i was assuming that
:the standard would have specified something like "an implementation
:MUST provide printf("string where % is special char..", var1,..);".

I don't understand that last bit. There is nothing in the standard
that requires that the first argument to printf() have a % format
specifier.

:Now
:a good implementor could have implemented this along with an error chek
:to see the user code strictly adheres to that format and raise an error
:if not (my e.g., above).

It isn't an error. Some compilers will warn about it, as will 'lint'.
--
If a troll and a half can hook a reader and a half in a posting and a half,
how many readers can six trolls hook in six postings?
Nov 14 '05 #3
"Greenhorn" <te************@yahoo.com> writes:
We see that C is a bit liberal towards non-standard syntax,
for e.g. when i tried
<printf("string1", "string2 %d", v1);> in Dev-C++, it printed string1
and no error was raised, is this the mistake of standard or the
implementation (Dev-C++).


This is the correct behavior. It is usually a mistake, so better
C implementations will warn about it, if you turn on that
feature. GCC is an example of an implementation that will do so.
--
"When I have to rely on inadequacy, I prefer it to be my own."
--Richard Heathfield
Nov 14 '05 #4
Walter Roberson wrote:

If a troll and a half can hook a reader and a half in a posting and a half,
how many readers can six trolls hook in six postings?


I make it 24. I stand ready to be corrected.
Nov 14 '05 #5
Greenhorn wrote:
Hi,
We see that C is a bit liberal towards non-standard syntax,
for e.g. when i tried
<printf("string1", "string2 %d", v1);> in Dev-C++, it printed string1
and no error was raised, is this the mistake of standard or the
implementation (Dev-C++).
I was under the impression that the implementations could have been
better by implementing proper rules and adhering to the standard (ANSI
C) at the same time, for e.g., in the above case i was assuming that
the standard would have specified something like "an implementation
MUST provide printf("string where % is special char..", var1,..);". Now
a good implementor could have implemented this along with an error chek
to see the user code strictly adheres to that format and raise an error
if not (my e.g., above).
But, many implementations, even popular ones don't seem to do this.
What do u opine? People who have read the actual Standard can throw
some light on the specification in the standard.


The issue is that the compiler can't necessarily see what you are
passing to printf, and it doesn't really care, either, as printf is a
library function and not an operator. Think of the following things:

1) the format string given to printf could also be a generated value, in
which case the compiler would not even be able to see what it is
2) printf is a library function, so someone could switch it out with
something that has different functionality, but the compiler wouldn't be
aware, and would generate errors even when there were none.
3) The call signature of printf is printf(char *format, ...). This
means that by its call signature, ANY number of parameters (except zero)
are LEGAL, even if the results aren't defined or useful. This is a
limitation of the C language, as this is a limitation of the way C
function prototypes work.

Jon
----
Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017
Nov 14 '05 #6
Jonathan Bartlett wrote:

3) The call signature of printf is printf(char *format, ...).


Minor nit: const char *format
Nov 14 '05 #7
I agree that any implementation can do anything, y not leverage on that
and try to raise warnings and errors when that is not expected in that
form. for e.g., i am guessing that ANSI standard doesn't say something
like "no errors are to be raised when printf("blah bhal.. is used".
which means an implementation can raise error (atleast a warning).
Ofcourse, some implementations use warnings as a proper tool.

Greenhorn

Kenneth Bull wrote:
Greenhorn wrote:
Hi,
We see that C is a bit liberal towards non-standard syntax,
for e.g. when i tried
<printf("string1", "string2 %d", v1);> in Dev-C++, it printed string1 and no error was raised, is this the mistake of standard or the
implementation (Dev-C++).
I was under the impression that the implementations could have been
better by implementing proper rules and adhering to the standard

(ANSI
C) at the same time, for e.g., in the above case i was assuming that the standard would have specified something like "an implementation
MUST provide printf("string where % is special char..", var1,..);".

Now
a good implementor could have implemented this along with an error

chek
to see the user code strictly adheres to that format and raise an

error
if not (my e.g., above).
But, many implementations, even popular ones don't seem to do this.
What do u opine? People who have read the actual Standard can throw
some light on the specification in the standard.

Greenhorn.

If you invoke undefined behaviour, any implementation can do anything
with your program. In others words "if you don't follow the rules,
anything can happen, and this 'anything' can be different for any
implementation"


Nov 14 '05 #8
I agree that any implementation can do anything, y not leverage on that
and try to raise warnings and errors when that is not expected, say in
an expression. For e.g., i am guessing that ANSI standard doesn't say
something like "no errors are to be raised when printf("blah bhal.. is
used" which means an implementation can raise error (atleast a
warning). Ofcourse, some implementations use warnings as a proper tool.

Greenhorn

Kenneth Bull wrote:
Greenhorn wrote:
Hi,
We see that C is a bit liberal towards non-standard syntax,
for e.g. when i tried
<printf("string1", "string2 %d", v1);> in Dev-C++, it printed string1 and no error was raised, is this the mistake of standard or the
implementation (Dev-C++).
I was under the impression that the implementations could have been
better by implementing proper rules and adhering to the standard

(ANSI
C) at the same time, for e.g., in the above case i was assuming that the standard would have specified something like "an implementation
MUST provide printf("string where % is special char..", var1,..);".

Now
a good implementor could have implemented this along with an error

chek
to see the user code strictly adheres to that format and raise an

error
if not (my e.g., above).
But, many implementations, even popular ones don't seem to do this.
What do u opine? People who have read the actual Standard can throw
some light on the specification in the standard.

Greenhorn.

If you invoke undefined behaviour, any implementation can do anything
with your program. In others words "if you don't follow the rules,
anything can happen, and this 'anything' can be different for any
implementation"


Nov 14 '05 #9
is it 6.

Nov 14 '05 #10
Greenhorn wrote:

I agree that any implementation can do anything, y not leverage on that


In c.l.c. and most other newsgroups, PLEASE DO NOT TOPPOST. Your
answer belongs after (or intermixed with) the material you are
quoting, after snipping out anything not germane to your reply.

Also, do not use silly one letter abbreviations for English words.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #11
Greenhorn wrote:
Hi,
We see that C is a bit liberal towards non-standard syntax,
for e.g. when i tried
<printf("string1", "string2 %d", v1);> in Dev-C++, it printed string1
and no error was raised, is this the mistake of standard or the
implementation (Dev-C++).
I was under the impression that the implementations could have been
better by implementing proper rules and adhering to the standard (ANSI
C) at the same time, for e.g., in the above case i was assuming that
the standard would have specified something like "an implementation
MUST provide printf("string where % is special char..", var1,..);". Now
a good implementor could have implemented this along with an error chek
to see the user code strictly adheres to that format and raise an error
if not (my e.g., above).
But, many implementations, even popular ones don't seem to do this.
What do u opine? People who have read the actual Standard can throw
some light on the specification in the standard.

Greenhorn.


If you use the lcc-win32 compiler (and other compilers as well)
you get:
D:\lcc\mc63\test>type tpr.c
#include <stdio.h>
int main(void)
{
int v1=7;
printf("string1", "string2 %d", v1);
}

D:\lcc\mc63\test>lc tpr.c
Warning tpr.c: 5 printf: too many arguments
0 errors, 1 warnings

D:\lcc\mc63\test>

Nov 14 '05 #12
jacob navia wrote:

<snip>
D:\lcc\mc63\test>lc tpr.c
Warning tpr.c: 5 printf: too many arguments
0 errors, 1 warnings


Consider:

fprintf(stderr,
"%u error%s, %u warning%s\n",
count_errs,
(count_errs == 1) ? "" : "s",
count_warns,
(count_warns == 1) ? "" : "s");
Nov 14 '05 #13
infobahn <in******@btinternet.com> wrote:
Walter Roberson wrote:

If a troll and a half can hook a reader and a half in a posting and a half,
how many readers can six trolls hook in six postings?


I make it 24. I stand ready to be corrected.


Somewhere in the thousands. Trolls have an exponentiating influence on
eachother.

Richard
Nov 14 '05 #14
infobahn wrote:
jacob navia wrote:
<snip>
D:\lcc\mc63\test>lc tpr.c
Warning tpr.c: 5 printf: too many arguments
0 errors, 1 warnings

Consider:

fprintf(stderr,
"%u error%s, %u warning%s\n",
count_errs,
(count_errs == 1) ? "" : "s",
count_warns,
(count_warns == 1) ? "" : "s");


There are no errors in there. If you modify it
slightly:

D:\lcc\mc63\test>type tpr1.c
#include <stdio.h>
int main(void)
{
int count_errs=2,count_warns = 67;

fprintf(stderr,
"%u error%s, %u warning%s\n",
count_errs,
(count_errs == 1) ? 4 : 8, // error in here
count_warns,
(count_warns == 1) ? "" : "s");
}

D:\lcc\mc63\test>lc tpr1.c
Warning tpr1.c: 11 fprintf argument mismatch for format s. Expected
char pointer got int
0 errors, 1 warnings

D:\lcc\mc63\test>
I do not think that lcc-win32 has *all* possible cases in store. The
evaluation of an argument could be of indeterminate type, etc.

BUT

Just because you can't catch 100% of the cases, this doesn't
justify catching 0% and doing nothing. If you get 95% of the errors
it is still much better than nothing!
Nov 14 '05 #15
On Wed, 09 Feb 2005 09:27:19 +0100, jacob navia
<ja***@jacob.remcomp.fr> wrote:
infobahn wrote:
jacob navia wrote:

<snip>
D:\lcc\mc63\test>lc tpr.c
Warning tpr.c: 5 printf: too many arguments
0 errors, 1 warnings


Consider:

fprintf(stderr,
"%u error%s, %u warning%s\n",
count_errs,
(count_errs == 1) ? "" : "s",
count_warns,
(count_warns == 1) ? "" : "s");


There are no errors in there. If you modify it
slightly:


Correct, there are no errors in that statement. The error is in your
compiler, and the code snippet is one way to fix it (altering the
variables to suit).

Hint: is one plural?

Chris C
Nov 14 '05 #16
Chris Croughton wrote:

On Wed, 09 Feb 2005 09:27:19 +0100, jacob navia
<ja***@jacob.remcomp.fr> wrote:
infobahn wrote:
jacob navia wrote:

<snip>

D:\lcc\mc63\test>lc tpr.c
Warning tpr.c: 5 printf: too many arguments
0 errors, 1 warnings

Consider:

fprintf(stderr,
"%u error%s, %u warning%s\n",
count_errs,
(count_errs == 1) ? "" : "s",
count_warns,
(count_warns == 1) ? "" : "s");


There are no errors in there. If you modify it
slightly:


Correct, there are no errors in that statement. The error is in your
compiler, and the code snippet is one way to fix it (altering the
variables to suit).

Hint: is one plural?


Chris: Jacob's (*cough*) reply hasn't hit my server yet, so thanks
for setting him straight.

Sometimes I despair of humanity, I really do.
Nov 14 '05 #17
Richard Bos wrote:
infobahn <in******@btinternet.com> wrote:
Walter Roberson wrote:

If a troll and a half can hook a reader and a half in a posting
and a half, how many readers can six trolls hook in six postings?


I make it 24. I stand ready to be corrected.


Somewhere in the thousands. Trolls have an exponentiating influence
on eachother.


They closely resemble flies gathering around a dead fish.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #18
infobahn <in******@btinternet.com> writes:

Chris: Jacob's (*cough*) reply ..

Do never cast the return value of reply.
--
/myr

Nov 14 '05 #19
Espen Myrland <Th***************************@toycompute.net> scribbled the following:
infobahn <in******@btinternet.com> writes:
Chris: Jacob's (*cough*) reply ..
Do never cast the return value of reply.


This would have been funnier if *cough* was proper syntax for a C type.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"O pointy birds, O pointy-pointy. Anoint my head, anointy-nointy."
- Dr. Michael Hfuhruhurr
Nov 14 '05 #20

Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Espen Myrland
infobahn <in******@btinternet.com> writes:
Chris: Jacob's (*cough*) reply ..

Do never cast the return value of reply.


This would have been funnier if *cough* was proper syntax for a C type.

Yess. I know. I first removed it and then put it back.
regards,

--
espen
Nov 14 '05 #21

"Chris Croughton" <ch***@keristor.net> wrote in message
news:sl******************@ccserver.keris.net...
jacob navia wrote: D:\lcc\mc63\test>lc tpr.c
Warning tpr.c: 5 printf: too many arguments
0 errors, 1 warnings

Correct, there are no errors in that statement. The error is in your
compiler, and the code snippet is one way to fix it (altering the
variables to suit).

Hint: is one plural?


Took me a while to get your point. However I think that is a little unfair.
I'm using an MS OS which (with their thousands of staff and tens of billions
of pounds) is still sprinkled with "1 Files", "1 Folders" and so on. Maybe
the idea of having just ONE file might be alien to them.

My own efforts are better behaved but sometimes dealing with multi-languages
means plurals are not that straightforward. But no excuse for MS though.

Bart


Nov 14 '05 #22
On Wed, 9 Feb 2005 15:40:50 +0000 (UTC), infobahn
<in******@btinternet.com> wrote:
Chris Croughton wrote:

Correct, there are no errors in that statement. The error is in your
compiler, and the code snippet is one way to fix it (altering the
variables to suit).

Hint: is one plural?
Chris: Jacob's (*cough*) reply hasn't hit my server yet, so thanks
for setting him straight.


De nada. The message "1 errors" and friends is one of my bugbears, it
indicates to me that the code is not production quality (it's those
little touches which make the difference in Real World(tm) programs
between being bought and being ignored).
Sometimes I despair of humanity, I really do.


Only sometimes? Well, you're young, you have lots of despair ahead of
you <g>...

Chris C
Nov 14 '05 #23
Bart C wrote:
"Chris Croughton" <ch***@keristor.net> wrote in message
news:sl******************@ccserver.keris.net...

jacob navia wrote:
D:\lcc\mc63\test>lc tpr.c
>Warning tpr.c: 5 printf: too many arguments
>0 errors, 1 warnings

Correct, there are no errors in that statement. The error is in your
compiler, and the code snippet is one way to fix it (altering the
variables to suit).

Hint: is one plural?

Took me a while to get your point. However I think that is a little unfair.
I'm using an MS OS which (with their thousands of staff and tens of billions
of pounds) is still sprinkled with "1 Files", "1 Folders" and so on. Maybe
the idea of having just ONE file might be alien to them.

My own efforts are better behaved but sometimes dealing with multi-languages
means plurals are not that straightforward. But no excuse for MS though.

Bart

Me too <grin> it took me a while to get your point...
I thought at first sight that you were saying that when
a complex expression appeared as an argument of printf
the compiler would fail...

Well, yesssssss, the customer is always right but now my compiler
says:

0 error, 1 warning

It should be

0 errors, 1 warning isn't it?

Or should I drop the message if there is only one
error? Actually it doesn't make sense to summarize
the error/warning count when there is only one isn't it?

Etc, etc...
Nov 14 '05 #24
On Wed, 9 Feb 2005 18:36:57 -0000, Bart C
<bc@freeuk.com> wrote:

"Chris Croughton" <ch***@keristor.net> wrote in message
news:sl******************@ccserver.keris.net...
jacob navia wrote:D:\lcc\mc63\test>lc tpr.c
>Warning tpr.c: 5 printf: too many arguments
>0 errors, 1 warnings
Correct, there are no errors in that statement. The error is in your
compiler, and the code snippet is one way to fix it (altering the
variables to suit).

Hint: is one plural?


Took me a while to get your point. However I think that is a little unfair.
I'm using an MS OS which (with their thousands of staff and tens of billions
of pounds) is still sprinkled with "1 Files", "1 Folders" and so on.


I rest my case, it's a prime example of crapness <g>.
Maybe
the idea of having just ONE file might be alien to them.
They've done it since early PCDOS times, when often there was only one
file on the floppy...
My own efforts are better behaved but sometimes dealing with multi-languages
means plurals are not that straightforward. But no excuse for MS though.


Yes, i18n is more of a problem. The solution is similar, though, you
just need to put the whole words in the conditionals:

printf("%d %s\n", number,
number == 1 ? gettext("file") : gettext("files"));

(or something like that).

Chris C
Nov 14 '05 #25
On Wed, 09 Feb 2005 20:59:27 +0100, jacob navia
<ja***@jacob.remcomp.fr> wrote:
Well, yesssssss, the customer is always right but now my compiler
says:

0 error, 1 warning

It should be

0 errors, 1 warning isn't it?
Correct. In most western European languages at least the only singular
number is one, zero is regarded as gramatically plural (I don't know
much about middle- and far-eastern languages, nor about those native to
the American and Pacific areas).

<OT>
Most W.E. languages except English have a construct which translates as
"isn't it?" which is often appended to sentences: "n'est pas", "nicht
wahr", etc. English seems to have largely dropped that construct...
</OT>
Or should I drop the message if there is only one
error? Actually it doesn't make sense to summarize
the error/warning count when there is only one isn't it?


I don't mind seeing something like:

0 errors, 0 warnings

but Unix-like utilities have traditionally not displayed anything at all
for 'success', only for failure (except of course for utilities the
purpose of which is to produce output to the user).

Chris C
Nov 14 '05 #26
In article <sl******************@ccserver.keris.net>,
Chris Croughton <ch***@keristor.net> wrote:
On Wed, 9 Feb 2005 18:36:57 -0000, Bart C
<bc@freeuk.com> wrote:

"Chris Croughton" <ch***@keristor.net> wrote in message
news:sl******************@ccserver.keris.net...
> jacob navia wrote:

>>D:\lcc\mc63\test>lc tpr.c
>>Warning tpr.c: 5 printf: too many arguments
>>0 errors, 1 warnings

Correct, there are no errors in that statement. The error is in your
compiler, and the code snippet is one way to fix it (altering the
variables to suit).

Hint: is one plural?


Took me a while to get your point. However I think that is a little unfair.
I'm using an MS OS which (with their thousands of staff and tens of billions
of pounds) is still sprinkled with "1 Files", "1 Folders" and so on.


I rest my case, it's a prime example of crapness <g>.
Maybe
the idea of having just ONE file might be alien to them.


They've done it since early PCDOS times, when often there was only one
file on the floppy...
My own efforts are better behaved but sometimes dealing with multi-languages
means plurals are not that straightforward. But no excuse for MS though.


Yes, i18n is more of a problem. The solution is similar, though, you
just need to put the whole words in the conditionals:

printf("%d %s\n", number,
number == 1 ? gettext("file") : gettext("files"));

(or something like that).


This depends very much on the language you are using. English is
relatively simple. Different languages treat the number zero
differently; in some languages it would be "0 file", in others it would
be "0 files". Some languages have different words for 0, 1, and many. In
some languages it depends on the last digit: It would be "101 file", but
"102 files". And there are probably rules when to use words instead of
digits ("one file", not "1 file").

Now to make things a bit more complicate, try to write code that prints
"1st file", "2nd file" and so on correctly for arbitrary numbers. Then
try to investigate the rules for different languages. Have fun.
Nov 14 '05 #27


Chris Croughton wrote:
[...]
Yes, i18n is more of a problem. The solution is similar, though, you
just need to put the whole words in the conditionals:

printf("%d %s\n", number,
number == 1 ? gettext("file") : gettext("files"));


Long ago my Latin teacher grew impatient with our
constant grumbling at trying to memorize the ten forms
of every noun, thirty forms of every adjective, and 120-odd
forms of every verb. We didn't know how lucky we were,
said he, because if we'd been studying Greek the job would
have been roughly fifty percent harder. Whenever a Latin
word had singular and plural forms, Greek had singular and
dual (exactly two) and plural (three or more) forms ...

Q1: Can any Greek speakers vouch for my old Latin
teacher's assertion? (He may have been kidding us.)

Q2: If I mistake not, gettext() would have a hard
time with this situation because the mapping of distinct
dual and plural Greek words to a single English plural
would be non-invertible.

--
Er*********@sun.com

Nov 14 '05 #28
Chris Croughton wrote:
but Unix-like utilities have traditionally not displayed anything at all
for 'success', only for failure (except of course for utilities the
purpose of which is to produce output to the user).


lcc-win32 doesn't print anything if there are no errors
and no warnings. The objective is when you have a lot of
warnings but no errors to avoid having to look up all the
output to see if there is an error...

OK now it is:
if (errcnt > 0 || warningCount > 0) {
printf("%d error%s, %d warning%s", errcnt,
(errcnt != 1) ? "s" : "",
warningCount, warningCount != 1 ? "s":"");
}

Small improvement but wothwhile.

Thanks for the tip :-)
Nov 14 '05 #29
jacob navia wrote:
"Chris Croughton" <ch***@keristor.net> wrote in message
news:sl******************@ccserver.keris.net...
Hint: is one plural?

<snip>
[...] it took me a while to get your point...
Review the thread to find out who actually made the point.

<snip>
Well, yesssssss, the customer is always right but now my compiler
says:

0 error, 1 warning


Then you didn't implement correctly the code I showed you. (Note
that I am neither Chris nor Bart.)

Did you really really really write a compiler? Furrfu.
Nov 14 '05 #30
Chris Croughton wrote:

The message "1 errors" and friends is one of my bugbears, it indicates
to me that the code is not production quality (it's those
little touches which make the difference in Real World(tm) programs
between being bought and being ignored).


It might mean that the author needs to translate the error messages
automatically with something like gettext (more precisely, switch
automatically between multiple human-written translations) and can't
sensibly do plurals without wasting too much of his time on what is, in
the end, a very minor issue.

In other words, people who make judgments like that without context get
bitten by their own smugness.
Nov 14 '05 #31
CBFalconer wrote:

They closely resemble flies gathering around a dead fish.


Are you saying that the regulars here are dead fish?

;)

--
Thomas.
Nov 14 '05 #32

On Thu, 10 Feb 2005, Chris Barts wrote:

Chris Croughton wrote:
The message "1 errors" and friends is one of my bugbears, it indicates to
me that the code is not production quality (it's those
little touches which make the difference in Real World(tm) programs
between being bought and being ignored).


It might mean that the author needs to translate the error messages
automatically with something like gettext (more precisely, switch
automatically between multiple human-written translations) and can't sensibly
do plurals without wasting too much of his time on what is, in the end, a
very minor issue.


No, I don't see that. I don't agree that such a minor defect would make
the difference between "being bought and being ignored," but neither would
I consider a program that printed "1 errors" really production-quality.
(Conclusion: I think a lot of people buy software that is not
production-quality.)
Sure, it might be a defect whose root cause was the laziness of the
gettext programmer or user, rather than the laziness of a hand-coding
programmer, but it's still a glaringly obvious defect that shouldn't
have slipped through testing.
If the project absolutely must use some gettext-like system that doesn't
support English plurals, then the obvious solution (to me) would be

Errors: 0
Warnings: 1

-Arthur
Nov 14 '05 #33
On Thu, 10 Feb 2005 00:55:20 +0100, jacob navia
<ja***@jacob.remcomp.fr> wrote:
Chris Croughton wrote:
but Unix-like utilities have traditionally not displayed anything at all
for 'success', only for failure (except of course for utilities the
purpose of which is to produce output to the user).
lcc-win32 doesn't print anything if there are no errors
and no warnings. The objective is when you have a lot of
warnings but no errors to avoid having to look up all the
output to see if there is an error...


Of course, if there was an error you still have to locate it amongst all
of the warnings...

There is a philosophical split between Unix types, who like to have no
output at all for success, and those used to Certain Other Systems who
like explicit confirmation of success ("Look, you got it right!").
OK now it is:
if (errcnt > 0 || warningCount > 0) {
printf("%d error%s, %d warning%s", errcnt,
(errcnt != 1) ? "s" : "",
warningCount, warningCount != 1 ? "s":"");
}

Small improvement but wothwhile.
Yup. As I said, it's something which indicates to many people
(including me) that the implementor has actually thought about it rather
than just shoving anything in. I feel the same about estimated time
displays which are broken (MS are prime culprits there as well), it's not
difficult to get right...
Thanks for the tip :-)


No problem. Anything which makes me less unhappy <g>...

Chris C
Nov 14 '05 #34

In article <sl******************@ccserver.keris.net>, Chris Croughton <ch***@keristor.net> writes:
On Wed, 09 Feb 2005 20:59:27 +0100, jacob navia
<ja***@jacob.remcomp.fr> wrote:
Well, yesssssss, the customer is always right but now my compiler
says:

0 error, 1 warning

It should be

0 errors, 1 warning isn't it?
Correct. In most western European languages at least the only singular
number is one, zero is regarded as gramatically plural (I don't know
much about middle- and far-eastern languages, nor about those native to
the American and Pacific areas).


Some of those don't even have gramatical number. Likely there are
many variations, which is an argument for not trying to handle
grammatical number in messages. Even dealing only with languages
that follow the English pattern (one inflection for singular, used
only with 1; another for plural, used with all other values) you
have to store two message templates for each language - the singular
and the plural version. More if there are multiple values (as there
are here). You can't cover all the languages with a rule like
"pass either "s" or "" for parameter N depending on the value of
parameter N-1"; there's no guarantee that will form the correct
plural in every language.

I think the best option is to avoid grammatical number entirely,
by not making the numeric value part of the phrase proper:

Number of errors: 0. Number of warnings: 1.
<OT>
Most W.E. languages except English have a construct which translates as
"isn't it?" which is often appended to sentences: "n'est pas", "nicht
wahr", etc. English seems to have largely dropped that construct...
</OT>


Depends on dialect, no? I frequently see, and occasionally employ, a
simple "no?" in this manner. "doesn't it?" and "isn't it?" are
common in at least some parts of the US (I've heard them from
speakers from the coasts, for example). In some Carribean dialects
"seen?" is used this way. There are other forms in other dialects.

In the spirit of posting meaningless statistics to Usenet, I note that
a quick Google search showed 57 uses of the appended "doesn't it?" in
the past 24 hours' Usenet posts.

Of course it's quite possible that such usage is rare in the dialects
you most frequently encounter.

--
Michael Wojcik mi************@microfocus.com

HTML is as readable as C. You can take this either way. -- Charlie Gibbs
Nov 14 '05 #35

In article <cu**********@news1brm.Central.Sun.COM>, Eric Sosman <er*********@sun.com> writes:

Long ago my Latin teacher grew impatient with our
constant grumbling at trying to memorize the ten forms
of every noun, thirty forms of every adjective, and 120-odd
forms of every verb. We didn't know how lucky we were,
said he, because if we'd been studying Greek the job would
have been roughly fifty percent harder. Whenever a Latin
word had singular and plural forms, Greek had singular and
dual (exactly two) and plural (three or more) forms ...

Q1: Can any Greek speakers vouch for my old Latin
teacher's assertion? (He may have been kidding us.)
According to my handy Greek textbook, the dual form is "obsolescent
in classical Greek, though frequent in Homer". I'm not sure what
exactly they mean by "classical Greek" here.

The text also notes that in Attic Greek the dual is sometimes used
for "natural pairs" (a pair of hands and such) but "other words in
agreement with [a noun in the dual] are sometimes found in the
plural".
Q2: If I mistake not, gettext() would have a hard
time with this situation because the mapping of distinct
dual and plural Greek words to a single English plural
would be non-invertible.


Yes, clearly there can't be a one-to-one mapping from two numbers
to three. :-)

I can see ancient Greek would be a bit of trouble. For nouns and
adjectives you have two or three numbers (singular, plural, maybe
dual); three genders (masculine, feminine, neuter); and five cases
(nominative, genitive, dative, accusative, vocative). There are
three declensions (forms of the combinations of the above), plus
some irregulars. For adverbs and pronouns you have five cases, but
they're different from those for nouns (interrogative, indefinite,
demonstrative, relative, and indefinite relative / indirect
interrogative).

And verbs are tough. The book gives the "complete paradigm" for
one omega-verb (one of the standard verb forms): it goes on for
five pages, showing several hundred forms. (And why not? You
wouldn't want to use just anything for a passive first aorist
optative second-person plural. Someone might get confused.)

--
Michael Wojcik mi************@microfocus.com

Company Secretary Finance Manager
1) Half-grey haired executives.
2) Must be waist-deep in their field of activities.
3) Must be having the know-how and the do-how of the latest
developments in their respective fields.
-- from "Appointments Vacant" section of Business India
Nov 14 '05 #36
jacob navia wrote:
Chris Croughton wrote:
but Unix-like utilities have traditionally not displayed anything
at all for 'success', only for failure (except of course for
utilities the purpose of which is to produce output to the user).


lcc-win32 doesn't print anything if there are no errors
and no warnings. The objective is when you have a lot of
warnings but no errors to avoid having to look up all the
output to see if there is an error...

OK now it is:
if (errcnt > 0 || warningCount > 0) {
printf("%d error%s, %d warning%s", errcnt,
(errcnt != 1) ? "s" : "",
warningCount, warningCount != 1 ? "s":"");
}


I would avoid all that foofaraw with:

if (errcnt || warningCount)
printf("Errors : %d, Warnings : %d\n" errcnt, warningCount);

EOGH (end of grammar hassles)

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #37
mw*****@newsguy.com (Michael Wojcik) wrote:
In article <cu**********@news1brm.Central.Sun.COM>, Eric Sosman <er*********@sun.com> writes:

Long ago my Latin teacher grew impatient with our
constant grumbling at trying to memorize the ten forms
of every noun, thirty forms of every adjective, and 120-odd
forms of every verb. We didn't know how lucky we were,
said he, because if we'd been studying Greek the job would
have been roughly fifty percent harder. Whenever a Latin
word had singular and plural forms, Greek had singular and
dual (exactly two) and plural (three or more) forms ...

Q1: Can any Greek speakers vouch for my old Latin
teacher's assertion? (He may have been kidding us.)

It's worse. There are at least six past tenses, and you're expected to
know them all. When I heard about that, I dropped it like a hot potato,
and kept Latin.
According to my handy Greek textbook, the dual form is "obsolescent
in classical Greek, though frequent in Homer". I'm not sure what
exactly they mean by "classical Greek" here.


I presume Greek as spoken in the classical period; that is, roughly
around the Persian and Pelepponesian wars. Most of the great classic
authors wrote during that period, beginning with Aischylos and ending
with Xenophon. Homer was a couple of centuries earlier, and was
considered historical and old-fashioned (but highly important) already.

Richard
Nov 14 '05 #38
CBFalconer <cb********@yahoo.com> writes:
jacob navia wrote:

[...]
OK now it is:
if (errcnt > 0 || warningCount > 0) {
printf("%d error%s, %d warning%s", errcnt,
(errcnt != 1) ? "s" : "",
warningCount, warningCount != 1 ? "s":"");
}


I would avoid all that foofaraw with:

if (errcnt || warningCount)
printf("Errors : %d, Warnings : %d\n" errcnt, warningCount);

EOGH (end of grammar hassles)


If you don't have to worry about internationalization, the
(errcnt != 1) ? "s" : ""
approach makes sense -- but it's likely that you will have to worry
about it some day.

It might make sense for an internationalization package to provide
a function like
char *plural(char *word, int count);
plural("Error", 2) would return "Errors" for English, something using
the grammatical dual number for pre-classical Greek, and do forth.
(Managing storage for the returned string is left as an exercise.)

This doesn't help much if you want to write "There was 1 error"
vs. "There were 2 errors".

Probably the folks in comp.software.international (which I've never
read) would have a lot more to say about this.

--
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.
Nov 14 '05 #39
"Thomas Stegen" <th***********@gmail.com> wrote in message
news:37*************@individual.net...
CBFalconer wrote:

They closely resemble flies gathering around a dead fish.


Are you saying that the regulars here are dead fish?


White bellies up, heads in the C...

And WHAT is that SMELL?!!

--
Mabden
Nov 14 '05 #40
"Chris Croughton" <ch***@keristor.net> wrote in message
news:sl******************@ccserver.keris.net...
On Thu, 10 Feb 2005 00:55:20 +0100, jacob navia
<ja***@jacob.remcomp.fr> wrote:

OK now it is:
if (errcnt > 0 || warningCount > 0) {
printf("%d error%s, %d warning%s", errcnt,
(errcnt != 1) ? "s" : "",
warningCount, warningCount != 1 ? "s":"");
}

Small improvement but wothwhile.


Not everything wothwhile is woth doing...

--
Mabden
Nov 14 '05 #41
"Richard Bos" <rl*@hoekstra-uitgeverij.nl> wrote in message
news:42****************@news.individual.net...
mw*****@newsguy.com (Michael Wojcik) wrote:
In article <cu**********@news1brm.Central.Sun.COM>, Eric Sosman <er*********@sun.com> writes:

Long ago my Latin teacher grew impatient with our
constant grumbling at trying to memorize the ten forms
of every noun, thirty forms of every adjective, and 120-odd
forms of every verb. We didn't know how lucky we were,
said he, because if we'd been studying Greek the job would
have been roughly fifty percent harder. Whenever a Latin
word had singular and plural forms, Greek had singular and
dual (exactly two) and plural (three or more) forms ...

Q1: Can any Greek speakers vouch for my old Latin
teacher's assertion? (He may have been kidding us.)

It's worse. There are at least six past tenses, and you're expected to
know them all. When I heard about that, I dropped it like a hot

potato, and kept Latin.
According to my handy Greek textbook, the dual form is "obsolescent
in classical Greek, though frequent in Homer". I'm not sure what
exactly they mean by "classical Greek" here.
I presume Greek as spoken in the classical period; that is, roughly
around the Persian and Pelepponesian wars. Most of the great classic
authors wrote during that period, beginning with Aischylos and ending
with Xenophon. Homer was a couple of centuries earlier, and was
considered historical and old-fashioned (but highly important)

already.


I guess one should just be born there and learn it from their mother's
teat. A time machine and a vial of sperm should do the job...

--
Mabden
Nov 14 '05 #42

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mantorok Redgormor | last post by:
Should I just avoid them? I have heard many bad things about them 1) if you set a signal handler, you can't really ignore the signal and continue with normal program execution, because after that...
11
by: bjrnove | last post by:
Hi. Me and a friend have a discussion about main. In my opinion the legal ways of writing main is: int main(void); int main(int,char**); My friend claims that you also have a standard...
85
by: fermineutron | last post by:
Some compilers support __asm{ } statement which allows integration of C and raw assembly code. A while back I asked a question about such syntax and was told that __asm is not a part of a C...
27
by: Simon Biber | last post by:
The following Example 3 is given in the 1999 C standard for the function fscanf: I have tested several implementations and none of them get the last case right. In no case does fscanf return 0...
4
by: dustin | last post by:
I've been hacking away on this PEP for a while, and there has been some related discussion on python-dev that went into the PEP: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.