Language Syntax Suggestion

Hans-Dieter.Dreier@materna.de Hans-Dieter.Dreier@materna.de
Fri, 12 Mar 1999 11:44:40 +0100


--kE2fu6deIGsnlOWotXeZi79N61akVfZI
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable

Jeremy Dunn wrote:
>Hans Dieter Dreier suggested that I write my collections as [ a b]
>rather than [,a,b], no doubt this is a return to familiar LISP syntax.
>This would be possible if I was willing to lose the distinction between
>ordered and unordered elements. The blank space in front of the first
>element would visually get lost in code and easily be mistyped as [a b]
>which does not mean the same thing at all. Remember, in LISP syntax the
>blank spaces are there only to visually separate the elements of the
>expression, the elements are ALWAYS assumed to be in the order that they
>appear. My notation was based upon a philosophy of indicating every
>operation that is being performed, explicitly, some people don't like
>this because they want to make simplifying assumptions. An analogy I
>might use would be the wide usage of calculators that use reverse-Polish
>notation, my wife hates them! We're used to using +, - and so on because
>we were taught it that way in grade school and we're going to cling to
>it to the very end. I suppose this is like the battle between English
>units and metric, I am outnumbered by the people who want to use the
>English system (at least partially) versus the approach of rigidly
>applying a syntax rule to each and every case.

Apparently you got me wrong. I'd never suggest to define a language so that=
 [ x] would have a different meaning from [x] just because of the missing s=
pace. That would really invite programming errors. What I wanted to say is =
that one token (here: the comma) should not be used to denote different thi=
ngs. If it is used inside a list, it acts as a separator, maybe carrying so=
me other semantics as well. If it is used as a "prefix" (certainly there is=
 a better term for that, but you get the point) like in [,a,b], it means so=
mething different. Not knowing your definition, I would intuitively take it=
 as "a list of three elements, where the first one is empty". You see, it's=
 just a matter of ergonomics. It is not only important to keep the number o=
f keywords at bay but also the number of rules. And to keep them consistent=
 to each other and to what people might expect. At least if you want others=
 to understand your program. Maybe you want to take a look at http://www.tu=
xedo.org/~esr/intercal/index.html (no offense intended ;)

Some people would also think "it's an index" if they see [].

>I wanted to say something about IF-THEN and LOOP structures. I have
>often felt that if/then structures in most languages carry more verbiage
>than is necessary. Here is how I would write various expressions:
>
>If A Then B			[If,A,B]
>If A Then B Else C		[If,A,B,C]
>If A Then B ElseIf C Then D	[If,A,B,C,D]
>
>Very simple, no need for all those elses and thens. A SELECT CASE

True, but again the reader has to scan the context to detect what "," means=
 in a particular place. That's one reason why they invented keywords - to m=
ake the token express its meaning more clearly if it is a special one (like=
 a control construct) without the need to look at the surrounding text. Of =
course no special symbols are ever required except () - just look at Lisp. =
But many people have big problems to read a Lisp program as fluently as a m=
ore traditional one, say Pascal or C, at least until they are used to it.

Well, but that really is a matter of taste. Of course you can design your s=
yntax to fit your taste. If there is an automatic translation to and from a=
nother visible representation available, other people may use their represe=
ntation. It is one of our aims to achieve that.

>[Loop,[,<test>,],[<body>]] - While-Do
>[Loop,[,,<test>],[<body>]] - Do-While

Here again I'd like to point out that it is easy to make a mistake since th=
ese look so similar yet have completely different meaning.

Why not use another keyword instead of Loop in one case?

>We notice that the test condition is now a two element collection that
>consists of a blank argument and the actual test. The blank argument
>indicates the order in which the body of the loop is to be executed. If
>the first argument is blank then the body is executed first then the
>test condition and vice-versa. No need for separate DoWhile and WhileDo
>functions.

Is this rule a special form of a more general one, or does it apply only to=
 loops? Which means if there is [,a,] and [,,a,], is there a general rule, =
regardless of context? What about [,,,a]?

> A FOREACH loop would be written as
>
>[Loop,[,X,[,a,b,c]],[<body>]]
>
>This would be the same as =

>
>Foreach X in [,a,b,c] Do <body>

Actually, if I'm new to the language, I can guess the meaning from the seco=
nd example but not from the first one.

>A FOR loop then becomes simply a Loop structure with a test condition
>that is a set with 3 elements that contain the initialization,
>conditional test and increment as
>
>[Loop,[,init,cond,incr],[<body>]]
>
>We now have a simple way to indicate what can take up to 5 (or more)
>loop functions in a conventional language, with only one Loop function.

How do you express a loop that has a conditional break somewhere in the mid=
dle of the loop body? Or two of them?

>I am of the opinion that if-structures and loop-structures should be
>handled in single commands rather than a proliferation of special cases
>that are really only representing one general concept.

So do I, but I would do it differently.

--

Regards,

Hans-Dieter Dreier
(Hans-Dieter.Dreier@materna.de)=

--kE2fu6deIGsnlOWotXeZi79N61akVfZI
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable

IDENTIFIKATIONSANGABEN:
a16029a.txt IA5 DX-MAIL X.400 User Agent=

--kE2fu6deIGsnlOWotXeZi79N61akVfZI--