View mode: basic / threaded / horizontal-split · Log in · Help
March 09, 2006
Expand 'with'?
Is there any particular reason why the 'with' statement is restricted to work
with classes only?  I keep running into situations where using it with (all?)
other D constructs, like structs, enums and such, would be quite useful; making
it a sort of specialized 'alias' instead of something so limited.

- EricAnderton at yahoo
March 09, 2006
Re: Expand 'with'?
pragma wrote:
> Is there any particular reason why the 'with' statement is restricted to work
> with classes only?  I keep running into situations where using it with (all?)
> other D constructs, like structs, enums and such, would be quite useful; making
> it a sort of specialized 'alias' instead of something so limited.
> 
> - EricAnderton at yahoo

IIRC it does work with structs. I think I have used it.
March 09, 2006
Re: Expand 'with'?
In article <dupphj$qf4$1@digitaldaemon.com>, BCS says...
>
>pragma wrote:
>> Is there any particular reason why the 'with' statement is restricted to work
>> with classes only?  I keep running into situations where using it with (all?)
>> other D constructs, like structs, enums and such, would be quite useful; making
>> it a sort of specialized 'alias' instead of something so limited.
>> 
>> - EricAnderton at yahoo
>
>IIRC it does work with structs. I think I have used it.

Ahh, so it does.  I think what threw me was the error message when you use
something that isn't supported, like an enum:

test4.d(8): with expressions must be class objects, not 'Foobar'

- EricAnderton at yahoo
March 18, 2006
Error message incomplete (with with)
Error message at bottom should be:

"with expressions must be class objects or structs"

pragma wrote:
> In article <dupphj$qf4$1@digitaldaemon.com>, BCS says...
> 
>>pragma wrote:
>>
>>>Is there any particular reason why the 'with' statement is restricted to work
>>>with classes only?  I keep running into situations where using it with (all?)
>>>other D constructs, like structs, enums and such, would be quite useful; making
>>>it a sort of specialized 'alias' instead of something so limited.
>>>
>>>- EricAnderton at yahoo
>>
>>IIRC it does work with structs. I think I have used it.
> 
> 
> Ahh, so it does.  I think what threw me was the error message when you use
> something that isn't supported, like an enum:
> 
> test4.d(8): with expressions must be class objects, not 'Foobar'
> 
> - EricAnderton at yahoo
Top | Discussion index | About this forum | D home