www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - A new blog article detailing the alternative function syntax

reply "Gary Willoughby" <dev nomad.so> writes:
I've just finished a new blog article on the subject of 
alternative function syntax in D. I guess this is pretty 
straightforward stuff to all the people here but was a major 
source of confusion to me (and others?) when first learning D.

I personally think this is more confusing than many people think. 
Hopefully this will quickly arm a developer with knowledge to be 
able to read and understand most D code. Let me know if i've 
missed anything important.

http://nomad.so/2013/08/alternative-function-syntax-in-d/

I'll post to reddit in the morning.
Aug 08 2013
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 8/8/2013 11:53 AM, Gary Willoughby wrote:
 I personally think this is more confusing than many people think. Hopefully
this
 will quickly arm a developer with knowledge to be able to read and understand
 most D code. Let me know if i've missed anything important.

 http://nomad.so/2013/08/alternative-function-syntax-in-d/
s/compliments/complements/ s/-profile/-property/ s/behaviour/behavior/ if you mean to use the american english spelling s/explained the rules/explained that the rules/ s/ommited/omitted/ s/in the call parens/in the call then parens/ s/i've/I've/ Under Extension Methods, a huge reason for them is to head off the temptation to write 'kitchen sink' classes that are filled with every conceivable method. The desired approach is to have the class implement the bare minimum of functionality, and add other functionality with extension methods (that do not have access to the class' private state). All in all, good article!
Aug 08 2013
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 8/8/2013 12:15 PM, Walter Bright wrote:
 s/compliments/complements/
The frequency with which I see this error is a pet peeve of mine!
Aug 08 2013
parent "Brad Anderson" <eco gnuk.net> writes:
On Thursday, 8 August 2013 at 19:18:22 UTC, Walter Bright wrote:
 On 8/8/2013 12:15 PM, Walter Bright wrote:
 s/compliments/complements/
The frequency with which I see this error is a pet peeve of mine!
I know! It's rediculous!
Aug 08 2013
prev sibling next sibling parent reply "Gary Willoughby" <dev nomad.so> writes:
On Thursday, 8 August 2013 at 19:15:29 UTC, Walter Bright wrote:
 lots...
I've made the corrections, thanks. I really need to work on my English. I haven't written anything in years and it's harder work than i remember. Nothing that practise, practise, practise ...and a spell checker won't fix! ;)
Aug 08 2013
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 8/8/13 1:28 PM, Gary Willoughby wrote:
 On Thursday, 8 August 2013 at 19:15:29 UTC, Walter Bright wrote:
 lots...
I've made the corrections, thanks. I really need to work on my English. I haven't written anything in years and it's harder work than i remember. Nothing that practise, practise, practise ...and a spell checker won't fix! ;)
s/practise/practice/g :o) If you want me to post to reddit tomorrow morning, let me know. My good post karma is likely to push the post into visibility quickly. On the other hand, if you post it yourself it will improve _your_ karma. Tradeoffs, tradeoffs... Andrei
Aug 08 2013
parent reply "Gary Willoughby" <dev nomad.so> writes:
On Thursday, 8 August 2013 at 22:37:04 UTC, Andrei Alexandrescu 
wrote:
 If you want me to post to reddit tomorrow morning, let me know. 
 My good post karma is likely to push the post into visibility 
 quickly. On the other hand, if you post it yourself it will 
 improve _your_ karma. Tradeoffs, tradeoffs...
Sure go ahead.
Aug 09 2013
next sibling parent "monarch_dodra" <monarchdodra gmail.com> writes:
On Friday, 9 August 2013 at 08:03:45 UTC, Gary Willoughby wrote:
 On Thursday, 8 August 2013 at 22:37:04 UTC, Andrei Alexandrescu 
 wrote:
 If you want me to post to reddit tomorrow morning, let me 
 know. My good post karma is likely to push the post into 
 visibility quickly. On the other hand, if you post it yourself 
 it will improve _your_ karma. Tradeoffs, tradeoffs...
Sure go ahead.
Good read. I think I already knew all of it, but seeing it all written in a concise and organized way is always a good refresher, and also reminds you of the why things are the way they are.
Aug 09 2013
prev sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 8/9/13 1:03 AM, Gary Willoughby wrote:
 On Thursday, 8 August 2013 at 22:37:04 UTC, Andrei Alexandrescu wrote:
 If you want me to post to reddit tomorrow morning, let me know. My
 good post karma is likely to push the post into visibility quickly. On
 the other hand, if you post it yourself it will improve _your_ karma.
 Tradeoffs, tradeoffs...
Sure go ahead.
Much obliged: http://www.reddit.com/r/programming/comments/1k18ls/alternative_function_syntax_in_d_explained/ Andrei
Aug 09 2013
prev sibling parent reply "Brad Anderson" <eco gnuk.net> writes:
On Thursday, 8 August 2013 at 19:15:29 UTC, Walter Bright wrote:
 Under Extension Methods, a huge reason for them is to head off 
 the temptation to write 'kitchen sink' classes that are filled 
 with every conceivable method. The desired approach is to have 
 the class implement the bare minimum of functionality, and add 
 other functionality with extension methods (that do not have 
 access to the class' private state).
http://www.drdobbs.com/cpp/how-non-member-functions-improve-encapsu/184401197#.UW1X9HWZeXA.reddit I think you linked this Meyers article at some point as being the original rationale for UFCS (correct me if I'm wrong).
Aug 08 2013
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 8/8/2013 3:02 PM, Brad Anderson wrote:
 On Thursday, 8 August 2013 at 19:15:29 UTC, Walter Bright wrote:
 Under Extension Methods, a huge reason for them is to head off the temptation
 to write 'kitchen sink' classes that are filled with every conceivable method.
 The desired approach is to have the class implement the bare minimum of
 functionality, and add other functionality with extension methods (that do not
 have access to the class' private state).
http://www.drdobbs.com/cpp/how-non-member-functions-improve-encapsu/184401197#.UW1X9HWZeXA.reddit I think you linked this Meyers article at some point as being the original rationale for UFCS (correct me if I'm wrong).
You're right. I was just too lazy to link to it myself. Thanks for doing it. BTW, I think that article is required reading. It's an easy read, and was an eye-opener for me.
Aug 08 2013
next sibling parent Rory McGuire <rjmcguire gmail.com> writes:
Quick question: does UFCS allow you to make a type implement an interface?
Aug 09 2013
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Friday, August 09, 2013 12:25:25 Rory McGuire wrote:
 Quick question: does UFCS allow you to make a type implement an interface?
No. _All_ that UFCS does is take auto result = foo.bar(args); and lower it to auto result = bar(foo, args); It's purely syntactic sugar, much as that sugar has some great benefits for generic code. For a class to implement an interface method, that method must actually be part of the class or one of its base classes. - Jonathan M Davis
Aug 09 2013
prev sibling next sibling parent reply Ary Borenszweig <ary esperanto.org.ar> writes:
On 8/8/13 3:53 PM, Gary Willoughby wrote:
 I've just finished a new blog article on the subject of alternative
 function syntax in D. I guess this is pretty straightforward stuff to
 all the people here but was a major source of confusion to me (and
 others?) when first learning D.

 I personally think this is more confusing than many people think.
 Hopefully this will quickly arm a developer with knowledge to be able to
 read and understand most D code. Let me know if i've missed anything
 important.

 http://nomad.so/2013/08/alternative-function-syntax-in-d/

 I'll post to reddit in the morning.
Nice article. But when I read "alternative function syntax" I thought your article was a proposal for that, an alternative function syntax. :-P Maybe it should be renamed to something else... but I don't know enough English to suggest that.
Aug 08 2013
next sibling parent "Tofu Ninja" <emmons0 purdue.edu> writes:
On Thursday, 8 August 2013 at 19:24:31 UTC, Ary Borenszweig wrote:
 On 8/8/13 3:53 PM, Gary Willoughby wrote:
 I've just finished a new blog article on the subject of 
 alternative
 function syntax in D. I guess this is pretty straightforward 
 stuff to
 all the people here but was a major source of confusion to me 
 (and
 others?) when first learning D.

 I personally think this is more confusing than many people 
 think.
 Hopefully this will quickly arm a developer with knowledge to 
 be able to
 read and understand most D code. Let me know if i've missed 
 anything
 important.

 http://nomad.so/2013/08/alternative-function-syntax-in-d/

 I'll post to reddit in the morning.
Nice article. But when I read "alternative function syntax" I thought your article was a proposal for that, an alternative function syntax. :-P Maybe it should be renamed to something else... but I don't know enough English to suggest that.
Maybe "unique" instead of "alternative"?
Aug 08 2013
prev sibling parent "Dejan Lekic" <dejan.lekic gmail.com> writes:
On Thursday, 8 August 2013 at 19:24:31 UTC, Ary Borenszweig wrote:
 On 8/8/13 3:53 PM, Gary Willoughby wrote:
 I've just finished a new blog article on the subject of 
 alternative
 function syntax in D. I guess this is pretty straightforward 
 stuff to
 all the people here but was a major source of confusion to me 
 (and
 others?) when first learning D.

 I personally think this is more confusing than many people 
 think.
 Hopefully this will quickly arm a developer with knowledge to 
 be able to
 read and understand most D code. Let me know if i've missed 
 anything
 important.

 http://nomad.so/2013/08/alternative-function-syntax-in-d/

 I'll post to reddit in the morning.
Nice article. But when I read "alternative function syntax" I thought your article was a proposal for that, an alternative function syntax. :-P Maybe it should be renamed to something else... but I don't know enough English to suggest that.
I agree, the article title should be something like "Uniform Function Call Syntax". Exactly like in in this article: http://www.drdobbs.com/cpp/uniform-function-call-syntax/232700394 .
Aug 09 2013
prev sibling next sibling parent reply "anonymous" <anonymous example.com> writes:
On Thursday, 8 August 2013 at 18:53:47 UTC, Gary Willoughby wrote:
 I've just finished a new blog article on the subject of 
 alternative function syntax in D. I guess this is pretty 
 straightforward stuff to all the people here but was a major 
 source of confusion to me (and others?) when first learning D.

 I personally think this is more confusing than many people 
 think. Hopefully this will quickly arm a developer with 
 knowledge to be able to read and understand most D code. Let me 
 know if i've missed anything important.

 http://nomad.so/2013/08/alternative-function-syntax-in-d/

 I'll post to reddit in the morning.
I think you should mention the terms UFCS and IFTI, since those are used by D folk. UFCS: Universal Function Call Syntax, i.e. dot notation. IFTI: Implicit Function Template Instantiation, i.e. template parameters can be omitted when they can be deduced from the function arguments.
Aug 08 2013
parent "Gary Willoughby" <dev nomad.so> writes:
On Thursday, 8 August 2013 at 20:37:35 UTC, anonymous wrote:
 I think you should mention the terms UFCS and IFTI, since those 
 are used by D folk.

 UFCS: Universal Function Call Syntax, i.e. dot notation.
 IFTI: Implicit Function Template Instantiation, i.e. template 
 parameters can be omitted when they can be deduced from the 
 function arguments.
Good point.
Aug 08 2013
prev sibling parent reply "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Thursday, 8 August 2013 at 18:53:47 UTC, Gary Willoughby wrote:
 I've just finished a new blog article on the subject of 
 alternative function syntax in D. I guess this is pretty 
 straightforward stuff to all the people here but was a major 
 source of confusion to me (and others?) when first learning D.

 I personally think this is more confusing than many people 
 think. Hopefully this will quickly arm a developer with 
 knowledge to be able to read and understand most D code. Let me 
 know if i've missed anything important.

 http://nomad.so/2013/08/alternative-function-syntax-in-d/

 I'll post to reddit in the morning.
The second non-member function example is part of the -property controversy. foo = 123; // called as foo(123) Not sure if you'd want that mentioned.
Aug 08 2013
parent Miles Stoudenmire <miles.stoudenmire gmail.com> writes:
s/quiet easily/quite easily/g

Nice article. I wish C++ had UFCS...


On 8 August 2013 20:40, Jesse Phillips <Jesse.K.Phillips+D gmail.com> wrote:

 On Thursday, 8 August 2013 at 18:53:47 UTC, Gary Willoughby wrote:

 I've just finished a new blog article on the subject of alternative
 function syntax in D. I guess this is pretty straightforward stuff to all
 the people here but was a major source of confusion to me (and others?)
 when first learning D.

 I personally think this is more confusing than many people think.
 Hopefully this will quickly arm a developer with knowledge to be able to
 read and understand most D code. Let me know if i've missed anything
 important.

 http://nomad.so/2013/08/**alternative-function-syntax-**in-d/<http://nomad.so/2013/08/alternative-function-syntax-in-d/>

 I'll post to reddit in the morning.
The second non-member function example is part of the -property controversy. foo = 123; // called as foo(123) Not sure if you'd want that mentioned.
-- -=Miles Stoudenmire=- miles.stoudenmire gmail.com estouden uci.edu http://itensor.org/miles/
Aug 08 2013