On Tue, 2 Jan 2001, Clive Rodgers wrote:
Maurice Lombardi a ecrit :
Indeed, it was already in Algol60, the first ancestor of Pascal. The syntax was as above
x := if cond then 42 else 17
and I had some trouble in beginning with Pascal to give away this very natural syntax !
No dangling else, use of () to be sure in case of doubt about precedences would be the simplest (but I have an historical bias !)
Hope this helps
Maurice
As a native Algol60 speaker, I agree - this was one of the features I too missed when Algol60 faded away. Syntax is close to natural language (easy to teach, easy to learn, and a clean syntax - that is the fundamental principle of Pascal). The rules of precedence for Algol60 are basically evaluate from left to right unless specific rules apply - isn't that already the case for Pascal? I don't think we need anything else. The endif (or end) construction is un-Pascalish
- use parentheses if required, in the same way as begin/end is used
when needed for conditional statements.
As another ex-Algol60 (my first language on an Elliot 503, just to show my age!) this is quite natural but I am not sure that there is that much to recommend it since it would make the program much less portable to other Pascal environments. I think the gpc team should be careful not to go too far down a divergent route. After all, open standards are there for guidance and to avoid some of the more destructive activities of certain Large Companies and it would be a little hypocritical of open source advocates to follow this bad example.
However, why restrict it to the RHS? ISTR that in Algol68 (or was it SCL, the ICL VME operating system language) you could say:
if cond1 then a else b := if cond2 then expr1 else expr2
or something like that, which could lead for example to (I think in SCL) the following curious-looking statement (until you worked out what it was doing):
if if then then else else := if not then while else for
since there were no reserved words (the compiler being sufficiently clever to work out when to expect one!). Fun to read anyway!
BTW while discussing other Algol/Pascal-like languages, does anyone know why in ADA95, there are no sets? This is a large omission I think.
Happy New Millenium too to all of you - the numerate millenium. I noted from DW-TV the other day that there is one town in Germany that refused to celebrate last year and one country (Cuba) also. There is hope for us all!
Best wishes
John