Perl-Apollo / Corinna

Corinna - Bring Modern OO to the Core of Perl
Artistic License 2.0
157 stars 19 forks source link

Dynamic generation of ... stuff #14

Open shadowcat-mst opened 4 years ago

shadowcat-mst commented 4 years ago

I mean, logically, I guess I can eval up an entire class in a BEGIN block or something ... but it'd be nice to be able to generate two or three methods dynamically all the same.

Ideally, I'd be able to do 'method $name (...) { ... }' but 'name = method (...) { ... }' or some similar syntax would also be fine, I just want some way to be able to generate two or three methods in a foreach loop or similar (and I'd like* to be able to do it for attributes as well, ideally).

If we want to be able to close the class at the end of the 'class { ... }' block I have no issue with having to do whatever I'm doing in a 'BEGIN { ... }' block inside the class block ... but I really do need some way to do that.

Ovid commented 3 years ago

This might be possible via the MOP. I cannot say, but maybe @leonerd can?

Unless this is trivial, I'm marking this as Post-MVP.

leonerd commented 3 years ago

There's plenty of MOP thoughts already, in https://metacpan.org/pod/Object::Pad::MOP::Class and the related ::Slot and ::Method.

Ovid commented 2 years ago

Leaving this open because I suspect it will be relevant to @leonerd's work on the MOP.

Ovid commented 2 years ago

Closed by accident,