any other language can do these?
It was argued that <== would be more logical that <= thus C being crappy and i agree.
The response to that?
Does any other language do things in this fasion?
No matter how you turn it, this is not the point.
1. Do people agree? (i do not agree that C is crappy)
2. What do we do about it? (problems arent fun if you dont try to find a solution)
The response to that?
Does any other language do things in this fasion?
No matter how you turn it, this is not the point.
1. Do people agree? (i do not agree that C is crappy)
2. What do we do about it? (problems arent fun if you dont try to find a solution)
This was supposed to be a cool signature...
My point is that <=, >=, == et al are used in MANY different programming languages and not just C. That's what I'm taking exception to.Back to the +=. In C you don't use = for comparison, right? You just use it for assignment, right? Not really. In the following operators = is used for assignment:
=
+=
-=
*=
/=
%=
>>=
<<=
&=
|=
^=
In the following operators = is used for comparison:
<=
>=
!=
If == means equal and < means less than, less than or equal would be <==. If += means add and assign, <= should mean compare to less and assign.
To me, this statement does not make sense. Can someone elaborate on this statement? "Compare to less and assign"--assign what? o.0<= should mean compare to less and assign.
This right here is my reasoning at why they did not do this. It simply has no meaning.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
neon: c.f.
Might be equivalent to
- possibly? That's my interpretation. It's unintuitive and is not an often used construct anyway...
seeing "<=" my initial (mathematical) interpretation is "Less than", "equal to", which when put together make "less than or equal to" in my head.
Code: Select all
mov eax, [a]
mov ebx, [b]
cmp eax, ebx
cmovl [a], eax
Code: Select all
a <= b;
seeing "<=" my initial (mathematical) interpretation is "Less than", "equal to", which when put together make "less than or equal to" in my head.
I see what you mean, but then again i can come up with many "(?)=" that wouldnt make sence.neon wrote:To me, this statement does not make sense. Can someone elaborate on this statement? "Compare to less and assign"--assign what? o.0<= should mean compare to less and assign.
This right here is my reasoning at why they did not do this. It simply has no meaning.
This was supposed to be a cool signature...
-
- Member
- Posts: 368
- Joined: Sun Sep 23, 2007 4:52 am
Why would assume that? It wasn't. It was in comparison with how good it COULD have been. It's not in comparison to any other language. It's not my fault that you read something I didn't write.JamesM wrote:No, the initial point was a rant (by Craze Frog, not you) about how terrible C is. I would assume this was in comparison with other current languagesZacariaz wrote:It is not of any importants how things are done currently, what is the subject of this part of the discussion is whether it can be done better, and i believe it can.JamesM wrote:Please name me an imperative programming language that does not use the '=' character in both assignment and comparison (with the obvious exception of bash (-eq) ).
Besides you're asking for an imperative programming langugage that does not use the '=' for both comparison and assignment. Firstly, the answer is obvious: Fortran 77.
Second: I want to use = for both comparison and assignment. In C, I can't! Only for some comparisons. That does not make sense.
In which case please state clearly that you are bashing all current languages and not just C. The context in which you spoke suggested this, ahem, 'problem', was identified in C alone. Please speak more clearly to avoid getting people's backs up.
Oh man. Sweet. I wish my kernel looked like that... :S :S :S
or that every comparison operator have an '=' in it?
Because if you meant the first, that removes a power of C:
It's not my fault you can't remember to put '==' instead of '='! They're two different operations, thus it seems logical that two different operators be used.
If you meant the second, why? It reads more logically to have:
'a < b' : a is less than b
'a <= b' : a is lessthan or equal to b
JamesM
Code: Select all
PROGRAM EUCLID
PRINT *, 'A?'
READ *, NA
IF (NA.LE.0) THEN
PRINT *, 'A must be a positive integer.'
STOP
END IF
PRINT *, 'B?'
READ *, NB
IF (NB.LE.0) THEN
PRINT *, 'B must be a positive integer.'
STOP
END IF
PRINT *, 'The GCD of', NA, ' and', NB, ' is', NGCD(NA, NB), '.'
STOP
END
I still don't understand you. Do you mean you want to use '=' as the equality operator? likeSecond: I want to use = for both comparison and assignment. In C, I can't! Only for some comparisons. That does not make sense.
Code: Select all
int a = 3;
if (a = 3) print("foo");
Because if you meant the first, that removes a power of C:
Code: Select all
if (!(stream = fopen(<bleh>))) exit(1);
If you meant the second, why? It reads more logically to have:
'a < b' : a is less than b
'a <= b' : a is lessthan or equal to b
JamesM
-
- Member
- Posts: 368
- Joined: Sun Sep 23, 2007 4:52 am
No, I said it's logical that '==' means "test for equality" in ANY situation, and '=' means "assign the value of" in ANY situation. I still think you don't quite comprehend what you're saying...You say that it's logical that == means equality in one situation and = means equality in some other situation. That's simply not logical no matter how you turn it.
EDIT: I take back completely what I said above (2 posts or so above). There I apologised (sort of), saying I had thought you were bashing C in particular for this 'problem', when it happens you weren't.
Well, I've just read your blog post, and I put it back out there - *what other language doesn't use the '<=' operator in comparisons?* (that is currently used).
Enjoy the comment I posted on there, the addendums you added in your blog post obviously show either how (1) stupid you are or (2) young and inexperienced. Either way you piss me off.
One of the reasons C has both = and == operators is for readability. We can quickly note what this is doing just by its operators.Second: I want to use = for both comparison and assignment. In C, I can't! Only for some comparisons. That does not make sense.
Here is an extreme example. What is easier to read for you?
a:
Code: Select all
if ( (a = (b == 1) ? 0 : 1) == 1) {
if (c == 0)
c = 1;
}
Code: Select all
if ( (a = (b = 1) ? 0 : 1) = 1) {
if (c = 0)
c = 1;
}
![Smile :)](./images/smilies/icon_smile.gif)
The point here is that there are valid reasons why the developers of a language do things. If you do not like the language, don't use it--use something else instead. No one forces you to use C or C++.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Not to mention, could you imagine the logic bombs you would get if the Language had to guess what you meant when you used a common operand? sometimes it would be easy like inside a descision loop, but in an optimized statement it would be nearly impossible to guess what you wanted where.
Getting back in the game.
-
- Member
- Posts: 368
- Joined: Sun Sep 23, 2007 4:52 am
Yes, that's logical, but it's not how it works in C.JamesM wrote:No, I said it's logical that '==' means "test for equality" in ANY situation, and '=' means "assign the value of" in ANY situation. I still think you don't quite comprehend what you're saying...You say that it's logical that == means equality in one situation and = means equality in some other situation. That's simply not logical no matter how you turn it.
But it is...Craze Frog wrote:Yes, that's logical, but it's not how it works in C.JamesM wrote:No, I said it's logical that '==' means "test for equality" in ANY situation, and '=' means "assign the value of" in ANY situation. I still think you don't quite comprehend what you're saying...You say that it's logical that == means equality in one situation and = means equality in some other situation. That's simply not logical no matter how you turn it.
C8H10N4O2 | #446691 | Trust the nodes.