In RFC 23, Damian Conway <[EMAIL PROTECTED]> proposes a syntax for
"higher-order functions".  One example given is related to a proposed
switch statement (RFC 22).  A trimmed version is:

>       sub beverage {
>               switch (shift) {
>                       case sub{ $_[0] < 10 }  { return 'milk' }
>                       case sub{ $_[0] < 20 }  { return 'coke' }
>                       else                    { return 'milk' }
>               }
>       }

which it is proposed could be re-written as:

>       sub beverage {
>               switch (shift) {
>                       case  __ < 10  { return 'milk' }
>                       case  __ < 20  { return 'coke' }
>                       else           { return 'milk' }
>               }
>       }

While I appreciate and applaud the attempt to solve a specific problem
with a generalized mechanism, it occurs to me that another general way to
attack this same problem might be through some sort of macro language.

As a trivial example, using CPP (*not* what I'd propose for perl6),
the switch example could be written 

#define arg_lt(X)       sub{ $_[0] < (X) }

        sub beverage {
                switch (shift) {
                        case  arg_lt(10)  { return 'milk' }
                        case  arg_lt(20)  { return 'coke' }
                        else           { return 'milk' }
                }
        }

I submit this is at least as clear as the __ version.

So I'd like to encourage folks to consider whether adding some sort of
(optional) macro language (perlpp ?) to perl6 would be worthwhile.
Folks with experience with a variety of macro languages would be more
qualified than I to develop an RFC on the subject, but I think it's
worth pursuing.

-- 
    Andy Dougherty              [EMAIL PROTECTED]
    Dept. of Physics
    Lafayette College, Easton PA 18042


Reply via email to