|
From: Martin K. <Mar...@St...> - 2005-02-26 23:42:17
|
> Actually, there's nothing wrong with this (provided that I haven't
> misunderstood the issue):
>
> return A && B || C && D;
>
> is semantically equivalent to
>
> return (A && B) || (C && D);
>
> according to the Java language spec. The && operator is stronger than ||,
> so
> the extra brackets don't change the semantics.
Odd. I thought it is left handed like the +/- operators. Well I checked the
specs but I couldn't find the right paragraph. I found 15.23/24 and
the syntax grammar talking about infix-operations but no destinction
between those two.
But I checked it myself and you are right. I never relied on this, but
now I learned something new. ;-)
> Admittedly, the explicit brackets make the expression easier to read,
> though, so I've changed the code accordingly. We use explicit brackets in
> similar cases too, so this also makes sense for consistency.
Thanks,
Martin (Kersten)
> -----Original Message-----
> From: spr...@li...
> [mailto:spr...@li...]On Behalf
> Of Martin Kersten
> Sent: Friday, February 25, 2005 10:58 PM
> To: spr...@li...
> Subject: [Springframework-developer] Is BeanUtils.isAssignable correct?
>
>
> Hi folks,
>
> while reviewing the code I found a construct that distracted me.
> It is the BeanUtils.isAssignable method:
>
> /* Determine if the given type is assignable from the given value,
> * assuming setting by reflection. Considers primitive wrapper classes
> * as assignable to the corresponding primitive types.
> * [..] */
> public static boolean isAssignable(Class type, Object value) {
> return (value != null && isAssignable(type, value.getClass()) ||
> (value == null) && !type.isPrimitive());
> }
>
> It seams odd to have something like: a && b || c && d. That is
> not clearly clear which binds first and I guess this is not
> which was intended.
>
> By reducing the semantic we have:
>
> A => value!=null
> B => isAssignable...
> C => value==null
> D => !type.isPremitive()
>
> So it reads:
>
> return A && B || C && D; //What is this meaning?
> I would say that this always true.
> If it is not a premitve it is true, if it is null and not a premitve
> it is the only thing where it might be returning null.
>
> From the reading I guess it is ment to be:
>
> return (A && B) || (C && D);
>
>
> Cheers,
>
> Martin (Kersten)
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
|