The short answer is probably these C operators +=, -=, *=, /= * %= are from Algol68′s +:=, -:=, *:=, /:= & %:=.
c.f. usenet: Ada and C and Algol 68
BTW: The best quote about C’s ancestory comes from Dennis Ritchie himself:
“The
scheme of type composition adopted by C owes considerable debt to Algol
68, although it did not, perhaps, emerge in a form that Algol’s
adherents would approve of. The central notion I captured from Algol was
a type structure based on atomic types (including structures), composed
into arrays, pointers (references), and functions (procedures). Algol
68′s concept of unions and casts also had an influence that appeared
later.” Apr 1993 c.f. Dennis Ritchie (April 1993). "The Development of the C Language" (PDF)
End of short answer…
——– 8>< - - - - - - - - cut here - - - - - - - -
But note that the /= and /:= are subtly different. Also C's %= is the same as Algol's %*:= operator.
Note also that the majority of C's operators came from Algol (+ – * / = ≠ etc ). However the “%” operator is notability different.
* Wikipedia: Monadic_operators
* Wikipedia: Dyadic_operators_with_associated_priorities
C has the “return” and “sizeof” operator, whereas Algol68 has syntax “EXIT” (or "□") and operator “UPB” (or "⌈") that achieve a similar function.
Algol 68 also has some related constants: “max int”, “max real”, “int width”, “real width” etc to determine sizes of things. These are not the same a C’s sizeof, but similar.
The most peculiar operators of C’s are /\ & \/, these come from Algol's ∧ & ∨ operators. These “C originals” were replaced by the current && and || operators. c.f. What _did_ the C operators /\ and \/ do?
Algol68 further allows operators to be define using non-ASCII characters:
×, ÷, ≤, ≥, ¬, ∨, ∧, , ↓, ↑, ⌊, ⌈, ⎩, ⎧ and ⊥;
And used the characters →, ○, □, ␣ and ¢ for other purposes. It is kind of like Algol68 was taking the liberty of using unicode some 20 years before Unicode characters were defined. {Earlier Algol60 used non-ASCII ⊂ and ≡}
* C's: int i = b ? a : b; /* pick maximum */
* A68′s: INT i := ( a > b | a | b );
c.f. Wikipedia: ?: - a ternary operator
The assignment “:=” looks like an operator, but in terms of “Algol68″ OPerators it isn’t. I believe they are called “Units associated with names” c.f. Array, Procedure, Dereference and coercion operations
(Or – if you are a language lawyer c.f. Algol 68 r1 report.html#52)
Similarly: Left assign, right assign and compare ( :=, =:, =) are also not "Algol68" Operators.
Pointers are not operators per se. There are a few “identity relations” associated with pointers: e.g. :=:, :/=:, IS & ISNT
c.f. Assignation and identity relations etc
(Or – if you are a language lawyer c.f. Algol 68 r1 report.html#5221)
No comments:
Post a Comment