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

Re: Perl::Improved Volume 0, Number 1

by theorbtwo (Prior)
on Sep 05, 2004 at 11:44 UTC ( #388591=note: print w/replies, xml ) Need Help??

in reply to Perl::Improved Volume 0, Number 1

Your abs() critique raises points that I haven't seen raised around here before, at least in this purticular context... but it gets the conclusion wrong, by (I suspect conciously) only considering the point against the status quo -- that is, that there is a convention for writing the absolute value in mathematics, and that perl should follow that convention.

This misses a whole slew of points in the other direction. The first, and probably most important, is that special cases are bad. There's a whole bunch of functions in perl, and there's no purticular reason that this purticular function should be written differently then the rest of them. It's simply not that important. There are functions that do have special syntax -- +, -, *, /, %, x, for example -- but those are generally more important -- indeed, even in math, they're normally called "operators", not "functions".

Secondly, there's also a convention in other programming languages to use abs() as the absolute-value function.

Thirdly, we already have uses for |, and important ones at that. It turns out they don't conflict as a matter of grammar, but they can easily conflict within the mind of the programmer.

Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Replies are listed 'Best First'.
Re^2: Perl::Improved Volume 0, Number 1
by Corion (Patriarch) on Sep 05, 2004 at 13:31 UTC

    I'm not convinced that the use of |...| to mean abs(...) doesn't break the existing grammar or introduces ugly whitespace dependency:

    can be naively parsed as
    or as

    because the ugly unary + is allowed, which breaks lots of things. Of course, introducing another slew of operator precedence could fix this, but I imagine it creates more confusion than the "clearer" syntax removes.

      Ah, thank you! My intuition told me that they conflicted, but I couldn't come up with a case -- largely because I forgot about unary +.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^2: Perl::Improved Volume 0, Number 1
by Aristotle (Chancellor) on Sep 05, 2004 at 13:41 UTC

    I'd guess these points haven't been raised before because noone feels the need, and because most people instinctively understand that this particular proposition cannot possibly work.

    He'll be able to try this and any other outlandish ideas he thinks would make the language better for himself once Perl6 is here.

    Makeshifts last the longest.

      Next we'll need to have "Keyboard::Improved" to give us keys to represent other mathematical functions such as the integral symbol, the nth root symbol, longhand division symbols, Pi, Sigma, and so on. Seriously, if we're going to nitpick about abs() versus |-5|, we'll have to do away with the entire fn() idiom as applied to the programmers version of mathematical symbols.


    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2022-01-24 19:43 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (65 votes). Check out past polls.