in reply to Re: How about class Foo {...} definition for Perl?
in thread How about class Foo {...} definition for Perl?

Do you have some idea of how to make this without filtering, and without rebuild Perl?

I suse Filter::Simple, and this is not very stable, since is very easy to break the syntax, specialy the place holders that Text::Balanced uses, that accept any char from 0 to 255, what will mess with the code if you have to much place holders, since you start to get #, @ , $ , @ , % in the code.

I have fixed the problem using my own place holder over the previous place holder, but this is a hard work.

Other fixes were made, because Text::Balanced also mess with q|qq|qr|qw|qx|tr|y|s|m! Well, I'm trying to make the best work here and test it a lot!

Graciliano M. P.
"Creativity is the expression of the liberty".

  • Comment on Re: Re: How about class Foo {...} definition for Perl?

Replies are listed 'Best First'.
Re: Re: Re: How about class Foo {...} definition for Perl?
by hardburn (Abbot) on Jan 18, 2004 at 14:14 UTC

    It'd be difficult to get exactly the same syntax without a filter. A subroutine named class with a prototype of (@&) could get you part way there. It could be called like class 'Foo' extends => qw( Bar Baz ) { . . . };.

    Instead of using the builtin sub definition, you could create a new subroutine named method with a prototype of ($@&) which could be called as method method_name => ('$attr1', '@attr2', '%attr3') { . . . };. This would then generate the regular Perl subroutine.

    I probably got the prototypes wrong, as I don't usually have a use for them.

    Alternatively, you can do what everybody else is doing: wait for Perl6 :)

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    : () { :|:& };:

    Note: All code is untested, unless otherwise stated