comp.lang.ada
 help / color / mirror / Atom feed
From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
Subject: Re: Language Choice and Coding style
Date: 1996/07/02
Date: 1996-07-02T00:00:00+00:00	[thread overview]
Message-ID: <4ra5hb$do6@goanna.cs.rmit.edu.au> (raw)
In-Reply-To: 4r7cnq$g57@sun.quiknet.com


rahill@mind.net (Russel A Hill) writes:
>Get a life Jon.  I type this way because it commnitactes well.  Out compiler 
>Technology isn't suuffieicently advbanced to handle:
> 
>  Loop Control Variable = Initial Value

Sorry, but this is rubbish.  Algol 60 and Algol 68 both allowed this.
As an exercise, I once wrote a version of the Prolog read/1 command
that allowed embedded blanks in identifiers, and IT WAS DEAD SIMPLE.
"Our compiler technology" has been "sufficiently advanced" for more
than 30 years.

It isn't even a "compiler technology" issue; it's only a "lexical analysis"
issue.  There is no problem dealing with a mix of identifiers, operator
symbols, and punctuation marks.  The only problem is when you have keywords
that look like identifiers.  Algol 68 explored the "stopping" possibilities
reasonably thoroughly.  One simple method, for example, is "case strop":
keywords are in upper case, everything else in lower case.  So one might
write

    FOR i FROM LB sensor table TO UB sensor table DO
	has overflowed OF sensor table [i] := FALSE
    OD

This is not rocket science.  Another technique is to use a special
prefix character:  IMP used '%', Algol 68 used '.':
    .For i .from .lb sensor table .to .ub sensor table .do
	Has overflowed .of sensor table [i] := .false;
    .Od
(and with the full stop being in the same shift as the lower case letters,
this cannot be said to be hard to type.  Indeed, I was surprised to find
just how easy it is.)

I note comp.lang.c and comp.lang.c++ in the newsgroups line.  Let's see
what changes to C would be needed to allow embedded blanks in identifiers.
Declarations can have lots of words run together, e.g. unsigned long int foo.
To handle that, we'll borrow Pascal/Fortran 90 declaration syntax.
	<id list> : <type>
will be a variable declaration, and
	<header> : <type> <block>
will be a function definition.  There is one word operator: sizeof.
We'll use function call syntax for that, which is already legal anyway.
A labelled statement can be told from a declaration by the fact that the
keywords that begin a <type> cannot begin a <statement> in revised syntax.

Here is part of a file comparison program:

void print_line(long n, char const *line) {
    printf("%7ld %s", n, line);
    if (0 == strchr(line, '\n'))
	printf("...\n");
}

void compare_streams(FILE *f1, FILE *f2) {
    char line1[LINE_BUFF_SZ];	/* line read from f1 */
    char line2[LINE_BUFF_SZ];	/* line read from f2 */
    char const *p1;		/* set to NULL at end of f1 */
    char const *p2;		/* set to NULL at end of f2 */
    long n;			/* current line number */

    n = 0;
    do {
	n++;			/* count attempts to read from f1 */
	p1 = fgets(line1, sizeof line1, f1);
	p2 = fgets(line2, sizeof line2, f2);
    } while (p1 != NULL && p2 != NULL && strcmp(p1, p2) == 0);

    if (p1 != NULL && p2 != NULL) {
	/* neither file has ended yet; the lines must disagree */
	printf("files differ\n");
	print_line(n, line1);
	print_line(n, line2);
    } else
    if (p1 != NULL) {
	/* file1 has not ended, but file2 has */
	printf("first file longer\n");
	print_line(n, line1);
    } else
    if (p2 != NULL) {
	/* file2 has not ended, but file1 has */
	printf("second file longer\n");
	print_line(n, line2);
    }
    /* no output is produced if both files were the same */
}

In revised C syntax:

print line(n: long, line: char const *): void {
    printf("%7ld %s", n, line);
    if (0 == find char in string(line, '\n'))
	printf("...\n");
}

compare_streams(file one, file two: FILE *) void: {
    line one, line two: char[LINE BUFF SZ];
    p one, p two: char const *;
    n: long;

    n = 0;
    do {
	n++;
	p one = f get string(line one, sizeof(line one), file one);
	p two = f get string(line two, sizeof(line two), file two);
    } while (p one != NULL && p two != NULL
          && string compare(p one, p two) == 0);

    if (p one != NULL && p two != NULL) {
	printf("files differ\n");
	print line(n, line one);
	print line(n, line two);
    } else
    if (p one != NULL) {
	printf("first file longer\n");
	print line(n, line one);
    } else
    if (p two != NULL) {
	printf("second file longer\n");
	print_line(n, line two);
    }
}

Except for declaration syntax, very little changes.  What conclusion does
this lead to?  A blindingly obvious one:

    it is not our *compiler technology* that forbids embedded blanks
    in identifiers, it is our *programming language standards*.
    If we wanted embedded blanks, we could have them.

All you have to do is design your language so that
	... <identifier> <identifier> ...
	... <keyword> <identifier> ...
	... <identifier> <keyword> ...
cannot occur, and then you don't even need stropping.	

-- 
Fifty years of programming language research, and we end up with C++ ???
Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.




  parent reply	other threads:[~1996-07-02  0:00 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-21  0:00 Language Choice and Coding style Nasser Abbasi
1996-06-21  0:00 ` Louis Tribble
1996-06-21  0:00 ` Robert Dewar
1996-06-24  0:00   ` Dr. John B. Matthews
1996-06-21  0:00 ` Giuliano Carlini
1996-06-21  0:00 ` The Amorphous Mass
1996-06-23  0:00   ` Robert Dewar
1996-06-27  0:00     ` Adam Beneschan
1996-06-28  0:00       ` Peter Hermann
1996-06-28  0:00         ` Robert Dewar
1996-07-02  0:00           ` John McCabe
1996-06-28  0:00         ` Robert A Duff
1996-06-29  0:00           ` Samuel Mize
1996-06-29  0:00             ` Robert Dewar
1996-07-04  0:00               ` Peter Hermann
1996-07-04  0:00                 ` Robert Dewar
1996-07-05  0:00                   ` software engineering and the notion of authorship Fergus Henderson
1996-07-08  0:00                     ` Jakob Engblom
1996-07-08  0:00                       ` John Byerly
1996-07-08  0:00                       ` Fergus Henderson
1996-07-09  0:00                         ` Richard A. O'Keefe
1996-07-09  0:00                           ` Fergus Henderson
1996-07-11  0:00                           ` Paul Eggert
1996-07-08  0:00                       ` The Amorphous Mass
1996-07-08  0:00                         ` Robert Dewar
1996-07-08  0:00                     ` Peter Hermann
1996-07-15  0:00                     ` Ralph Silverman
1996-07-15  0:00                       ` Fergus Henderson
1996-07-17  0:00                       ` Robert Dewar
1996-07-19  0:00                         ` Mike Curtis
1996-07-05  0:00                   ` Language Choice and Coding style John McCabe
1996-07-04  0:00               ` John McCabe
1996-07-04  0:00               ` Dan Evens
1996-07-02  0:00             ` John McCabe
1996-07-02  0:00               ` Samuel Mize
1996-07-03  0:00                 ` John McCabe
1996-07-03  0:00                 ` Jeff Dege
1996-07-03  0:00                   ` Robert Dewar
1996-07-04  0:00                     ` Phil Howard
1996-07-04  0:00                       ` Peter Hermann
1996-07-04  0:00                     ` John McCabe
1996-06-28  0:00         ` John McCabe
1996-07-06  0:00       ` Laurent Guerby
1996-07-19  0:00       ` software engineering and the notion of authorship Andrew Gierth
1996-06-27  0:00     ` Language Choice and Coding style The Amorphous Mass
1996-06-23  0:00   ` mfinney
1996-06-23  0:00     ` Robert Dewar
1996-06-26  0:00       ` mfinney
1996-06-21  0:00 ` David Weller
1996-06-21  0:00 ` Jerry van Dijk
1996-06-24  0:00   ` Adam Beneschan
1996-06-21  0:00 ` David Emery
1996-06-23  0:00 ` Darin Johnson
     [not found] ` <4qeu56$52r@news.interpath.net>
1996-06-23  0:00   ` Nasser Abbasi
1996-06-24  0:00 ` Michael R. Hartwig
1996-06-24  0:00 ` John McCabe
1996-06-24  0:00   ` Peter Hermann
1996-07-01  0:00     ` Alan Brain
1996-07-02  0:00       ` John McCabe
1996-06-24  0:00   ` Adam Beneschan
1996-06-26  0:00   ` Ian Ward
1996-06-26  0:00   ` Nasser Abbasi
1996-06-24  0:00 ` Theodore E. Dennison
1996-06-24  0:00 ` Andreas Schoter
1996-06-29  0:00 ` Rich Maggio
1996-06-29  0:00 ` Samuel Mize
1996-07-01  0:00   ` Richard A. O'Keefe
1996-07-02  0:00     ` Samuel Mize
1996-07-03  0:00       ` Robert Dewar
1996-07-08  0:00     ` ++           robin
     [not found] ` <JSA.96Jun26141502@organon.com>
1996-07-01  0:00   ` Russel A Hill
1996-07-01  0:00     ` Robert Dewar
1996-07-08  0:00       ` Russel A Hill
1996-07-02  0:00     ` Richard A. O'Keefe [this message]
1996-07-02  0:00   ` Jon S Anthony
1996-07-03  0:00   ` Mark Eichin
1996-07-02  0:00 ` Nasser Abbasi
1996-07-03  0:00   ` steidl
1996-07-05  0:00     ` Samuel Mize
1996-07-06  0:00     ` N. L. Sizemore
1996-07-08  0:00       ` steidl
     [not found] <835824850.11044.0@assen.demon.co.uk>
1996-06-27  0:00 ` Ian Ward
1996-06-27  0:00   ` John McCabe
  -- strict thread matches above, loose matches on Subject: below --
1996-07-05  0:00 Robert C. Leif, Ph.D.
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox