The Expressiveness of D

Leandro Lucarella luca at llucax.com.ar
Tue Nov 2 07:59:11 PDT 2010


Gary Whatmore, el  2 de noviembre a las 09:40 me escribiste:
> The D way of returning tuples is:
> 
>   T!(int,int) ret;
>   auto f = (ref T!(int,int) r){ r = e; };
>   f(ret);
> 
> It doesn't look so bad if you think about it. The tuple is first stack allocated. It doesn't trigger heap allocation. High level scripting languages always cause extra heap allocation if you do
> 
> auto f = { return (1,2); };
> 
> It's much faster the D way.

What has returning a tuple has to do with heap allocation. Is like
returning a struct, which you can. Not being able to return a tuple has
no explanation performance-wide. If you are concerned about the copy, is
the same with static arrays, which are value types in D2. So here
something is not very consistent...

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
PROTESTA EN PLAZA DE MAYO: MUSICO SE COSIO LA BOCA
	-- Crónica TV


More information about the Digitalmars-d mailing list