At the risk of being repetitious, I wanted to second this 
statement/paragraph from Michael:

> I'd reserve the no-parenthesis method version for situations where it
> really could be a field (and maybe was in one implementation).

In my previous response, I was focusing more on the specific case of abs() 
than the philosophical question that you were really asking (and which 
Michael did a better job of answering).

When deciding between x.foo (as a parenthesis-less method) and x.foo(), we 
usually ask ourselves whether the thing feels "field-like" (a space-time 
tradeoff that one has decided to take in the "time" direction, but could 
just as easily have taken in the other direcetion) vs. "computation-like" 
-- expecting that some sort of non-trivial computation needs to take place 
to get the result.

Another aspect of the decision process is that parenthesis-less methods 
are not dynamically dispatched (like field accesses), so if one required 
dynamic dispatch, you'd want to the parentheses-based approach.

As far as methods vs. standalone functions, I agree with Michael there as 
well:  For the most part, I tend toward using methods to reduce namespace 
pollution unless the interface that the likely user community is 
accustomed to uses standalone functions.

The other main cases where I use standalone functions are ones in which 
there isn't a most logical object to attach the routine to (e.g., a binary 
operation implemented as a function rather than an operator overload).

-Brad


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to