[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: syntax across languages

Guy Steele - Sun Microsystems Labs <gls@labean.East.Sun.COM> writes:


> Do look further into some of the older languages (Ada, Modula-2,
> Smalltalk, Fortran, PL/I, Joss, MAD, Focal, etc.).  The diversity
> of notations before 1980 will astound you.

hopefully some knowledgeable people will do it :)


> block
> 	(progn x y ...)		Lisp (also "implicit progn" in the bodies
> 				of such constructs as lambda, let, and cond)
> 	[ x. y. ... ]		Smalltalk
> 	{ ... }			Ruby

i don't agree on this one. ruby's {} is more like lisp's "lambda".
You can't write:  if c then { ... } end

> 	foo ... end		Modula-2 (foo = if, do, ...)
> 	foo ... end foo		Fortran 90, Ada (foo = if, do, ...)


> equality/inequality


> 	eq functions		Lisp
> 	eq, eql functions	Common Lisp



> if_then_else
> 	IF c1 THEN a* ELSIF c2 THEN b* ELSE d* END	Modula-2
> 	if c1 then a* elsif c2 then b* else d* end if	Ada
> 	(cond (c1 a*) (c2 b*) (t d*))			Lisp
> 	if (c1) a else if (c2) b else d			C
> (I suggest that the examples illustrate a chain of if statements,
> since many languages have a special keyword for such chaining
> I also suggest that you distinguish between an if-then-else syntax
> permitting a sequence of statements and permitting only a single
> statement in various positions.  I have used "*" to indicate a
> statement sequence.  In contrast, C does not permit statement
> sequences; one must use a block.)

well, adding the "elsif" part is interesting.

as far the "statement" restriction, i think it's better placed at the "block"
entry. This is what you did when showing that
  "foo ... end foo" with foo = if ...
introduces a block.

> How about a category for switch/case statements?

well, very different from language to another :-/