any other language can do these?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

OP: Yes, I believe pascal is (was) used extensively for kernel development. Some people here are kernel-ing in pascal, I believe.
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post 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)
This was supposed to be a cool signature...
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post 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.
This was supposed to be a cool signature...
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post 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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post 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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post 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++.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

JamesM wrote:Either way you piss me off.
I second that motion.
C8H10N4O2 | #446691 | Trust the nodes.
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

Post 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.
Getting back in the game.
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post 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.
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post 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...
C8H10N4O2 | #446691 | Trust the nodes.
Post Reply