and recieving code does something like$foo->bar(myarg1 => "myval", myarg2 => "baz");
sub bar { my $self = shift @_; my $args = Argpass::new('strictpolicy', @_); my $argone = $args->accept('myarg1', 'defaultvalue'); my $argtwo = $args->mandate('myarg2'); $args->argok(); # And the function goes on, provided all mandated arguments are passed + in and any arguments that needed type checking passed it successfull +y, anything that needed processing was processed, etc.. # ... # ... }
(fill in a number of additional possibly meaningful and useful ways to automagically pass arguments around, some mandatory, some not, some with defaults, include some typechecking, etc)
This works, and it's been used on some reasonably large projects. It would be useful to add a new 'policy' allowing me to do a kind of reflection - to force the caller, as soon as argument passing is finished (when argok() is called) to return with a structured set of data describing the parameters it takes based on all these accept/mandate/etc methods. Unfortunately, after staring at caller(), goto, etc, I don't see a way to do this.
In short, is there a way, from a subroutine/method to force your caller to return with a value you specify? (let's assume we don't want to complicate the caller with conditionals and have it do the returning)
In reply to Force caller to return - reflection by Improv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |