Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: how to self define a operator

by rjt (Curate)
on Oct 22, 2019 at 06:19 UTC ( #11107823=note: print w/replies, xml ) Need Help??

in reply to how to self define a operator

What you want to do would require modifying the language with new syntax. Hopefully needless to say, such endeavors are difficult, dangerous, and likely to be a waste of time, even if you are already a language specialist. To wit, the ~~ (smartmatch) binary operator was added to a public release almost 12 years ago, and it's still not stable.

You might be able to hack something together with source filters that sort of works in limited cases, but please don't. Odds of something like that breaking in simultaneously spectacular and sneaky fashion are unacceptably high for anything other than toy programs.

Would you mind sharing more details on what you are actually trying to accomplish (apart from inventing syntax)? A proper description of what you are actually working on would help us help you. There may well be an easy, elegant solution in pure Perl.

Replies are listed 'Best First'.
Re^2: how to self define a operator
by toothedsword (Sexton) on Oct 22, 2019 at 07:49 UTC

    Thank you very much for your reply!

    What I want to do is making the PDL more simple, as simple as matlab :D.

    for example, if we want to transfer the values from $t(1:4,0,0) to $d1(0,0:3), we can not write as below, because the dimensions are not same.

    $d1(0,0:3) .= $t(1:4,0,0);

    We have to write as this:

    $d1(0,0:3) .= $t(1:4,0,0)->reshape($d1(0,0:3)->dims);

    So I think if I can generate a "_=" which equal to .= $t(1:4,0,0)->reshape($d1(0,0:3)->dims or using a new method "rp" as $d1(0,0:3)->rp($t(1:4,0,0));

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11107823]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2023-03-27 04:43 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (63 votes). Check out past polls.