Multiple inheritance in Java/C#
Duncan Booth
duncan at NOSPAMrcp.co.uk
Fri Nov 21 11:43:43 EST 2003
Oren Tirosh <oren-py-l at hishome.net> wrote in
news:mailman.967.1069426914.702.python-list at python.org:
> On Tue, Nov 18, 2003 at 08:31:35PM -0800, Hung Jung Lu wrote:
>> Hi,
>>
>> I think Microsoft did look into Python when they designed C#.
>
> In C# 2.0 it looks like they copied Python's generator functions:
>
> http://dev.r.tucows.com/extdocs/c_sharp_2.0_spec.html#_Toc48187963
>
That looks fun. I see they've also picked up on lambda functions and nested
scope variables. I especially liked this:
> static void Main() {
> foreach (D d in F()) d();
> }
...
> static D[] F() {
> D[] result = new D[3];
> int x = 0;
> for (int i = 0; i < 3; i++) {
> int y = 0;
> result[i] = delegate { Console.WriteLine("{0} {1}", ++x, ++y); };
> }
> return result;
> }
>
> the three delegates capture the same instance of x but separate
> instances of y, and the output is:
>
> 1 1
> 2 1
> 3 1
>
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list