Another idea I had, something I do all the time but would be interesting to see 
in a syntactical sugar approach.  Again, almost all this is because I (and many 
others) are writing real time, GC-sensitive applications (in my case a 
auto-generated first person shooter, every bitmap, every surface, etc) and 
trying to find ways to defeat or minimize the GC, and to get a discussion going 
about this kind of usage so more important people understand it’s a problem and 
maybe others will have better ideas.

Take this class:

class thing
{
constructor
{
}
doSomething(x,y)
{
let a=x+y;
let b=a*y;
let c=b*x;
return(c);
}
}

If I call doSomething a lot of times, I get a lot of objects to be tracked and 
GC’d.  Yes, I can rewrite that code to obviously eliminate them, but pretend 
there is actually something interesting happening here that requires those 
variables.  And engines can be smart enough to mark them and deal with them 
with the function ends (I don’t know if this is done.)

What I’m thinking is some kind of class based hint that would “super” hoist all 
local function variables.  It would be sugar but it would transform it into:

class thing
{
constructor
{
let _doSomething_a=null;
let _doSomething_b=null;
let _doSomething_c=null;
}
doSomething(x,y)
{
this._doSomething_a=x+y;
this._doSomething_b=a*y;
this._doSomething_c=b*x;
return(this._doSomething_c);
}
}

I actually do this now, just by hand.

Thoughts?

[>] Brian
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to