On 15.03.2006, at 09:08, Raphael Collet wrote:
Torsten Anders wrote:
Wouldn't it be worth discussing macros for Oz again?

It is not public, but at UCL we are thinking about it. But we are not satisfied at all with what Denys proposed. We want to be able to extend Oz with something that still looks like Oz. We want something like

   unless X<Y do {Show X} {Show Y} end

instead of

   <<unless X<Y {Show X} {Show Y}>>

We have a student who is currently working at macros that allows to define something like the first alternative. He even consider macros with a recursive definition! This is extremely elegant for defining loops. He defines a while loop more or less as

MACRO while Cond do Body end
   if Cond then
      Body  while Cond do Body end
   end

You don't need to know how to manipulate the syntax tree of your program with such a definition. This part is done for you.

Nice! If writing macros becomes so easy, they may as become abused as in Lisp ;-)

I believe there are two cases for which macros are often used:

* To write control structures which do not necessarily evaluate all their arguments (like unless)

* To write special and convenient syntactic constructs which do not have a function/procedure equivalent but could have one

In Oz, an example for the second case is the class <...> end construct. The function Class.new supports only partly what the special construct can do: You can not define methods with Class.new. Similar restrictions can be found for similar constructors such as Functor.new (no support for the keywords require and prepare).

Is there some fundamental reason, that creators like Class.new and Functor.new only partly support what their special syntax counterpart supports?

Having full creator procedures for every syntactic construct which can be expressed by a procedure would reduce the need for macros. Abstractions could be written as procedures instead (such as a function creating a class).

Thank you very much!

Best,
Torsten

--
Torsten Anders
Sonic Arts Research Centre
Queen's University Belfast (UK)
www.torsten-anders.de


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to