Re: Globlization and Object.system.load

2011-11-17 Thread David Herman
On Nov 17, 2011, at 3:48 PM, Roozbeh Pournader wrote:

> On Thu, Nov 17, 2011 at 3:08 PM, Roozbeh Pournader  wrote:
>> That would make something like this the minimum code needed to use the 
>> module:
>> 
>> var g11n;
>> Object.system.load("@g11n", function (g11n_module) {
>>   g11n = g11n_module;
>> });
> 
> I guess I was wrong about the minimum code. The minimum code is
> something like this:
> 
> Object.system.load("@g11n", function (g11n) {
>  // put all the code that uses g11n in here
> });
> 
> I actually like this. I think I should just take back my comment...

I agreed with you before. :) When you know for sure that it can't block, you 
should have a synchronous API. Something like:

var g11n = Object.system.loaded["@g11n"];

Dave

___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Globlization and Object.system.load

2011-11-17 Thread David Herman
We intend to have a synchronous API for accessing the built-in modules (those 
beginning with "@" in their URL), as well as a synchronous way to access 
modules that have already been loaded. This went by briefly in July:

https://mail.mozilla.org/pipermail/es-discuss/2011-July/015929.html

I'm behind in work on fleshing out the API. I'll get back on this ASAP and 
update the list.

Dave

On Nov 17, 2011, at 3:23 PM, Brendan Eich wrote:

> I didn't make up load from whole cloth, there's a proposal at
> 
> http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders
> 
> Module people should weigh in.
> 
> /be
> 
> 
> On Nov 17, 2011, at 3:08 PM, Roozbeh Pournader wrote:
> 
>> I was talking with Nebojša about the Object.system.load interface for
>> loading globalization, thinking from the user side.
>> 
>> Brendan's email suggested something like this:
>> 
>> Object.system.load = function(name, callback) {
>> if (name === '@g11n') {
>>   callback(v8Locale);
>> }
>> };
>> 
>> That would make something like this the minimum code needed to use the 
>> module:
>> 
>> var g11n;
>> Object.system.load("@g11n", function (g11n_module) {
>>  g11n = g11n_module;
>> });
>> 
>> What if we define load to be something like the following?
>> 
>> Object.system.load = function(name, callback) {
>> if (name === '@g11n') {
>>   if (callback) {
>> callback(v8Locale);
>>   } else {
>> return v8Locale;
>>   }
>> }
>> };
>> 
>> That way, a user who can afford the delay, or know that this is
>> immediate in Chrome, can simply do:
>> 
>> var g11n = Object.system.load("@g11n");
>> 
>> While the users who want the callback, can call it using the proper method.
>> 
>> Roozbeh
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> 
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Globlization and Object.system.load

2011-11-17 Thread Roozbeh Pournader
On Thu, Nov 17, 2011 at 3:08 PM, Roozbeh Pournader  wrote:
> That would make something like this the minimum code needed to use the module:
>
> var g11n;
> Object.system.load("@g11n", function (g11n_module) {
>   g11n = g11n_module;
> });

I guess I was wrong about the minimum code. The minimum code is
something like this:

Object.system.load("@g11n", function (g11n) {
  // put all the code that uses g11n in here
});

I actually like this. I think I should just take back my comment...

Roozbeh
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Globlization and Object.system.load

2011-11-17 Thread Brendan Eich
I didn't make up load from whole cloth, there's a proposal at

http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders

Module people should weigh in.

/be


On Nov 17, 2011, at 3:08 PM, Roozbeh Pournader wrote:

> I was talking with Nebojša about the Object.system.load interface for
> loading globalization, thinking from the user side.
> 
> Brendan's email suggested something like this:
> 
> Object.system.load = function(name, callback) {
>  if (name === '@g11n') {
>callback(v8Locale);
>  }
> };
> 
> That would make something like this the minimum code needed to use the module:
> 
> var g11n;
> Object.system.load("@g11n", function (g11n_module) {
>   g11n = g11n_module;
> });
> 
> What if we define load to be something like the following?
> 
> Object.system.load = function(name, callback) {
>  if (name === '@g11n') {
>if (callback) {
>  callback(v8Locale);
>} else {
>  return v8Locale;
>}
>  }
> };
> 
> That way, a user who can afford the delay, or know that this is
> immediate in Chrome, can simply do:
> 
> var g11n = Object.system.load("@g11n");
> 
> While the users who want the callback, can call it using the proper method.
> 
> Roozbeh
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss