I want to overload an operator (ideally '~~') but want the result to be a list. It seems like that's not possible, the list is only handled like in scalar context.Indeed. There were some messages on p5p about this quite recently. I think the outcome was "No, that's not possible. The implementor (Ilya) of overloading deemed it not necessary to be able to ask the context - that is, the operands are always in scalar context".
Note that when overloading was implemented, '~~' wasn't an operator, and only a few overloadable operators would behave differently in list context anyway. (<> being the obvious on. x behaves different in list context as well, but only if its LHS has parens, making it an odd one).
In reply to Re: Operator overloading with returning lists?
by JavaFan
in thread Operator overloading with returning lists?
by renormalist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |