December 22, 2007
downs wrote:
> Consider:
> 
>> R delegate() bind(R, T...)(R delegate(T) dg, T bind) {
>> 	struct Holder { typeof(dg) _dg; T _bind; R call() { return _dg(_bind); } }
>> 	with (new holder) {
>> 		_dg=dg;
>> 		_bind=bind;
>> 		return &call;
>> 	}
>> }
> 

Arrgh!
I mean

>
> with (new Holder) {
> 	foreach (id, entry; dg) _dg[id]=entry;
>

Sorry :)
December 23, 2007
On Sat, 22 Dec 2007 02:15:27 +0100, Daniel Keep <daniel.keep.lists@gmail.com> wrote:

>
>
> Simen Kjaeraas wrote:
>> On Thu, 20 Dec 2007 16:31:56 +0100, downs <default_357-line@yahoo.de>
>> wrote:
>>
>>> The first part of the feature request is to allow "with" to take a
>>> pointer to a struct as a parameter.
>>>
>>> This is for the sake of internal consistency; since you can already call
>>> methods on a struct pointer as if it was dereferenced, it makes sense to
>>> also be able to use "with" on it.
>>>
>>> The second one arises from the following really cute idea ge0rg had in
>>> #d. Quote
>>>
>>>> > <Ge0rG> so you want 'auto foo = with(new myStruct) { bar = 23; baz
>>>> = 42; ... }'?
>>
>> Wouldn't it be more logical to use
>>
>>     with (auto foo = new myStruct) { bar = 23; baz = 42; ... }
>
> Consistency demands that 'foo' only exists until the end of the while
> block.  What, then, would be the point of giving the struct a name for
> the duration of a construct whose primary purpose is to allow you to
> omit the name?

Right. Make that

	static with (auto foo = new myStruct) { bar = 23; baz = 42; ... }

:p
1 2
Next ›   Last »