[m-dev.] Suggestion: change quotation rule

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Mar 23 05:39:02 AEDT 2000


On 22-Mar-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> I've just discovered that backquotes do not implicitly `forward'quote
> their content -

Correct so far...

> that is, I can't write
> 
> 	X `:<>` Y	% Direct transliteration of a bit'o'Haskell.
> 
> rather, I have to type
> 
> 	X `':<>'` Y

That's not correct.

For example, the following program compiles fine (with --infer-all),

	:- module example.
	:- interface.
	:- import_module io.

	:- pred main(state::di, state::uo) is det.

	:- implementation.
	:- import_module int.

	main --> print(foo), nl.

	foo = 1 `:<>` 2.

	X `:<>` Y = X + Y.

and prints out `3'.

Only if the operator is not a name or a graphic-token, i.e.
a sequence composed of the following characters

	# $ & * + - . / : < = > ? @ ^ ~ \

do you need to put the operator in quotes.

> which seems a tad unnecessary (and my program starts to look like an
> m4 script).  Could we change the quotation rule so that the former is
> acceptable?

Well, it would be possible... but one example does not by itself
constitute a specification, especially when that example is already
legal according to the current specification.

There would be a couple of complications for any such proposal.  What about
module qualifiers? Note that currently ":" is a module qualifier.  Currently
we allow e.g. "X `foo:bar` Y", and surely we should continue to allow module
qualifiers in backquoted operators.  What then are we to make of things like
"X `:<>` Y"?

Another issue with module qualifiers is that currently we allow spaces around
the module qualifier, so you can write e.g. `foo : bar' instead of `foo:bar'
if you want.  If backquotes also forward-quote what they enclose, it seems
difficult to handle module qualifiers in a consistent manner both inside and
outside backquotes.

Also, what about backslash escapes -- should they be allowed inside backquotes?
What would "X `\\` Y" expand to?  Would it be the same as "'\\'(X, Y)",
i.e.  "\(X, Y)", or would it expand to "\\(X, Y)"?

Given that the current language already supports the use of backquotes
with graphic-tokens, which probably covers 80% of the cases for which
you'd want this, I don't see any compelling reason to try to address
the above complications.

Cheers,
	Fergus.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list