perlquestion
blazar
<p>First of all, let me premise that this is a <em>"just out of curiosity kinda question"</em>.</p>
<p>As of the Subject, if <c>$obj</c> holds a [doc://bless]ed reference, and <c>$action</c> is a [doc://perlref|subref], then in</p>
<c>
$obj->$action(@args);
</c>
<p>the latter will be called as if it were an object method. (Similarly if instead of <c>$obj</c> you have a bareword, in which case it will be called like a class method.) I like to use this mechanism, sometimes, to implement callbacks. "Of course", it also works if instead of <c>$obj</c> you have an expression returning an object. OTOH generally wherever a variable holding a subref is used, an expression returning one (especially an anonymous sub altogether) could be used instead, but I don't <em>think</em> in this one: any kind of parentheses I may put around the expression would be parsed as some kind of dereferencing. Similarly, I can't hope in putting anything in <c>${ }</c> beacause that is parsed as scalar dereferencing as of itself.</p>
<p>As I said above, not that I really need this "feature", but <em>is there a way to "inline" a subref as hinted above?</em> Somehow it strikes me as as something that should be doable if not for anything else for completeness sake...</p>
<p>Now, just like you can disambiguate between grouping parens and sub call's ones with a unary plus, what I want if not available in other ways, may have a syntax like the following:</p>
<c>
$obj->+(EXPR)(@args);
</c>
<p>Admittedly, I suppose that could make a hell to parse...</p>