develooper Front page | perl.perl6.language | Postings from May 2005

Re: How do I... create a new meta operator?

Thread Previous
May 20, 2005 01:58
Re: How do I... create a new meta operator?
Message ID:
HaloO Luke,

you wrote:
> I wonder how we specify meta
> operators that only work on comparators, or only on assignment forms,
> or etc. etc. etc.

Well, Perl6 has got first class Code types, hasn't it?
So it's a matter of defining a type hierarchy among the
operators and then you can dispatch on them with MMD or
restrict applicable types for non-invocant params.
Ingo's &infix_circumfix_meta_operator:{'->', '<-'}:(Code,Any,Any:)
could then easily be specialized like
  &infix_circumfix_meta_operator:{'->', '<-'}
   :(Comparator of ::T, T does Compare[T], T does Compare[T] :)
or less specific, of course.

The above said, I hope that the degree to which meta ops are
macro/compiler supported versus how much they lean onto the
type system is favoring the type system. The typical Perl < 6
programmer seems for historical reasons more inclined to think
about this language feature more in terms of combinations of
eval, join and split. E.g. could the macro assistence for »« and []
be restricted to parse their inside as an operator name so that
the programmer doesn't have to use their long name? Or is something
more complicated needed? And if yes, then why?

TSa (Thomas Sandlaß)

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About