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

Ralph Becket rafe at cs.mu.OZ.AU
Fri Jun 7 14:52:02 AEST 2002


Milan Zamazal, Thursday,  6 June 2002:
> Is there anyone here considering this a good idea?  (It's useless to say
> you don't like the idea at all -- satisfied Mercury users can just
> ignore it, and if nobody expresses an interest I won't waste my limited
> resources to go further with the idea.)

There is a more direct translation:

(:- (module sort))
(:- (interface))
(:- (import_module io))

(:- (pred (main (:: io di) (:: io uo) (is det))))

(:- (implementation))
(:- (import_module (string list char require std_util)))

(:- (main IO0 IO)
    (, (io__command_line_arguments Args)
       (; (, (= Args (list))
             (handle_args no no)
	     sort)
          (, (= Args (list Input))
	     (handle_args (yes Input) no)
	     sort)
	  (, (= Args (list Input Output))
	     (handle_args (yes Input) (yes Output))
	     sort)
  	  (, (= Args (list _ _ _ | _))
	     (io__write_string "Usage: ...")))))

and so forth.

We experimented with taking the comma argument separators out and moving
to Lisp-style parentheses while retaining infix notation, but decided
it didn't add anything in terms of readability.

The thing is, if you just want term_expansion (= Lisp) style macros, you
can just use the expand_terms.m approach in the samples directory.
Certainly some nicer syntax could be provided, but you don't need to
shift to S-expressions to achieve your goal.

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