On Friday, September 2, 2011 5:02:26 AM UTC-7, Scott Sauyet wrote:
>
> much more palatable to me.  Can you also choose to have immutable 
> properties?  I would expect area to be only an accessor not a 
> mutator.  I can't quite buy the notion of an area function that allows 
> you to set the height and width.  But that is a secondary concern. 
>
>
Yes, GSet lets you configure each method as a getter and/or setter.

The .area() method you want would set the first (or "get-index") only, like 
so:

  var mySquareAccessor = new GSet(theScope,
    {
      area: [
        function () {
          return calcArea(this.width, this.length);
        }
      ]
    }
  );

While the mutator variation sets the vet and set indices, so .area() can 
accept arguments, like so:

  var mySquareMutator = new GSet(theScope,
    {
      area: [
        function () {
          return calcArea(this.width, this.length);
        },
        'number',
        function (w, l) {
          this.setArea(w, l);
        }
      ]
    }
  );
 

> I would expect some degradation from a naive prototype-based approach, 
> but does it degrade too much to be useful?  At least for client-side 
> JS, I find that many significant performance optimizations in don't 
> noticeably affect the end user. 


The impact of deep-closures is negligible, numerically speaking, and 
subjective otherwise. Principally, however, closures do hurt application 
performance, especially when run on poor user-agents. Compared to native 
timings, GSet had unconscionably slow numbers (we're talking hundredths of a 
millisecond, of course)... I think there are five closures per method. While 
there is a place for libraries like GSet and XJSAccessors - until native 
solutions are widespread - there isn't any demand. That kind of low-level 
object configuration just isn't  part of the JavaScript culture, yet.

P.S.  Any recent news on your flow code?  (I can't remember it's name 
> offhand.)


Speaking of Flow, the current version uses GSet. The next version is in 
development, and will not use GSet, for all the aforementioned reasons. 
However, I do provide some object protection by creatively using the 
prototype-chain - if I do say so myself. The result is a much smaller 
footprint, fewer closures, and faster performance. I'm busy nowadays, but 
will blog something decent in a month or so (don't hold your breath). In the 
meanwhile, you can preview the new code on github.

- best,

bemson

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to