www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [guards] syntax extension?

reply Manfred Nowak <svv1999 hotmail.com> writes:
I usually prefer head/body speaking, i.e. first the main rule, then 
the fine grained exceptions.

What about a syntax extension with the keywords `guarded' and 
`guards'. Example:

int ackermann( int m, int m)
{
    if(!m) return n + 1;
    if(!n) return ackermann( m-1, 1);
    return( ackermann( m-1, ackermann( m, n-1)));
}

would turn to:

int ackermann( int m, int n)
{
  guarded return( ackermann( m-1, ackermann( m, n-1)));

  guards{
    !m: return n + 1;
    !n: return ackermann( m-1, 1);
  }
} 

-manfred
Aug 06 2005
parent Chris Sauls <ibisbasenji gmail.com> writes:
Manfred Nowak wrote:
 I usually prefer head/body speaking, i.e. first the main rule, then 
 the fine grained exceptions.
 
 What about a syntax extension with the keywords `guarded' and 
 `guards'. Example:
Its an interesting concept...
 int ackermann( int m, int m)
 {
     if(!m) return n + 1;
     if(!n) return ackermann( m-1, 1);
     return( ackermann( m-1, ackermann( m, n-1)));
 }
 
 would turn to:
 
 int ackermann( int m, int n)
 {
   guarded return( ackermann( m-1, ackermann( m, n-1)));
 
   guards{
     !m: return n + 1;
     !n: return ackermann( m-1, 1);
   }
 } 
 
You can also do: -- Chris Sauls
Aug 07 2005