Thanks for this suggestion, Ben.  I ultimately went with a combination of this 
suggestion (dynamically determining associativity) and Ronald's suggestion 
(allowing the user to choose).  My parser will start with the associativity 
used by NSExpression, but provides a property to change it.

Thanks!

Dave

On Nov 21, 2010, at 3:33 AM, Ben Haller wrote:

>  Another option would be to make your code mimic whatever NSExpression is 
> doing on that machine, by evaluating 2 ** 3 ** 2 (once, and caching the 
> result) and seeing whether it comes out as 64 or 512.  That way if/when Apple 
> fixes their bug, your code will seamlessly follow suit.
> 
>  Which of these alternatives is best depends upon how your code is going to 
> be used, of course.  Roland's suggestion of a compatibility switch seems 
> good; the behavior I suggest could be a third option for that switch.  Then 
> the user of the class can decide what they want to get.  Probably the best 
> default would be to use the correct (right associative) parsing, though, as 
> it seems unlikely that a whole lot of code specifically depends upon this bug 
> in NSExpression, so for most clients there is probably no need to propagate 
> the buggy behavior...
> 
> Ben Haller
> McGill University
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to