Newsgroups: comp.lang.pop

Continuing the thread on list and vector syntax ....

In reply to my comments on the difficulty of beginners using the 
list and vector syntax, John Williams writes:

> Only those programmers who had the misfortune to learn another
> language first!. I don't think there's anything intrinsically
> counter-intuitive about the fact that the list and
> vector syntax doesn't evaluate items by default.

Well, since POP-11 is hardly the world's most popular programming language
I regard this as a very peculiar argument.  This position would only be
supportable if the list and vector syntax was superior in some technical 
sense.  But, as I argue below, it is a technically inferior position in
a minority language -- so let's expunge it.

The current syntax conflates two language roles -- quoting and
sequence construction.  This runs against the solid grain of orthogonality
that permeates the rest of POP-11.  Although we can conveniently build
lists and vectors with quoted contents, we cannot conveniently put
quoted items on the stack, for example.  The nearest idiom is
    cons_with erase { this is a quoted collection of words }

My view is that these two roles can and should be separated.  In POP-11
we have too many distinct quoting contexts.  There are four quoting 
contexts in POP-11:

    "word"          a lexical word enclosed in a pair of double-quotes
    "'9*9'"         a string enclosed in a pair of double-quotes
    [ ... ]         the interior of lists
    { ... }         the interior of vectors

Replacing these four different contexts by a single context, introduced
by the '"' symbol is, to my way of thinking, a step towards the 
rationalisation of a language that is rapidly evolving away from
beginners and towards experts, prepared to put up with useful, infrequent
and obscure idioms.

So instead of writing 
    cons_with erase { this is a quoted collection of words }
I am suggesting the rather more obvious
    "this is a quoted collection of words"


I'd also like to respond to comments by Aaron Sloman on my original
posting.  Aaron's first remark about my observations on beginners was,
simply enough :-

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

Naturally, this is true in both a trivial and non-trivial way.  But would
pursue this further and suggest that most of my POP-11 "beginners" are 
familiar with other high-quality programming languages.  They are 
rightfully critical of investing time and energy in a language with
archaic and negative features -- and list and vector syntax sticks out
like a sore thumb in POP-11.

These learners are, to me, the most interesting and important category.
They are the people whose interest has to be won if POP-11 is ever to 
move beyond its niche position.  Unlike complete novices, they are able
to examine the language critically and don't accept that every
feature is good in blind faith.

Aaron goes on to point out some real issues with the concept of abandoning
the role of lists and vectors as quoting contexts.  The examples used
are those of complex constant lists:

> 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',')']

Well, this certainly requires addressing.  Although Prolog and ML 
programmers don't complain about writing this kind of stuff, POP-11
programmers probably would -- after all they are used to better things.

The argument I would put forward here is that the '"' syntax should
be extended to allow putting a sequence of (quoted) values onto the
stack.  So the above example might be written
      [ "f(x)" ]
which is both neat and simple.  

Aaron continues to point out the issue of the need for explicit 
quotation in Prolog:

> and if you try [in Prolog]
>     [f ( x ) ]
> you will get a list of one element. And if you try, instead
>     [f, (, x, )]
> you will get [a syntax error]

The Prolog programmer has to write, of course,
      [ f, '(', x, ')' ]
This simply shows that Prolog has no easy way of quoting sequences.  I
would suggest that it is superior for beginners because there is no
special quoting context.  I would agree it is clumsy because of the need
to quote so many arguments.  The expert programmer would appreciate a
quoting context -- but only one mechanism is required, not 4.

Aaron points out that the above is clumsy by indictaing how anti-quoting
in POP-11 only needs a single pair of "%" marks.

> 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. 

And the exact converse argument applies.  If the '"' suggestion is followed
through, I would argue that if you wanted to quote a bit of text
you only require a single pair of quote marks.  To juxtapose the
suggestions:

                    One Expression      Quoted Words 
Current POP-11       [% f(x) %]         [ f ( x ) ]
Suggested            [ f(x) ]           [" f ( x ) "]


Aaron remarks on the learning difficulties of experienced programmers
as follows:

> 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 is a misunderstanding of the argument.  Non-novice beginners
don't so much have problems with the details of the syntax but with
motivating themselves to learn a language with apparently unjustifiable
design.  It is rather like learning the lexical conventions of C -- only
a handful of programmers can get it together to remember them.  In general,
programmers put in enough brackets and spacs to make sure they get the
lexis and parse that they intended.

To argue they have over-generalised is one view.  I would argue that they
are generalising from within POP-11 itself.  POP-11 is a superb model
of orthogonal design in most ways.  Experienced programmers quickly
recognise this and it becomes, I claim, a vital element in the way they
remember the language.  Since conflating quoting and sequence construction
is not only non-orthogonal but pointless, they inevitably have troubling
recalling the relevant details.


In reply to my comment that using a compile_mode flag would enable POP-11
to flip from old style to new style syntax Aaron writes:

> 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.)

This is replying to a point I never made.  I was not suggesting that the two
notations compete.  I am suggesting that the current list and vector
syntax is abandoned completely.  The use of a compile_mode flag is to
allow old style code to survive for a few years inside the POPLOG system.

Adopting both conventions would be the worst possible resolution (not that
I am suggesting that Aaron was arguing for it as a resolution.)
It would complicate rather than simplify.  My goal is to
make POP-11 easier for both beginners and experts by making the language
more regular.  The cost would be entailed by experts who would have to
learn a slightly different way of working.

I justify the cost in the following way.  POP-11 stands or falls by virtue
of its reputation.  Improving the quality and reputation of POP-11 benefits
everyone in the POP community over the long term.  Without this process of
rationalisation, POP-11 will become an ever-increasingly complex and
fragmented language.  So it is a cost that experts should be prepared to
bear -- provided they agree the change is worthwhile!

Steve