why are Assign Expressions r-values?

Bill Baxter dnewsgroup at billbaxter.com
Sun Apr 29 17:42:32 PDT 2007


Daniel Keep wrote:
> 
> BCS wrote:
>> Reply to Daniel,
>>
>>> BCS wrote:
>>>
>>>> fo(void, 1);  // call fo with a temporary variable for i and a temp
>>> I'd be tempted to just use
>>>
>>> foo(0, 1);
>>>
>>> Since the first argument's going to be re-initialised anyway.  That
>>> said, having a way to specify "I don't care what goes here" would be
>>> nice.  The problem with using void would be functions like this:
>>>
>>> void ba(out int* i, inout int j);
>>>
>>> If you specify the first argument as void, what are you actually
>>> saying?
>>> Create temporary storage for the first argument, or actually pass
>>> void?
>> void has no value. Might you be thinking of null?
> 
> I could be... I could be.  It's certainly a possibility.  I would like
> to think I know what I'm talking about, but clearly that's not true. :P
> 
> My excuse is that void *should* be a literal (equal to void.init), and
> hence why I was confused.  Not stupid.  Nope.
> 
> 	-- Daniel
> 


I was thinking vaguely the other day that it might be nice if you could 
'return void;'  as a synonym for just plain 'return;'.

I didn't really go through seeing how it would pan out, but it just 
occurred to me that in trying to write a signal/slot setup or 
otherthings like that might be more straightforward if you could just 
blindly do:

       foreach(s; slots) {
           RetT v = call_slot(s);
           ret = reduce_ret(ret, v);
       }
       return ret;

--bb



More information about the Digitalmars-d mailing list