[PLA] #00009: Extended syntax proposal based on PLA #00004
Clifford Wolf
clifford at clifford.at
Wed Dec 5 09:43:16 CET 2007
Hi,
On Sun, Dec 02, 2007 at 06:30:24PM +0100, Clifford Wolf wrote:
> Macros can be used whenever an expression is excepted. They start with
> the '.' character and the macro processer may access the parser to
> test-parse code snippets and so find the begin and end of an expression.
It just came to my mind: we do not need the '.' prefix: all pre-defined
macros are used in a pattern which would result in an syntax error if they
would be identifiers.
So it would absolutely possible to simply define the macro "if" without
loosing the probability of also declaring a variable "if" and use it
without any limitations..
> .define .if ( $0 ) $1; .else $2;
> . (( $0 ) ? ( $1 ) : ( $2 ));
>
> .define .while ( $0 ) $1;
> . (@ ( $0 ) : ($1));
>
> .define .do { $0 } .while ( $1 )
> . (@ ( $0 ; $1 ))
>
> .define .foreach $0! ( $1 ) $2;
> . (_$0_ := $1; @ (_$0_).next() : ( $0 := _$0_.current; $2 ));
>
> .define .function ( $0 ) { $1 }
> . { Arguments(%, "$#0"); __function_blk__ :: ( $1 ); }
>
> .define .function $0! ( $1 ) { $2 }
> . $0 := { Arguments(%, $#1); __function_blk__ :: ( $2 ); }
>
> .define .return $0;
> . (>> __function_blk__ ($0));
>
> .define .throw $1;
> . ( ## ($1) );
>
> .define .try ( $1 ) $2[ .catch $3! $4 ( $5 ) $2] $6[ .catch_all $7! ( $8 ) $6]
> . ( # ($1) : __try_ok__ :: ( $2[ __try_type__ := ($4);
> . %# ?> __try_type__ ? ( $3 := %# -> __try_type__; $5;
> . >>__try_ok__; ); $2] $6[ ( $7 := %#; $8; >>__try_ok__;
> . ); $6] ## %# ) )
>
> .define .defined $1?
> . (? $1)
>
> .define .declared $1?
> . (?? $1)
yours,
- clifford
--
"Paranoia is faith in a hidden order behind the visible."
- pi, the movie
More information about the PLA
mailing list