Using closure in function scope to make "real" private class members

H. S. Teoh hsteoh at qfbox.info
Wed Jun 1 12:59:17 UTC 2022


On Wed, Jun 01, 2022 at 12:24:23PM +0000, Dukc via Digitalmars-d wrote:
> On Wednesday, 1 June 2022 at 01:54:52 UTC, H. S. Teoh wrote:
> > So today, I thought I wanted to explore how far I can push the idea
> > of using closures over local variables in function scope to simulate
> > class-private field, i.e.:
[...]
> Frankly, I don't think this thing is worth doing any hacks for.
> Controlling the scope of encapsulation is rarely that critical, and if
> it is, it's easier to just put the class to it's own file.

I know, I wouldn't actually do this myself in a real project.  But I was
just curious how far I could go with the current language.


T

-- 
If it tastes good, it's probably bad for you.


More information about the Digitalmars-d mailing list