digitalmars.D - [guards] syntax extension?
- Manfred Nowak (20/20) Aug 06 2005 I usually prefer head/body speaking, i.e. first the main rule, then
- Chris Sauls (13/37) Aug 07 2005 You can also do:
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
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