Git Product home page Git Product logo

Comments (8)

andrewplummer avatar andrewplummer commented on July 28, 2024

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.

andrewplummer avatar andrewplummer commented on July 28, 2024

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.

Raynos avatar Raynos commented on July 28, 2024

"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.

olivernn avatar olivernn commented on July 28, 2024

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.

andrewplummer avatar andrewplummer commented on July 28, 2024

@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.

Raynos avatar Raynos commented on July 28, 2024

@andrewplummer

prototypical OO in JS

more prototypical OO in JS

If you want further details feel free to say so.

from sugar.

andrewplummer avatar andrewplummer commented on July 28, 2024

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.

Raynos avatar Raynos commented on July 28, 2024

@andrewplummer Good work, you reacted to community feedback well and still kept to your own vision of sugarjs.

from sugar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.