Multiple return values...

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Mar 13 12:26:24 PDT 2012


On 3/13/12 2:07 PM, Jose Armando Garcia wrote:
> On Tue, Mar 13, 2012 at 9:07 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org>  wrote:
>> On 3/13/12 10:48 AM, Manu wrote:
>>>
>>> float t;
>>> ...
>>> (myStruct.pos, t, _, int err) = intersectThings();
>>
>
> This can be checked at compile time. The D compiler can check that the
> number of arguments and the types match.

scatter() can also be compile-time checked. I left that to a runtime 
assert for more flexibility, but probably more checking is better 
particularly because skip allows skipping some values.

>> I actually find the scatter syntax better than this. Anyway, I hope you'll
>> agree there's not much difference pragmatically.
>>
>
> Correct if I am wrong but the scatter and gather functions cannot
> check that the number of arguments and their type match at compile
> time.

Just replace the two assert()s with static assert or a template constraint.


Andrei


More information about the Digitalmars-d mailing list