Easy API Mapping concept

Mike Samuel mikesamuel at gmail.com
Sun Dec 27 07:36:07 PST 2009


2009/12/27 memolus at googlemail.com <memolus at googlemail.com>:
> This is my idea for an easy mapping concept:
>
> First Example:
>
>    this.__defineGetter__("modus", function() {
>                return !gui.hidden;
>        });
>        this.__defineSetter__("modus", function(modus) {
>                return gui.hidden = !modus;
>        });
>
> will be turned into:
>
>        this.modus := function() { return !gui.hidden }
>
> Second Example:
>
>        this.__defineGetter__("input", function() {
>                if (modus === true)

Is modus a global variable or does it bear any relation to this.modus
defined above?

>                        return gui.input;
>                else
>                        return gui.placeholder_input;
>        });
>        this.__defineSetter__("input", function(input) {
>                if (modus === true)
>                        return gui.input = input;
>                else
>                        return gui.placeholder_input = input;
>        });
>
> will be turned into:
>
>        this.input := function() {
>                if (modus === true)
>                        return gui.input;
>                else
>                        return gui.placeholder_input;
>        }
>
> Third Example:
>
>        this.__defineGetter__("name", function() {
>                return "Bob";
>        });
>        this.__defineSetter__("name", function(newName) {
>                return "Bob"; // ignore newName
>        });
>
> will be turned into
>
> this.name := function() { return "Bob"; }
>
> There also be the easier way:
>
> this.name := "Bob";
>
> You could also write:
>
> let name = "Bob";
> this.name := name;
>
> Note that
>        this.name := firstname + surname;
> and
>        this.name := function() { return firstname + sirname; }
> are NOT equivalent. In the first example the operator will be executed
> one time when the interpreter reads this line, in the second example
> the function will always be called if you want to get or set
> this.name. Note that 'this.name' and 'this.name="abc"' are equivalent
> after you wrote the mentionend line. This is only a side-effect. The
> real features are "dynamic references" and "references to primitive
> data types".
>
> dynamic references:
>        You can get another reference each time you get or set the object
>
> references to primitive data types:
>        You can set an real reference to a String or a Number
>
> These are all features important to API mapping.

Can't they be achieved with a library function
   mapApi(xform, source, sourcePropertyName, target, targetPropertyName)
?


> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


More information about the es-discuss mailing list