sigmundch / DEP-member-interceptors

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

Change ordering of arguments for WriteInterceptor and InvokeInterceptor? #1

Open jakemac53 opened 9 years ago

jakemac53 commented 9 years ago

Currently the proposal is the following:

abstract class WriteInterceptor {
  set(target, value, Member member);
}

abstract class InvokeInterceptor {
  invoke(target, List positionalArguments, Map<Symbol,dynamic> namedArguments,
      Member member);
}

I would like to propose that we change member to always be the 2nd argument:

abstract class WriteInterceptor {
  set(target, Member member, value);
}

abstract class InvokeInterceptor {
  invoke(target, Member member, List positionalArguments,
      Map<Symbol,dynamic> namedArguments);
}

This is more intuitive, because it looks more like the calls its actually intercepting. For example when assigning a property:

foo.bar = 'baz';

The set method would be called with foo, a member whose name is #bar, and the value 'baz', in that order. With the current semantics 'baz' would come before the member with name #bar, which isn't as intuitive.