DIP44: scope(class) and scope(struct)
Ramon
spam at thanks.no
Sat Aug 24 05:29:42 PDT 2013
On Saturday, 24 August 2013 at 08:34:10 UTC, Simen Kjaeraas wrote:
> On Sat, 24 Aug 2013 03:34:32 +0200, Ramon <spam at thanks.no>
> wrote:
>
>> What, for instance, if I aquire 10 resources in ctor and
>> during normal programm execution cleanup 7 of them, so only
>> some are left for dtor?
>
> Then they don't have the same lifetime as the object, and
> scope(this)
> would be the wrong tool for the job.
Understood. But there *are* objects with different lifetimes. If,
for instance, I aquire some "nice" objects (GC'd, properly
through D) - and - some "dirty" malloced stuff (not talking about
externals).
Thinking about it I also dislike a special thing that also feels
and shows a special thing (namely "this" rather than e.g.
"failure").
"Holy rule": No special cases if any possible but everything in a
consistent way. If there are special cases, somehow make them not
look like it; try to make them look consistent. The scope
mechanism deals with success, with failure and with exit. That's
great, that's sufficient. That's how it should at least *look*
like in ctors, too.
Another inconsistency: If this mechanism is to "guard" on class
level, it should be there, at class level and not in a function
like entity (albeit the rather special "function" this).
Maybe I'm overly shy but I feel that logical consistency is a
major issue to be a good language and for safety, too.
More information about the Digitalmars-d
mailing list