[mercury-users] Re: Lisp-like syntax for Mercury (Mercury & macros)

Peter Schachte schachte at cs.mu.OZ.AU
Wed Jun 12 11:15:21 AEST 2002


On Tue, Jun 11, 2002 at 05:08:38PM +1200, Richard A. O'Keefe wrote:
> When backslash escapes were added to QP, unescaped newlines in strings
> are forbidden.  That means you only have to worry about single quotes
> on the current line.

Unfortunately, character_escapes must be explicitly enabled, and in
general there's no way to tell by looking at it if a file is meant to
be compiled with character escapes on or off.  It's also rather a
nuissance, and error prone to boot, to turn on character escapes for
a single file.  It's unfortunate that character escapes weren't made
an always on feature, with the prohibition on unescaped newlines.

> But the real secret is "in order to move backwards, tokenise FORWARDS".

Of course, this isn't easy in a text editor.  You pretty much have to
rely on the rule that all and only clause heads begin in column 1.
Except for % comment lines.  And there is a performance hit involved
in finding the beginning of the clause and tokenizing it forward to
the current location every time you do anything.

> Newline at same indentation: <LF>.
> Increase indentation: <ESC><Ctrl-I>
> Decrease indentation: <ESC><Ctrl-U>
> 
> Given these keys, I find getting the indentation right manually
> is practically effortless

You are still forced to think about your program as text.  I'd rather
think about it as predicates and terms.  Only the comments are text.

> 	> However, '.' followed by white space is
> 	> end of clause, '.' followed by anything else isn't.
> 	
> 	Not true:
> 	
> 		  X =  0'.
> 		, Y = '0'.
> 	
> 	is a single Prolog term, not two.
> 	
> Remember, the trick is to parse FORWARDS.

My point was that "." followed by whitespace does not necessarily end
a clause, and telling whether it does or not is difficult.  In fact,
because of character escapes, it's not in general possible to tell
just by looking at the file.

-- 
Peter Schachte              As the mainstream media has become increasingly
schachte at cs.mu.OZ.AU        dependent on advertising revenues for support,
www.cs.mu.oz.au/~schachte/  it has become an anti-democratic force in
Phone: +61 3 8344 9166      society. -- Robert McChesney 
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list