Loading ...
Sorry, an error occurred while loading the content.

66Re: [caplet] ADsafe, Take 3

Expand Messages
  • David Hopwood
    Oct 3 6:22 PM
      Douglas Crockford wrote:
      [...]
      > return {
      > get: function (object, name) {
      > var value;
      > if (reject(object, name)) {
      > return;
      > }
      > value = object[name];
      > if (typeof value === 'function') {
      > return;
      > }
      > return value;
      > },
      > set: function (object, name, value) {
      > if (reject(object, name) || typeof value === 'function') {
      > return;
      > }
      > object[name] = value;
      > return object;
      > }
      > };
      > }();

      IMHO the rejections should not be silent; they should throw an exception.

      In any case, I prefer my suggestion to use object.get(name) and
      object.set(name, value). That way, these methods can be added only to
      prototypes of objects that should be indexable, rather than all objects
      being indexable by default. Since implementations of .get and .set in user
      code would not be able to use the [] syntax, there is then no need for
      explicit checks. (The trusted ADsafe implementation can of course use
      [] where it needs to.)

      --
      David Hopwood <david.hopwood@...>
    • Show all 17 messages in this topic