digitalmars.D.learn - object.function()
- %u (3/3) May 13 2011 I have a question,
- Timon Gehr (2/5) May 13 2011 This currently only works for D arrays. (I think Walter&Andrei wanted it...
- Jonathan M Davis (12/18) May 13 2011 It currently only works for arrays. IIRC, the fact that it ever worked t...
I have a question, can I write all functions like this object.function() instead of functin(object) ? or that form for some function or cases.
May 13 2011
I have a question, can I write all functions like this object.function() instead of functin(object) ? or that form for some function or cases.This currently only works for D arrays. (I think Walter&Andrei wanted it for other types too originally, I do not know if it will be implemented.)
May 13 2011
It currently only works for arrays. IIRC, the fact that it ever worked that way in the first place was a bug rather than intended, but it was determined to be useful and was kept around. There has been a push to make it it so that it works for _everything_ (so-called Universal Function Call Syntax) - which would make stuff like 3.min(4) legal. It's not clear however whether that will ever happen. If nothing else, there are a number of design and implementation issues which may make it too difficult to reasonably implement. In particular, would increase the number possible ambiguities in code, which would cause problems. So, it may or may not ever be implemented, and if it is implemented, it may only be implemented in a restricted sense. Regardless, for now, it only works with arrays. - Jonathan M DavisI have a question, can I write all functions like this object.function() instead of functin(object) ? or that form for some function or cases.This currently only works for D arrays. (I think Walter&Andrei wanted it for other types too originally, I do not know if it will be implemented.)
May 13 2011