[mercury-users] Urgent Queries

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Oct 12 01:07:39 AEST 2002


On 11-Oct-2002, Noel  Pinto <cool4life at rediffmail.com> wrote:
> 1) What are backslash escapes??  There are various escapes sucvh 
> as \a \b and more. I would like to know more about them. Plz do 
> give examples showing how they could be used.

    Here's an example, from samples/hello.m:

main --> io__write_string("Hello world\n").

    The \n is a backslash escape.  It stands for a new-line character.
    In other words, this is the same as writing

main --> io__write_string("Hello world
").

    The other backslash escapes also provide ways of denoting characters
    that would otherwise be inconvenient to embed directly in your source
    code.  As it says in the language reference manual:

	 | `\a' stands for "alert" (a beep character),
	 | `\b' for backspace, `\r' for carriage-return, `\f' for form-feed,
	 | `\t' for tab, `\n' for newline, `\v' for vertical-tab.

    Here's another example:

main --> io__write_string("Hello world\n\a").

    If it is run with the output directed to a terminal (as is usually
    the case by default), this will print "Hello world", advance the
    cursor to a new line, and then make a beep.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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