Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 26, 2010 Uniform function call syntax | ||||
---|---|---|---|---|
| ||||
I've asked this before, probably several times: if and when will D get the uniform function call syntax that has been talked about? Example:
void foo (int i) {}
3.foo();
And please don't say it's already implemented because it isn't, I've heard that before.
--
/Jacob Carlborg
|
May 26, 2010 Re: Uniform function call syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | Wed, 26 May 2010 22:05:48 +0200, Jacob Carlborg wrote: > I've asked this before, probably several times: if and when will D get the uniform function call syntax that has been talked about? Example: > > void foo (int i) {} > 3.foo(); > > And please don't say it's already implemented because it isn't, I've heard that before. Are you sure you're not confusing two things. "The uniform access says that client code should not be affected by a decision to implement an attribute as a field or method." -- Programming in Scala The other is a term known as extension methods. "Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type." -- http:// msdn.microsoft.com/en-us/library/bb383977.aspx |
May 26, 2010 Re: Uniform function call syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to retard | On Thu, 27 May 2010 01:41:16 +0200, retard <re@tard.com.invalid> wrote: > Wed, 26 May 2010 22:05:48 +0200, Jacob Carlborg wrote: > >> I've asked this before, probably several times: if and when will D get >> the uniform function call syntax that has been talked about? Example: >> >> void foo (int i) {} >> 3.foo(); >> >> And please don't say it's already implemented because it isn't, I've >> heard that before. > > Are you sure you're not confusing two things. > > "The uniform access says that client code should not be affected by a > decision to implement an attribute as a field or method." -- Programming > in Scala > > The other is a term known as extension methods. "Extension methods enable > you to "add" methods to existing types without creating a new derived > type, recompiling, or otherwise modifying the original type." -- http:// > msdn.microsoft.com/en-us/library/bb383977.aspx http://s3.amazonaws.com/dconf2007/WalterAndrei.pdf Page 9. The idea is that foo(bar) may be replaced with bar.foo() and vice versa, making function calls 'uniform' in that both member functions and free functions may be called in the same manner. -- Simen |
May 27, 2010 Re: Uniform function call syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | Thu, 27 May 2010 01:52:32 +0200, Simen kjaeraas wrote:
> On Thu, 27 May 2010 01:41:16 +0200, retard <re@tard.com.invalid> wrote:
>
>> Wed, 26 May 2010 22:05:48 +0200, Jacob Carlborg wrote:
>>
>>> I've asked this before, probably several times: if and when will D get the uniform function call syntax that has been talked about? Example:
>>>
>>> void foo (int i) {}
>>> 3.foo();
>>>
>>> And please don't say it's already implemented because it isn't, I've heard that before.
>>
>> Are you sure you're not confusing two things.
>>
>> "The uniform access says that client code should not be affected by a decision to implement an attribute as a field or method." -- Programming in Scala
>>
>> The other is a term known as extension methods. "Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type." -- http:// msdn.microsoft.com/en-us/library/bb383977.aspx
>
> http://s3.amazonaws.com/dconf2007/WalterAndrei.pdf
>
> Page 9. The idea is that foo(bar) may be replaced with bar.foo() and
> vice versa, making function calls 'uniform' in that both member
> functions and free functions may be called in the same manner.
I understood what you meant. It's just that the idea was invented before in C#. I usually give attribution to (and favor the term invented by) the original innovator, not the copycat. Those two features have only few differences, for example C# requires importing the symbols first with 'using'. The proposed D feature is more careless here.
|
May 27, 2010 Re: Uniform function call syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to retard | On Wed, 26 May 2010 20:44:50 -0400, retard <re@tard.com.invalid> wrote:
> Thu, 27 May 2010 01:52:32 +0200, Simen kjaeraas wrote:
>
>> On Thu, 27 May 2010 01:41:16 +0200, retard <re@tard.com.invalid> wrote:
>>
>>> Wed, 26 May 2010 22:05:48 +0200, Jacob Carlborg wrote:
>>>
>>>> I've asked this before, probably several times: if and when will D get
>>>> the uniform function call syntax that has been talked about? Example:
>>>>
>>>> void foo (int i) {}
>>>> 3.foo();
>>>>
>>>> And please don't say it's already implemented because it isn't, I've
>>>> heard that before.
>>>
>>> Are you sure you're not confusing two things.
>>>
>>> "The uniform access says that client code should not be affected by a
>>> decision to implement an attribute as a field or method." -- Programming
>>> in Scala
>>>
>>> The other is a term known as extension methods. "Extension methods
>>> enable you to "add" methods to existing types without creating a new
>>> derived type, recompiling, or otherwise modifying the original type."
>>> -- http:// msdn.microsoft.com/en-us/library/bb383977.aspx
>>
>> http://s3.amazonaws.com/dconf2007/WalterAndrei.pdf
>>
>> Page 9. The idea is that foo(bar) may be replaced with bar.foo() and
>> vice versa, making function calls 'uniform' in that both member
>> functions and free functions may be called in the same manner.
>
> I understood what you meant. It's just that the idea was invented before
> in C#. I usually give attribution to (and favor the term invented by) the
> original innovator, not the copycat. Those two features have only few
> differences, for example C# requires importing the symbols first with
> 'using'. The proposed D feature is more careless here.
Actually, C# is, if anything, the copycat. (Convergent evolution is much more likely) Extension methods were introduced in C# 3, which was released November 2007. Uniform function call syntax was discussed at D language conference in August 2007. And it's a logical extension from array 'Functions as Array Properties' which has been around since at least 2006.
|
May 27, 2010 Re: Uniform function call syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Wed, 26 May 2010 16:05:48 -0400, Jacob Carlborg <doob@me.com> wrote: > I've asked this before, probably several times: if and when will D get the uniform function call syntax that has been talked about? Example: > > void foo (int i) {} > 3.foo(); > > And please don't say it's already implemented because it isn't, I've heard that before. > Is your patch still current or does it need to be looked at? (http://d.puremagic.com/issues/show_bug.cgi?id=3382) |
May 27, 2010 Re: Uniform function call syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to retard | On 2010-05-27 01.41, retard wrote: > Wed, 26 May 2010 22:05:48 +0200, Jacob Carlborg wrote: > >> I've asked this before, probably several times: if and when will D get >> the uniform function call syntax that has been talked about? Example: >> >> void foo (int i) {} >> 3.foo(); >> >> And please don't say it's already implemented because it isn't, I've >> heard that before. > > Are you sure you're not confusing two things. > > "The uniform access says that client code should not be affected by a > decision to implement an attribute as a field or method." -- Programming > in Scala > > The other is a term known as extension methods. "Extension methods enable > you to "add" methods to existing types without creating a new derived > type, recompiling, or otherwise modifying the original type." -- http:// > msdn.microsoft.com/en-us/library/bb383977.aspx This was talked about at the first D conference and the term used there was "uniform/unified function call syntax". -- /Jacob Carlborg |
May 27, 2010 Re: Uniform function call syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | On 2010-05-27 01.52, Simen kjaeraas wrote: > On Thu, 27 May 2010 01:41:16 +0200, retard <re@tard.com.invalid> wrote: > >> Wed, 26 May 2010 22:05:48 +0200, Jacob Carlborg wrote: >> >>> I've asked this before, probably several times: if and when will D get >>> the uniform function call syntax that has been talked about? Example: >>> >>> void foo (int i) {} >>> 3.foo(); >>> >>> And please don't say it's already implemented because it isn't, I've >>> heard that before. >> >> Are you sure you're not confusing two things. >> >> "The uniform access says that client code should not be affected by a >> decision to implement an attribute as a field or method." -- Programming >> in Scala >> >> The other is a term known as extension methods. "Extension methods enable >> you to "add" methods to existing types without creating a new derived >> type, recompiling, or otherwise modifying the original type." -- http:// >> msdn.microsoft.com/en-us/library/bb383977.aspx > > http://s3.amazonaws.com/dconf2007/WalterAndrei.pdf > > Page 9. The idea is that foo(bar) may be replaced with bar.foo() and vice > versa, making function calls 'uniform' in that both member functions and > free functions may be called in the same manner. What he said ^ -- /Jacob Carlborg |
May 27, 2010 Re: Uniform function call syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Jacques | On 2010-05-27 07.17, Robert Jacques wrote: > On Wed, 26 May 2010 16:05:48 -0400, Jacob Carlborg <doob@me.com> wrote: > >> I've asked this before, probably several times: if and when will D get >> the uniform function call syntax that has been talked about? Example: >> >> void foo (int i) {} >> 3.foo(); >> >> And please don't say it's already implemented because it isn't, I've >> heard that before. >> > > Is your patch still current or does it need to be looked at? > (http://d.puremagic.com/issues/show_bug.cgi?id=3382) 1. I assume that the line numbers in the diff is not correct anymore, don't know how sensitive that is 2. As I say in the bug report literals don't work, i.e. 3.foo();, x.foo(); works though. To make 2. work I assume additional changes need to made in the lexer and/or parser. What I've heard 2. will never work until ".1" and/or "1." are not allowed anymore. -- /Jacob Carlborg |
May 27, 2010 Re: Uniform function call syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Jacques | Wed, 26 May 2010 21:43:38 -0400, Robert Jacques wrote:
> On Wed, 26 May 2010 20:44:50 -0400, retard <re@tard.com.invalid> wrote:
>
>> Thu, 27 May 2010 01:52:32 +0200, Simen kjaeraas wrote:
>>
>>> On Thu, 27 May 2010 01:41:16 +0200, retard <re@tard.com.invalid> wrote:
>>>
>>>> Wed, 26 May 2010 22:05:48 +0200, Jacob Carlborg wrote:
>>>>
>>>>> I've asked this before, probably several times: if and when will D get the uniform function call syntax that has been talked about? Example:
>>>>>
>>>>> void foo (int i) {}
>>>>> 3.foo();
>>>>>
>>>>> And please don't say it's already implemented because it isn't, I've heard that before.
>>>>
>>>> Are you sure you're not confusing two things.
>>>>
>>>> "The uniform access says that client code should not be affected by a decision to implement an attribute as a field or method." -- Programming in Scala
>>>>
>>>> The other is a term known as extension methods. "Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type." -- http:// msdn.microsoft.com/en-us/library/bb383977.aspx
>>>
>>> http://s3.amazonaws.com/dconf2007/WalterAndrei.pdf
>>>
>>> Page 9. The idea is that foo(bar) may be replaced with bar.foo() and
>>> vice versa, making function calls 'uniform' in that both member
>>> functions and free functions may be called in the same manner.
>>
>> I understood what you meant. It's just that the idea was invented before in C#. I usually give attribution to (and favor the term invented by) the original innovator, not the copycat. Those two features have only few differences, for example C# requires importing the symbols first with 'using'. The proposed D feature is more careless here.
>
> Actually, C# is, if anything, the copycat. (Convergent evolution is much more likely) Extension methods were introduced in C# 3, which was released November 2007. Uniform function call syntax was discussed at D language conference in August 2007. And it's a logical extension from array 'Functions as Array Properties' which has been around since at least 2006.
I've found articles of the proposed extension methods for C# already in 2004 and blog posts in 2005. Of course C# is a copycat, most of the ideas in "modern" programming languages were already invented 20-50 years ago. But AFAIK this feature was presented in C# context long before D reinvented it.
|
Copyright © 1999-2021 by the D Language Foundation