I think these are a couple of cases where c got it wrong.
The C syntax allows the combination of assignment + logic test into one statement.
No, the compiler will warn you that unreachable code was detected. The whitespace is irrelevant to the token parser. The last line in that example can never be reached, and modern compilers can detect this. And some environments will even do this within the editor before you ever try to compile (for example Resharper addon for Visual Studio).
QuoteThe C syntax allows the combination of assignment + logic test into one statement.
That's what I mean, they made a mistake by allowing it. Obviously this is my point of view, but I doubt I am the only person who thinks this.
It has led to lots of confusion and I am sure lots of errors, for the sake of what? To save a bit of typing, are there any other reasons why you want this?
That's what I mean, they made a mistake by allowing it.
It has led to lots of confusion and I am sure lots of errors, for the sake of what?
Like they say: language doesn't make mistakes; stupid programmers do.
/* Create SFN in directory form */
mem_set(dj->fn, ' ', 11);
for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */
if (si) cf |= NS_LOSS | NS_LFN;
while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */
b = i = 0; ni = 8;
for (;;) {
w = lfn[si++]; /* Get an LFN char */
if (!w) break; /* Break on end of the LFN */
if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */
cf |= NS_LOSS | NS_LFN; continue;
}
if (i >= ni || si == di) { /* Extension or end of SFN */
if (ni == 11) { /* Long extension */
cf |= NS_LOSS | NS_LFN; break;
}
if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */
if (si > di) break; /* No extension */
si = di; i = 8; ni = 11; /* Enter extension section */
b <<= 2; continue;
}
if (w >= 0x80) { /* Non ASCII char */
#ifdef _EXCVT
w = ff_convert(w, 0); /* Unicode -> OEM code */
if (w) w = cvt[w - 0x80]; /* Convert extended char to upper (SBCS) */
#else
w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */
#endif
cf |= NS_LFN; /* Force create LFN entry */
}
if (_DF1S && w >= 0x100) { /* Double byte char */
if (i >= ni - 1) {
cf |= NS_LOSS | NS_LFN; i = ni; continue;
}
dj->fn[i++] = (BYTE)(w >> 8);
} else { /* Single byte char */
if (!w || chk_chr("+,;[=]", w)) { /* Replace illegal chars for SFN */
w = '_'; cf |= NS_LOSS | NS_LFN; /* Lossy conversion */
} else {
if (IsUpper(w)) { /* ASCII large capital */
b |= 2;
} else {
if (IsLower(w)) { /* ASCII small capital */
b |= 1; w -= 0x20;
}
}
}
}
dj->fn[i++] = (BYTE)w;
}
if (dj->fn[0] == 0xE5) dj->fn[0] = 0x05; /* If the first char collides with deleted mark, replace it with 0x05 */
if (ni == 8) b <<= 2;
if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */
cf |= NS_LFN;
if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended char, NT flags are created */
if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */
if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */
}
dj->fn[NS] = cf; /* SFN is created */
return FR_OK;
At least Madires gave me an answer to a question that I was wondering. It's not a mistake , it's a consistent syntax. If we allow the usage of some expressions just in a specific context we would limit the syntax and we would have to learn about those exceptions. Another one would then complain why he doesn't may use a specific expression in a specific context and call that a mistake.
QuoteLike they say: language doesn't make mistakes; stupid programmers do.Conveniently ignore the question and resort to abuse.
Look I would love not to use C but it is not practical. I don't even dislike C but how many times to you see a crock of shit written by some of these very clever C programmers, with 5 layers of macros and 100s of warnings. Cant be bothered typing decent names for variables.
Stupid code from a not stupid programmer.
but trying to find debug in this sort of stuff is hard.
Oh dear, Elm Chan's FAT library
except the forth point, where I would say c programmers seem to have a mentality that if you can do 5 things in one line and name your variables in the most abbreviated form possible then the code will run faster.
with 5 layers of macros and 100s of warnings.
where I would say c programmers seem to have a mentality that if you can do 5 things in one line and name your variables in the most abbreviated form possible then the code will run faster.
Stupid code from a not stupid programmer. Look I realise it is hard to write widely used libraries, but trying to find debug in this sort of stuff is hard.
Not really understanding the Python hate, just set your editor to insert spaces as tabs @ 4 spaces and I've never had any issues. I actually like the whitespace because it forces consistency which is more important to me than whatever coding standards you are using.
That's what I mean, they made a mistake by allowing it.The whole design of C revolves around allowing you to make mistakes and leaving it to the programmer to decide.
.....
I live with the consequences of my decision.

QuoteI live with the consequences of my decision.
PASCAL: I am the government, and I am here to help.
I liked D when I looked at it last (about a year ago), but as for compilers, it was in a sorry state. The GCC plugin was massively out of date (IIRC only compatible with D 1.0) and the other compiler only ran on a few platforms and was closed-source.
Looks like some of that has changed now. I just downloaded the source for the main compiler, but the license terms are ambiguous. (The main license.txt says "this is not open source" and all of the individual files I've opened claim to be GPL / "Artistic license", and even some under the Boost Software License) The compiler comes in a 64-bit binary version now, but I'm not sure if it will actually compile a 64- bit binary.
It looks like a lot of progress has been made since then, though. I think I may take another look at this.