Steve Yegge's rant on The Next Big Language

Daniel Keep daniel.keep.lists at gmail.com
Mon Mar 12 19:01:22 PDT 2007



Vassily Gavrilyak wrote:
> Argument(s) type could be inferred too, as it is currently with foreach.
> So
> 
> auto res = [1,2,3].map((x){return x+x;}).filter((x, i){return i<2;});

I wouldn't want to be the one to write the type inference code for that :3

[1,2,3].map(f) works because it's rewritten as map([1,2,3], f), and the
type of [1,2,3] and f is known.  But if the type of f is inferred from
the call to map, and the call to map needs to know the type of f in
order to know its' own type...

*groans*  My brain hurts just trying to think about it >_<

Not saying I wouldn't *love* to have this, just that I wouldn't be at
all upset if it never happened :P

> Almost array comprehension.
> Another possibility is to do it C# 3.0 way
> 
> auto res = [1,2,3].map(x=> x+x).filter(_, i => i<2).sort(a,b => a>b);
> Such syntax is consistent with current lazy arguments.

Whoa, now *that* is nasty.  Quick: is foo(a,b=>a>b) a delegate of two
arguments or one?  What if a is declared outside the scope; which is it
then?

Hell, I couldn't even work out what the "_" was for until I realised it
was allowing multiple arguments :P

> 
> Max Samukha Wrote:
> 
>> On Mon, 12 Mar 2007 16:14:09 +0200, Max Samukha
>> <samukha at voliacable.com> wrote:
>>
>>> The return value of the delegate literal is inferred from the return
>>> expression type.
>>>
>> Not return value, return type, of course. Frits was faster, anyway.
> 

Frits is a forum-post ninja; beware his stealthy and sudden posts!

	-- Daniel

-- 
Unlike Knuth, I have neither proven or tried the above; it may not even
make sense.

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/



More information about the Digitalmars-d-announce mailing list