Newsgroups: comp.lang.dylan
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!lerc.nasa.gov!magnus.acs.ohio-state.edu!math.ohio-state.edu!uwm.edu!chi-news.cic.net!newsfeed.internetmci.com!in2.uu.net!munnari.OZ.AU!news.hawaii.edu!phinely
From: phinely@Hawaii.Edu (Peter Hinely)
Subject: The power of Dylan macro's
X-Nntp-Posting-Host: uhunix4.its.hawaii.edu
Message-ID: <DHw5Gw.CIL@news.hawaii.edu>
Sender: news@news.hawaii.edu
Organization: University of Hawaii
Date: Sat, 11 Nov 1995 18:17:20 GMT
Lines: 71

Here is a question about Dylan macro's that maybe someone could be so kind
to answer for those of us familiar with only the more mainstream
programming languages. 

For example, say that I am annoyed at what I feel is an inconsistency in
the grammar of Dylan's standard "if"/"select"/"case" statements. Can I
change the grammar for such statements, for example by bringing the
grammar of the "case" statement into line with that of "if" statement,
just by writing the appropriate macro?  The DRM says "Certain built-in
macros cannot be implemented with rewrite rules or necessarily rewrite
into implementation-dependent code", but I'm not sure what that means.

Example:

Standard Dylan "case" statement
-------------------------------
case
   player1.money <= 0
     => end-game(player1);
   player2.money <= 0
     => end-game(player2);
   otherwise
     => move(player1);
        move(player2);
end case;


My "case" statement
-------------------
case
   (player1.money <= 0)
   	end-game(player1);
   (player2.money <= 0)
	end-game(player2);
   otherwise
	move(player1);
        move(player2);
end case;


Or going the other way:

Standard Dylan "if" statement
-----------------------------
if (player1.money <= 0)
  end-game(player1)
elseif (player2.money <= 0)
  end-game(player2)
else
  move(player1);
  move(player2);
end if


My "if" statement
-----------------
if player1.money <= 0
  => end-game(player1)
elseif player2.money <= 0
  => end-game(player2)
else
  => move(player1);
     move(player2);
end if


If I can change this sort of stuff via macros (even if I have to make new
names for my control statements), then from a C programmers perspective,
that is a really cool feature. 


