sigmundch / DEP-member-interceptors

little experiment of using barriers to implement observability
4 stars 4 forks source link

Do intercepted fields have backing state? #7

Open munificent opened 9 years ago

munificent commented 9 years ago

The proposal says:

and the _$foo field will be final.

But the example doesn't show a field at all. It might be nice if the interceptor can choose whether or not the intercepted field gets backing state or not.

sigmundch commented 9 years ago

Oops - I seem to have a missed the field in the snippet and also didn't update sentence from a previous version of the draft (_$foo was not defined anywhere).

I fixed in 80876f9 to say:

An intercepted field:

@interceptor var name;

is equivalent to:

  var _$name;
  get name => interceptor.get(target, const _$nameMember());
  set name(value) => interceptor.set(target, value, const _$nameMember());

A final field will not have the setter, and the _$name field will be final.

As of your question of making the backing state optional - it's a good idea, I'm open to it. I'll leave this bug open to keep track of that.