[% setvar title Allow keywords in sub prototypes %]
Note: these documents may be out of date. Do not use as reference! |
To see what is currently happening visit http://www.perl6.org/
Allow keywords in sub prototypes
Maintainer: Simon Cozens <simon@brecon.co.uk> Date: 25 Sep 2000 Mailing List: perl6-language-subs@perl.org Number: 309 Version: 1 Status: Developing
This is a general way of helping people create their own syntax.
The perlsub documentation talks about the use of &
in a prototype:
The interesting thing about C<&> is that you can generate new syntax with it, provided it's in the initial position
Well, you can, within limits. But it would fix a lot of things that people believe they want if you could really define your own syntax.
sub apply (& to @) { ... } apply { this } to @that;
This becomes a little bit of a nightmare for the parser; but TeX manages it.
In fact, it's not as hard as it looks, because you still know what you're expecting: after a block, we want some whitespace and the keyword "to", then some more whitespace and an array. Since we may well be having the parser dynamically modifiable, this should be easy. Yeah, right.
RFC 57: Subroutine prototypes and parameters
RFC ??: Byte-compiled Parser
RFC ??:use syntax