Omissible Parentheses...

Leandro Lucarella llucax at gmail.com
Sun Aug 2 11:02:37 PDT 2009


Michiel Helvensteijn, el  2 de agosto a las 16:25 me escribiste:
> KennyTM~ wrote:
> 
> >> Interesting.  I don't think I've seen this angle yet.
> >> 
> >> Could you provide code examples, please?
> > 
> > "<p>yes?</p>".replace("<", "&lt;").replace(">", "&gt;");
> 
> Sure, but they have parameters, so they require parentheses anyway. Robert
> Jacques was talking about omissible parentheses for function chaining. That
> would require parameter-less functions.

Well, just take parameter-less functions then:

" hello   ".strip.toupper.replace("O", "A"); // "HELLA"

(I don't know if that even compiles in D2)

I think it's better to have mandatory (), though. Even when you save
a couple of strokes there, I find that code way more confusing than the
same with () (from that code it looks like hello has a strip property
which in case have a toupper property which then have a replace method).

Again, is a tradeoff between writeability and readability. I think is way
more important to prioritize readability.

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
- i bet microsoft's developers were on diet when they had to do win95
- microsoft has developers?



More information about the Digitalmars-d mailing list