auto, var, raii,scope, banana

Juan Jose Comellas jcomellas at gmail.com
Thu Jul 27 09:02:35 PDT 2006


I think "local" may be a better name. At least I don't think I have ever
used a variable with that name.


kris wrote:

> Don has a good point: changing to "var" would cause conflict with
> existing variable-names.
> 
> Chad et. al. also have a good point about the conflict regarding static
> opCall() (via the lack of a "new" keyword). I suspect many people find
> the use of "new" to be indicative of allocation, and breaking this
> consistency may have a detrimental effect? Further, it was noted that a
> missing "new" can only be used at the instantiation site -- not at the
> class decl -- thus, D would be losing an existing feature.
> 
> I suspect you could count the current number of raii-class uses on a few
> hands, whereas the use of "auto" for implied-type is pretty darned
> popular -- and rightly so, since it's really very, very useful. Changing
> the raii style to use a different keyword, whilst retaining implied-type
> "auto" would be an almost imperceptible change?
> 
> Thus, it would appear to make sense to retain "auto" for implied-type,
> and introduce something *else* for automatic cleanup at end-of-scope
> (and also as a class attribute). how about reusing the "scope" keyword?
> 
> void main()
> {
>    auto i = 10;
>    auto foo = new Foo;
>    auto scope bar = new Bar;
>    auto scope wumpus = new Wumpus;
> }
> 
> class Foo {}
> 
> class Bar {}
> 
> scope class Wumpus {}




More information about the Digitalmars-d mailing list