DUAL FEATURE REQUEST: let "with" take a struct pointer and evaluate to its parameter

Guillaume Benny guillaume.spam.remove_me.spam.benny at sympatico.ca
Thu Dec 20 18:14:13 PST 2007


downs 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; ... }'?
> 
> Things this breaks:
>  * None; as usual with my feature requests, it only affects behavior that
>  is currently illegal.
> 
> What do you think?
>  --downs

 Already proposed the second part:

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=57615

It's a bit like the "returning" method from Ruby on Rails:
http://weblog.jamisbuck.org/2006/10/27/mining-activesupport-object-returning

 Only BCS voted with a small "vote += 0.25;" :)

 Guillaume B.




More information about the Digitalmars-d mailing list