in reply to Prototypes and hand-written MMD
Your question was nearly incomprehensible because you start out with a code example that is simply a syntax error. My first guess was that you were asking a Perl6 question but didn't bother to say so.
The problem you'll run into is more likely that you can't have two different prototypes for class() (plus a bunch of other problems). But ignoring your first proposal, sub class(&), (since it is probably incompatible with your primary question) you are incorrect in your thinking on how to make class 'Foo' is { ... } work...
The prototype for sub class shouldn't be ($&) since you aren't putting a block as the second argument to class() (tho, & only really works for first arguments anyway). Your second argument to class() is a plain expression that returns a code reference. The prototype of is() is what handles the bare block, not the prototype of class() at all.
The next problem is that you don't want to put a comma between 'Foo' and is{...}. That means you've got that extra-vague syntax that /might/ get interpretted as indirection object syntax (but might not, and is pretty easy to break besides).
So, Perl might interpret your code as 'Foo'->class( is { ... } ) (but it might not, depending).
But my primary advice is to turn back now. Please don't make another module that tries to fool the perl interpretter into understanding some non-Perl5 syntax. Let the people reading Perl5 code and expecting to find Perl5 code understand the code. Attempts to invent alternate syntax always end up being quite fragile; that is, they often confuse the computer in addition to confusing the human.
Next you can try source filters. I hope you have the sense not to, however.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Prototypes and hand-written MMD (Ah! No!!)
by dragonchild (Archbishop) on Jan 10, 2006 at 14:08 UTC | |
by diotalevi (Canon) on Jan 10, 2006 at 16:49 UTC |