Comments (8)
You've discovered one of a handful of thorny areas with Sugar. I ran across that spec somewhat late in the game and immediately noticed the clash. I also noticed how goofy it was in that it's attempting to do what the standard constructor should, and in an inverted, counterintuitive way with the prototype object as the first param. It's going to require a bit of thought but I will say that there are no sacred cows, not even native ECMA ones, and I may be able to live with a single clash.
In the meantime, any suggestions for a name? "Make" just doesn't do it for me. Also there is Date.create as well. I would like to rename to maintain the parallel naming.
from sugar.
FWIW I also considered "extend", as the method in fact does create an object with extended methods... I don't like that name, however, because it's ambiguous in sounding similar to the Object.merge method.
from sugar.
"but I will say that there are no sacred cows, not even native ECMA ones, and I may be able to live with a single clash."
Object.create is the best part of ES5. It's a huge improvement over new
and .prototype
and really gives us a solid prototypical OO API.
This really needs to change.
from sugar.
Perhaps Object.build
is a little better?
I'm afraid I have to disagree with the statement about "no sacred cows, not even native ECMA ones, and I may be able to live with a single clash.". I think that wherever possible the native methods should be left alone, by all means provide a shim when they're not available but always leave the behaviour etc intact.
Having a look at the code for Object.create it appears to be creating a Hash, why not just have Hash.create, or even new Hash?
Interesting project though, I started on something similar a while back but didn't quite get as far - http://olivernn.github.com/supplement.js/.
from sugar.
@olivernn This in the end will be a hard-line for me and I may end up simply disagreeing. However we're probably working toward the same goal more than we think. Object.build
is not a bad compromise... let me give it some thought.
@Raynos I'm willing to believe you but can you please give examples? How is Object.create the best part? (that's quite a statement). In other words, how would you use it?
from sugar.
If you want further details feel free to say so.
from sugar.
Okay, after thinking about it, I'm with you guys on this one. The fact is that Object.create wasn't a very accurate name to begin with, as it's not simply acting like the constructor but returning a Hash class that has extended methods on it. I'm very much against the terminology hash
though when it comes to JS because it tends to raise more questions for those unfamiliar with the term. I also didn't like extend
due to it's confusion with merge
in other frameworks. So I've settled on extended
as a balance. It's more correct in what it's doing, yet is still intuitive and reads well.
The greater point I guess is that Object.create
is now left alone again, and is released in v0.9.1.
Scrambled to get this one out before people settled into using create
.
OK time to get some sleep...
from sugar.
@andrewplummer Good work, you reacted to community feedback well and still kept to your own vision of sugarjs.
from sugar.
Related Issues (20)
- hu (Hungarian - magyar) locale HOT 5
- Datejs replacement?
- Adding Marathi language to Sugar language code- (mar)<EOM>
- Can't parse Polish date with time
- Can't import sugar-date in TypeScript HOT 2
- TypeScript typings pollute global namespace HOT 1
- typo in docs
- Sugar.Date.get throwing "Invalid Date" when running on 2 tests in jest HOT 2
- Modifying an existing format / Adding a format for all Locales
- titleize does not take in account addAcronym
- Formatting large numbers gives unexpected results
- Date.create to find a date in complex string
- Problem parsing Spanish DateTime string
- Reversed fromUTC fallback logic
- Date.create can't parse dots in time format
- string replaceAll breaks normal js replaceAll HOT 1
- Question: Is there a way to do a short form duration/relative?
- Here's how to fix SugarJS parsing of dates with Unicode space characters in them
- "Next" doesn't work with month name, returns 2001 as the year HOT 1
- can't use sugar or sugar-core npm modules if Sugar is already loaded globally on the page
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sugar.