The stately := operator feature proposal

Manu turkeyman at gmail.com
Thu May 30 17:36:17 PDT 2013


On 31 May 2013 00:59, Byron Heads <byron.heads at gmail.com> wrote:

> On Thursday, 30 May 2013 at 14:41:09 UTC, Byron Heads wrote:
>
>> On Thursday, 30 May 2013 at 14:27:13 UTC, Russel Winder wrote:
>>
>>>
>>> I still like:
>>>
>>>         x := 1
>>>
>>> for a declaration and initialization with type inference.
>>>
>>
>>
>> Could be used for assigning from tuples.
>>
>> iVal, sVal := returnsIntAndString();
>>
>> would have to decide on how to handle this
>> x := 1;
>> x := y * 7;  // error or assignment?
>>
>> more of an issue with tuples then single lvalues
>>
>
> could also be used without the type inference
>
> int x;
> x, string s := returnIntAndString();
> ------
> int wx, wy;
> ...
> wx, wy := window.position;
>

I've raised the topic of multiple-return-values a whole heap of times. It's
usually shot down because it would create ambiguities in existing syntax.
MRV is super useful, and potentially more efficient too (in an ABI where
MRV can each return in arg registers, can save lots of memory hazards). It
produces a situation where you can return more than a single value from a
leaf function (really handy!).

So, I'm very curious to explore how any new assignment syntax can
interact/support with MRV...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130531/ec7cdf12/attachment.html>


More information about the Digitalmars-d mailing list