18. мај 2011. 16.48, Allen Wirfs-Brock <al...@wirfs-brock.com> је написао/ла:
> > On May 18, 2011, at 4:33 PM, Nebojša Ćirić wrote: > > > John, > > I think you are correct. We allow for cached items, so it wouldn't be > "new" object we return in that case. I guess it's better to leave names as > they are now. > > The the cached and potentially sharable instance immutable? > I think that's what we agreed at the last meeting, to prevent potential problems. > > > > Allan, > > this is how current proposal looks like (just parts relevant to > DateTimeFormat): > > > > LocaleInfo = function(settings|string) {...} > > LocaleInfo.prototype.dateTimeFormat(settings) > > LocaleInfo.DateTimeFormat = function(settings, locale) {...} > > LocaleInfo.DateTimeFormat.prototype.format(Date) > > ... > > > > So one can do both: > > > > var locale = new LocaleInfo(); > > var dtf = locale.dateTimeFormat({skeleton: 'MMMy'}); // shorthand for > one below > > > > or > > > > var dtf = new LocaleInfo.DateTimeFormat({skeleton: 'MMMy'}, locale}); > > > > I think you should only support one or the other (and I would go with the > version on the prototype). By having both you effective double the surface > area of this part of the API., but for what benefit? It isn't clear that > the connivence in a few situations justify the cost of developers having to > learn a larger API set. > > Particularly if the above example is typical, I don't see why anyone would > ever code the second form. You still have to have locale available and the > first form is shorter. If I remove constructor LocaleInfo.DateTimeFormat where would I put LocaleInfo.DateTimeFormat.prototype.format() method for example (I would gladly remove the duplication, but I am not sure how)? Right now I do: LocaleInfo.prototype.dateTimeFormat(settings) { return new LocaleInfo.DateTimeFormat(settings, this); } and LocaleInfo.DateTimeFormat = function(settings, locale) { } does actual work of creating the new object.
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss