C expression syntax in other languages?

rbutterworth at watmath.UUCP rbutterworth at watmath.UUCP
Wed Dec 17 07:13:43 AEST 1986


> One of the reasons I enjoy programming in C so much is its
> expression syntax.  Are there any other languages that have
> a similar expression syntax?  Do BCPL and B have it ?

B has a very similar syntax.  If written carefully. some simple
programs will compile and run correctly under either language.

B is typeless (or rather the type is determined by the context
in which it is used), so in x=5, x(), x[2], x=2.3, x="xxx",
"goto x", the compiler treats "x" as an integer, a function,
a word array pointer, a float, a character string, or a label.

New operators are needed for floating point operations since
"x+y" adds "x" and "y" as if they were integers.  "x#+y" adds
them as if they were floats.  "#x" is the float value of the
int "x", while "##x" is the integer value of the float "x" (used
like casts in C).  This gets rather ugly, but there is seldom any
need to use the floating point operators.

There is no double precision since "x" and all expressions are
always exactly one word.  (36 bits on this Honeywell DPS-8).

ASCII is the normal character set, but grave-accent-quotes `xxx`
can be used to define up to 6 bcd characters, the same way as
apostrophe-quotes 'xxx' can be used to define up to 4 ASCII
characters.

There is an additional "@expression" operator.  It causes the
hardware indirection bit to be turned on in the last generated
instruction for the expression.  It is seldom used, even by
those that understand what this means.

  [LR]  name const primary[expr] primary(arglist) (expr)
  [RL]  ++ -- * & - ! ~ #- # ## (unary)
  [LR]  >> <<
  [LR]  &
  [LR]  ^
  [LR]  |
  [LR]  * / % #* #/ (binary)
  [LR]  + - #- #+
  [LR]  == != > < <= >= #== #!= #> #< #<= #>=
  [LR]  &&
  [LR]  ||
  [RL]  ?:
  [RL]  =  +=  -=  etc.  (all assignment operators)



More information about the Comp.lang.c mailing list