Page 3 of 4

Posted: Fri Oct 05, 2007 2:53 am
by JamesM
OP: Yes, I believe pascal is (was) used extensively for kernel development. Some people here are kernel-ing in pascal, I believe.

Posted: Fri Oct 05, 2007 2:56 am
by Zacariaz
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)

Posted: Fri Oct 05, 2007 3:24 am
by JamesM
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.
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.

Posted: Fri Oct 05, 2007 4:59 am
by neon
<= 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

This right here is my reasoning at why they did not do this. It simply has no meaning.

Posted: Fri Oct 05, 2007 5:06 am
by JamesM
neon: c.f.

Code: Select all

mov eax, [a]
mov ebx, [b]
cmp eax, ebx
cmovl [a], eax
Might be equivalent to

Code: Select all

a <= b;
- 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.

Posted: Fri Oct 05, 2007 5:11 am
by Zacariaz
neon wrote:
<= 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

This right here is my reasoning at why they did not do this. It simply has no meaning.
I see what you mean, but then again i can come up with many "(?)=" that wouldnt make sence.

Posted: Fri Oct 05, 2007 5:45 am
by Craze Frog
JamesM wrote:
Zacariaz wrote:
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) ).
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.
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 languages
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.

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.

Posted: Fri Oct 05, 2007 6:16 am
by JamesM
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.

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
Oh man. Sweet. I wish my kernel looked like that... :S :S :S
Second: I want to use = for both comparison and assignment. In C, I can't! Only for some comparisons. That does not make sense.
I still don't understand you. Do you mean you want to use '=' as the equality operator? like

Code: Select all

int a = 3;
if (a = 3) print("foo");
or that every comparison operator have an '=' in it?

Because if you meant the first, that removes a power of C:

Code: Select all

if (!(stream = fopen(<bleh>))) exit(1);
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

Posted: Fri Oct 05, 2007 8:49 am
by Craze Frog
I said C because while other languages has incosistencies, C is an inconsistency.

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.

Posted: Fri Oct 05, 2007 10:01 am
by JamesM
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.
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...

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.

Posted: Fri Oct 05, 2007 1:41 pm
by neon
Second: I want to use = for both comparison and assignment. In C, I can't! Only for some comparisons. That does not make sense.
One of the reasons C has both = and == operators is for readability. We can quickly note what this is doing just by its operators.

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;
}
b:

Code: Select all

if ( (a = (b = 1) ? 0 : 1) = 1) {
   if (c = 0)
     c = 1;
}
I would prefer code block a :)

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++.

Posted: Fri Oct 05, 2007 1:48 pm
by Alboin
JamesM wrote:Either way you piss me off.
I second that motion.

Posted: Fri Oct 05, 2007 1:48 pm
by LordMage
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.

Posted: Fri Oct 05, 2007 3:05 pm
by Craze Frog
JamesM wrote:
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.
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...
Yes, that's logical, but it's not how it works in C.

Posted: Fri Oct 05, 2007 3:11 pm
by Alboin
Craze Frog wrote:
JamesM wrote:
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.
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...
Yes, that's logical, but it's not how it works in C.
But it is...