bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes:
> Date: 16 Dec 92 23:28:32 GMT
> Organization: University of California, Berkeley
>
> I'm a non-Pop-programmer following this discussion with interest.
> If I'm understanding right, it's proposed that the notation
> "strawberry fields forever"
> should mean three separate quoted words.
>
> Is there a way to include a space character in a word? This looks
> like a potential ambiguity to me. In Lisp we'd say
>
> '(strawberry fields forever) 3 words
> "strawberry fields forever" 1 string
>
> to distinguish these cases.
In pop-11 you can, at present, create a quoted word by putting
the word-quote symbol around a string, so
'the cat' 1 string
"the cat" Illegal syntax
"'the cat'" 1 word with the same characters as the string
also achieved by consword('the cat'), except the
former creates the word and puts it in the
dictionary at compile time, the latter at
run time.
Note that the Pop-11 lexical analyser will separate out some
character sequences into separate words. E.g.
x+5*f(x,y)
is exactly equivalent to
x + 5 * f ( x , y )
and some sequences of characters cannot be combined in a legal
quoted word, so that the following will produce an error:
"f(x,y)"
Strings, by contrast, using single quotes ' .... ' can contain
arbitrary sequences of characters. This was the basis of my
proposing a few years ago that the Pop-11 syntax be extended to
allow a quoted word in the format
"'<arbitrary characters>'"
since previously that would not have been legal Pop-11, and it has a
natural interpretation. Thus
"'f(x,y)'"
is now a single quoted word with the six characters: f ( x , y )
I've just realised that this facility could be screwed up by the
suggestion from Steve Knight and Chris Dollin to allow multiple
quoted words by using
"the cat on the mat"
to put five words on the stack, i.e. equivalent to
"the", "cat", "on", "the", "mat"
if their multiple quote syntax is to work by analogy with the
current Pop-11 convention for quotation in list and vector
expressions.
At present these allow strings and numbers to represent themselves.
Thus
[the cat 'on the' 3 mats 6.5]
is a list containing two words, a string, an integer a word and a
decimal number (float). This is very convenient instead of having to
unquote the contexts containing non-words, e.g.
[the cat % 'on the', 3 % mats % 6.5 %]
If the proposed new "multiple quotation" syntax were to be really
convenient it would be necessary to allow strings and numbers within
such multiple quotes to be interpreted as strings and numbers, not
as words with the string quote character, or words containing only
numeric characters.
In that case we would need some *other* syntax to make it convenient
to create words containing spaces and other arbitrary symbols. If,
instead of using " .... " for multiple quotes we used % .... % as
suggested in my previous replies to Steve and Chris, this problem
would not exist
% the cat 'the cat' 55 % -- two quoted words a string an integer
"'the cat'" -- one quoted word including a space
Of course including a word with arbitrary characters in a multiple
quote would not be possible, just as it is not possible now within
a list, unless you put it inside an unquoted context, then use the
format "'...'".
Taking account of all requirements when designing a general purpose
language is HARD!
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
|