[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Dec 15 23:13:58 1992 
Subject:Re: Syntax Misdesign 
From:Aaron Sloman 
Volume-ID:921215.03 

sfk@otter.hpl.hp.com (Steve Knight) writes:

> Date: 11 Dec 92 12:00:57 GMT
> Organization: Hewlett-Packard Laboratories, Bristol, UK.
>....
> For myself, I cannot abide the list and vector syntax.  Just the other
> day I was speaking with a highly competent programmer (in C & Prolog)
> who said to me "You know, I can never seem to get the hang of POP syntax."
> Needless to say, I had to investigate!  And, little to my surprise, I
> discovered that the quasi-quoting syntax of lists and vectors were the
> problem.
>
> The number of beginners who want to build a list of one element with the
> result of a computation, say ``f(x)'', in it who write
>     [ f(x) ]
> must be beyond recall.  In fact, I suspect _every_ programmer made this
> eminently sensible guess when they were learning to program in POP and
> discovered, to their horror, just how wrong they were.

No. You have simply been exposed to a particular subset of learners.

> Another common mistake must be to attempt to correct the above expression
> and write
>     [ ^f(x) ]
> Whoops!  I just feel tired when I see beginners struggling with this piece
> of misdesign.
>
> What I would like to see is list notation brought into line with modern
> languages such as Prolog and Standard ML.

No. I found that on the contrary having to remember to put commas
into Prolog lists and to use quotes all over the place was a real
pain. E.g. to create a list of program text items in Pop-11 you
can type for example:
    [f(x)]

which creates a list of four items. To do the same in Prolog you
need:

    ['f','(','x',')']

and if you try

    [f ( x ) ]

you will get a list of one element. And if you try, instead
    [f, (, x, )]

you will get ;;; PROLOG SYNTAX ERROR - EXPECTED THE START OF A TERM

In Pop-11 if you want to evaluate a bit of text to get one element
you have to do just:

    [%f(x)%]

It's much easier where the default is quotation to have a single
pair of brackets to unquote, than when the default is evaluation and
lots of quotation marks are needed to quote. Of course, in Lisp you
don't need lots of quotation marks as a prefix quotes the whole list
expression.

If people learning Pop-11 make the mistake you have described then
they just have not been introduced systematically to the list syntax
and have just over-generalised from some other language.

> ...I think this could be done in
> a practical way by introducing a suitable compile_mode flag, for example.

NO then bits of code will have meanings that are too context
dependent. It would be better to have a special prefix that
determined whether the following list or vector expression was
quoted, as in Lisp. E.g.

    #_eval [f(x)] eval_#

could unquote EVERYTHING (unlike %....% which will not unquote
nested list or vector expressions.)

> What do other people get fuming about when they use POP?  Inquiring minds
> want to know!

One bad thing is that we did not in the early days reserve some
identifiers for system use. Also there's no consistency as to when
underscores are and are not used, e.g. is it sys_parse_string or
sysparse_string or sysparsestring, etc.

(And I hate the creeping mixed-case identifiers encouraged by X : I
keep putting the shift key down at the wrong time and having to go
back and make corrections. Previously I used to be a very fast
typist!)

Probably one of the most serious misdesigns is that there's no good
syntax for defining procedures that take different combinations of
arguments, like, for example, newanyarray or newarray. You have to
write horrible code to test what's on the top of the stack.

We need a syntax that uses patterns to handle the different cases.
(Like prolog?)
Aaron
-- 
Aaron Sloman, School of Computer Science,
The University of Birmingham, B15 2TT, England
EMAIL   A.Sloman@cs.bham.ac.uk  OR A.Sloman@bham.ac.uk
Phone: +44-(0)21-414-3711       Fax:   +44-(0)21-414-4281