Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

language supporting (x<y<z)

0 views
Skip to first unread message

Kenn Goutal

unread,
Oct 10, 1986, 4:57:33 PM10/10/86
to
In a recent article, Dave Brosious asks if there is a language
that supports constructs such as:

IF (4 < x < 8) THEN blabla

The answer is, yes, at least one: SAIL -- Stanford AI Language.
SAIL is an ALGOL derivative at heart, with two large extensions,
one to support sets and operations thereon and
one to support lists and operations thereon.
The requested construct was a part of the Algol part of the language.
My all-time favourite programming language.

-- Kenn Goutal ...decvax!savax!sii!siia!kgg

Barry Shein

unread,
Oct 11, 1986, 6:05:51 PM10/11/86
to

Doesn't SPSS support something like "IF a .LT. b .LT. c"? I seem to
remember this but it's been years. Not sure if SPSS is a "programming
language", but then again you should have seen some of the things we
used to do with it :-)

-Barry Shein, Boston University

Theodore S. Norvell

unread,
Oct 12, 1986, 3:14:58 PM10/12/86
to
The language Icon by Ralph Griswold supports (x<y<z) in an interesting
way. Every expression in the language either succeeds or fails. Success
and failure of expressions in Icon is much like success and failure
of procedure calls in Prolog, except that in Icon a succeeding expression
results in a value. (By the way, just as a Prolog call can succeed more
than once if backtracked into, an Icon expression can produce more than
one result.)

Assuming x, y and z are arbitrary variables :
If x<y fails then x<y<z fails.
If x<y succeeds then its result is y and the whole expression becomes
y<z. Now if that succeeds then the whole expression (x<y<z) succeeds
(resulting in z) else it fails.

By the way Icon also does away with most semicolons, though in a
clumsy way. If a line does not end in a semicolon, but it would
be syntactically valid for there to be one there then, the parser assumes
it's there.

A better way to get rid of semicolons in a free format
language is to design the grammar so that it needs neither statement
(or declaration) separators nor terminators and is still LR(1).
An example is the Turing language. Dave Brosius speculates that
this will make error recovery difficult. However, error recovery in Turing
compilers is quite good, and because there are no forgotten-semicolon
errors less frequent than in Pascal ones. It is almost as easy to recover
by skipping to the next identifier which follows a ")", identifier or
constant as it is to skip till the next semicolon. My experience is
that forgetting meaningful separators (like writting x := 1 x rather
than x := 1 + x) is rare whereas forgetting syntactic artifacts like
";", "(" and ")" is common.

Contrary to Barry Shien's Statement, it is not necessary to forbid
assignments embedded in expressions in free form languages.
For instance this grammar will be unambiguous and LR(1).
Expression --> Identifier | Identifier ":=" Expression
| "(" Expression ")"
Statement --> Expression
Program --> Statement | Program Statement.
If you still want semicolons in your language, add the production
Statement --> ";"
so that those who like to exercise there right little finger
can put in all the statement terminators and/or separators they want.

Theodore Norvell
DCS U of Toronto

Tom Cole

unread,
Oct 14, 1986, 7:49:29 PM10/14/86
to

Line eater? Eat this!

In a response to a question about languages that support the construct
if (x < y < z ) bla bla bla, Barry Shein replies something to the effect
that SPSS supports something like this. For the record, so does SAS, but
then the more important question is are either of these really considered
languages by you guys...

Tom Cole
SAS Institute (where we are supposed to know better)
Cary NC USA Earth

Darrel VanBuer

unread,
Oct 15, 1986, 5:34:07 PM10/15/86
to
In PL/I, a<b<c is a legal expression, but doesn't mean (a<b)&(b<c); it means
compare a<b, yielding a BIT(1) which is 1 or 0 for True/false; coerce the
bit to a number (0 or 1) and compare to c. Thus 4<5<2 is true and -2<-1<0
is false!
A cautionary tale in the confused world of real programming languages from
...

--
Darrel J. Van Buer, PhD
System Development Corp.
2525 Colorado Ave
Santa Monica, CA 90406
(213)820-4111 x5449
...{allegra,burdvax,cbosgd,hplabs,ihnp4,orstcs,sdcsvax,ucla-cs,akgua}
!sdcrdcf!darrelj
VAN...@USC-ECL.ARPA

Tom Cole

unread,
Oct 17, 1986, 4:57:13 PM10/17/86
to

ja...@tekecs.uucp

unread,
Oct 26, 1986, 3:50:21 PM10/26/86
to
Alright, sports fans! The most commonly available language supporting:

(value relop value relop value)

is indeed (TA TA!) the Korn Shell! (evidenced by the following script)

| Script started on Sun Oct 26 12:32:45 1986
| $ if ((2>1>0)); then echo true; else echo false; fi
| true
| $ if ((1>1>0)); then echo true; else echo false; fi
| false
| $ if ((1>1>1)); then echo true; else echo false; fi
| false
| $ if ((2>1>1)); then echo true; else echo false; fi
| false
| script done on Sun Oct 26 12:35:04 1986

The first person who correctly explains this behavior will have $2.56
donated in their name to the Steinman Charitable Beer Trust.

(Just when you thought this silly subject had died out!)
--
:::::: Artificial Intelligence Machines --- Smalltalk Project ::::::
:::::: Jan Steinman Box 1000, MS 60-405 (w)503/685-2956 ::::::
:::::: tektronix!tekecs!jans Wilsonville, OR 97070 (h)503/657-7703 ::::::

0 new messages