Quantcast

New operator overloading ! (not operator)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

New operator overloading ! (not operator)

Arturo Herrero
I think it's worth to overloading ! (not operator)

We've a code more clear:

if (! isAdmin()) {
    println "You don't have permission to access on this server"
}


if (not(isAdmin())) {
    println "You don't have permission to access on this server"
}

What do you think?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: New operator overloading ! (not operator)

Marc Wrobel
I do not think so. Using ! operator is so common for a developper I think it does not make so much difference.

And not using a negation operator is even more clear (and it could be nice if it was auto-generated by groovy from the "isAdmin" method) :

if (isNotAdmin()) {
   println "You don't have permission to access on this server"
}

Marc

On Sun, Sep 4, 2011 at 21:31, Arturo Herrero <[hidden email]> wrote:
I think it's worth to overloading ! (not operator)

We've a code more clear:

if (*!* isAdmin()) {
   println "You don't have permission to access on this server"
}


if (*not(*isAdmin()*)*) {
   println "You don't have permission to access on this server"
}

What do you think?

--
View this message in context: http://groovy.329449.n5.nabble.com/New-operator-overloading-not-operator-tp4768200p4768200.html
Sent from the groovy - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: New operator overloading ! (not operator)

Guillaume Laforge-4
You can always use some expando metaclass trick, or an AST transformation, to add those isNot methods.

On Mon, Sep 5, 2011 at 06:47, Marc Wrobel <[hidden email]> wrote:
I do not think so. Using ! operator is so common for a developper I think it does not make so much difference.

And not using a negation operator is even more clear (and it could be nice if it was auto-generated by groovy from the "isAdmin" method) :

if (isNotAdmin()) {

   println "You don't have permission to access on this server"
}

Marc


On Sun, Sep 4, 2011 at 21:31, Arturo Herrero <[hidden email]> wrote:
I think it's worth to overloading ! (not operator)

We've a code more clear:

if (*!* isAdmin()) {
   println "You don't have permission to access on this server"
}


if (*not(*isAdmin()*)*) {
   println "You don't have permission to access on this server"
}

What do you think?

--
View this message in context: http://groovy.329449.n5.nabble.com/New-operator-overloading-not-operator-tp4768200p4768200.html
Sent from the groovy - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email






--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: New operator overloading ! (not operator)

deigote
In reply to this post by Marc Wrobel
I agree with Arturo, not is much more clear than !. I've always found funny that Java, as verbose as it's supposed to be, uses on of the thinnest characters for an operation that changes the expression meaning to the opposite! (yes, I know that is a C heritage, but still... nonsense :-).

Debugging a misplaced not in Java (and then in Groovy) has always been painful for me (more accurately, for my eyes :-D).

I guess not so many Java people would use the not (I would anyway :-), but it probably would help programmers from other languages such as Python.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: New operator overloading ! (not operator)

Paulo Gabriel Poiati
I liked the Marc suggestion. And we can do this through an AST.

[]'s
Paulo Poiati

blog.paulopoiati.com


On Mon, Sep 26, 2011 at 11:48 AM, deigote <[hidden email]> wrote:
I agree with Arturo, not is much more clear than !. I've always found funny
that Java, as verbose as it's supposed to be, uses on of the thinnest
characters for an operation that changes the expression meaning to the
opposite! (yes, I know that is a C heritage, but still... nonsense :-).

Debugging a misplaced not in Java (and then in Groovy) has always been
painful for me (more accurately, for my eyes :-D).

I guess not so many Java people would use the not (I would anyway :-), but
it probably would help programmers from other languages such as Python.

--
View this message in context: http://groovy.329449.n5.nabble.com/New-operator-overloading-not-operator-tp4768200p4841636.html
Sent from the groovy - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Loading...