Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: [Perl 6] Even more freedom for custom operators?

by ForgotPasswordAgain (Deacon)
on Sep 18, 2007 at 14:21 UTC ( #639652=note: print w/ replies, xml ) Need Help??


in reply to [Perl 6] Even more freedom for custom operators?

I read recently about a "juxtaposition operator" in Fortress. This is the (overloadable) operator that allows "A x" to mean "A multiplied by x". Coupled with the ability to use unicode for things like sums, etc., it makes a beautiful syntax for mathematicians.


Comment on Re: [Perl 6] Even more freedom for custom operators?
Re^2: [Perl 6] Even more freedom for custom operators?
by blazar (Canon) on Sep 18, 2007 at 15:17 UTC
    [...] it makes a beautiful syntax for mathematicians.

    Very true! But I think it will never fit into Perl. For the likes of ambrus there are J and K, one of which must be the language he used in his cool reply to a post of mine.

Re^2: [Perl 6] Even more freedom for custom operators?
by ikegami (Pope) on Sep 18, 2007 at 15:34 UTC

    I don't know about Perl 6, but Perl 5 parses code differently based on whether an operator or expression is expected. This probably makes such an operator impossible to implement. Worse yet, the context dependency happens with every basic math operator:

    $y = 2+$x; # + = addition operator $y = +$x; # + = disambiguation operator $y = 2-$x; # - = subtraction operator $y = -$x; # - = arithmetic negation operator $y = 1*FOO; # * = multiplication operator $y = *FOO; # * = Glob sigil $y = 1/... # / = division operator $y = /... # / = match operator

    How would you write something as simple as "$A multiplied by the negation of $x" using this operator?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2014-08-30 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls