Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!watmath!rbutterworth
From: rbutterworth@watmath.UUCP
Newsgroups: comp.lang.misc,comp.lang.c
Subject: Re: C expression syntax in other languages?
Message-ID: <3971@watmath.UUCP>
Date: Tue, 16-Dec-86 16:13:43 EST
Article-I.D.: watmath.3971
Posted: Tue Dec 16 16:13:43 1986
Date-Received: Wed, 17-Dec-86 20:45:23 EST
References: <358@danews.ATT.COM>
Organization: U of Waterloo, Ontario
Lines: 46
Keywords: C,syntax
Xref: watmath comp.lang.misc:48 comp.lang.c:425

> 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)