Reflect.create()

# even stensberg (9 years ago)

Before going further, please note that feedback will be on Github, since we want to avoid spamming in ES Discuss in order to provide a much cleaner system.

I wrote up a draft about how I'd like this to look at: ev1stensberg/proposal-reflect-or, please note that I humbly accept any changes or opinions of this via Github, not here. This is because ES-Discuss is a bit messy when it comes to feedback, I.E that I get a mail every 30th minute of a one line comment. If it's absolutely necessary, drop a comment here, but I strongly advice you to try out GitHub issues.

# Bergi (9 years ago)

even stensberg wrote:

I wrote up a draft about how I'd like this to look at: ev1stensberg/proposal-reflect-or

I'm sorry for the harsh tone, but that's not a draft.

I tried to read your medium post but failed to understand anything (and didn't get any point you were going to make). As such, the "Reason" for this proposal is completely missing to me.

While I fail to understand what your proposal is all about, it seems to have something to do with defaulting values. And great, you've even asked the question "How is this different to Default Param in ES6 / the OR operator?" yourself in that text - but there is no answer?!

The next thing that completely escaped me is your API description

| Reflect.create(target, value, [DefaultValue]) | | Creates a Reflect, which is not an object.

Uh, what? What is "a Reflect"?

And the first thing that came to my mind after I read what you're talking about is that you should rename the proposal. Reflect.create will remind everyone of Object.create (given that some of the methods are duplicated between Object and Reflect) and one would expect that they do the same or at least have a similar purpose. You seem to be proposing something completly different that has nothing to do with creation.

Kind , Bergi

# even stensberg (9 years ago)

If you read the description, it clearly says unofficial proposal, of which draft means a mock-up for improvement. I thought that was retorical enough for people to understand, I'll change that up.

Wierd. Was having this discussion / pep-talk with Brendan Eich and think he understood that fairly.( twitter.com/ev1stensberg/status/722180638971936768)

About lack of answer in the reason, you should read the Medium article again, and reconsider what I said about ambiguously written code. I think it provides a clear intent, of which we want to avoid re-writing an assignment in order to use the logical OR.

I advice you to read this on MDN developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect

which explains what I mean about "not an object" . ( It's a built-in object) Where you need to assign it through a object assignment. And yea, the name was intentional. What makes this somewhat similar to Object.create is that we create an logical instance, but not an actual object like Object.create does. If you look at the issue tracker I want this to be viable with AND operators as well, so change of name is something I'd be up for! ( Also, if you got a proposal, I'd like to hear).

Is there anything else I missed?

Even

# Oriol Bugzilla (9 years ago)

I agree with Bergi.

Brendan Eich and think he understood that fairly

I can't see that. He says things like "what's to propose?", "what is declare? I don't think core language needs to grow", "What does this have to do with promises?", "I don't see the point" and "It's not making sense, sorry."

you should read the Medium article again

How is that article related to Reflect.create()?

I think it provides a clear intent

I disagree.

I advice you to read this on MDN which explains what I mean about "not an object"

I can't see where that article explains "not an object". The closest sentence is "Reflect is not a function object".

It's a built-in object

How can a built-in object not be an object?

Where you need to assign it through a object assignment.

What is "it" in this sentence? What do you mean with "object assignment", exactly?

we create an logical instance, but not an actual object

What is a "logical instance"? How can an instance not be an object?

not an actual object like Object.create does

Then like what?

How is this different to Default Param in ES6 / the OR operator?

Exactly. Please answer this question.

Creates a Reflect instance

Does this mean Reflect becomes a constructor? Currently it's not. In which way are these Reflect instances special? Why do we need them?

The target object you want your values to be referenced to.

What values? Referenced in which way?

The second argument or object you want to refer to, if the target fails.

What does "fail" mean?

fail, undefined, null or similar.

"fail" and "similar" are too vague

This is an object, which we can turn straight into a function on the fly if we want to.

How do you turn an object straight into a function on the fly?

Example

I don't understand what the example is supposed to show

This is equivalent

The first example seems to have two alternative codes, the second example only one. Which one is "this"?

# Bergi (9 years ago)

Wierd. Was having this discussion / pep-talk with Brendan Eich and think he understood that fairly.( twitter.com/ev1stensberg/status/722180638971936768)

Thanks for that link, but while Brendan Eich seemed to agree with the idea that something had to be done about defaulting declarations, he also showed some confusion about your ideas. Btw, that gist you linked (gist.github.com/ev1stensberg/883fd67da9809c84c08b84982e74148a) seems to be broken now.

About lack of answer in the reason, you should read the Medium article again, and reconsider what I said about ambiguously written code. I think it provides a clear intent, of which we want to avoid re-writing an assignment in order to use the logical OR.

Yes, I did reread the article. I know that there are many wrongs about

| var value = value || "another value";

but I failed to understand which ones you mean. By "avoid re-writing an assignment" you refer to the duplication/repetition of the variable name? And what is ambiguous about this code? It's purpose is well-known, it's behaviour is well-defined, and after all it's a common JS idiom.

In the medium post you seemed to propose a new "declare" keyword that could replace the repeated variable name, and that keyword would magically resolve the the contextual variable if I understand correctly. OK, regardless of what I think about this idea (too verbose, too implicit), what does this have to do with your Reflect.create proposal?

I advice you to read this on MDN developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect which explains what I mean about "not an object" . ( It's a built-in object)

Uh, Reflect is still an object if that's what you refer to here. Maybe what you actually wanted is to introduce a new Specification Type that works similar to a Reference?

Where you need to assign it through a object assignment. And yea, the name was intentional. What makes this somewhat similar to Object.create is that we create an logical instance, but not an actual object like Object.create does.

Sorry, you lost me here again.

Bergi

# even stensberg (9 years ago)

Yeah, the conversation was about vanilla js, and this links to that. We want Reflect.create to be a solution instead of writing var DefaultValue = DefaultValue || SomeOtherValue. That is what the medium article was about, of which Brendan was agreeing too. The rest of the discussion was about shaping the code into a proposal, which we didn't manage to do.

In order for you to fully understand the context I have copy+pasted from MDN so you can stop arguing of how I wrote "it is not an object". In terms of how this is not an object, is that is doesn't give us a constructor or prototype(?) and it behaves statically in that matter.

Unlike most global objects, Reflect is not a constructor. You can not use it with a new operator developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new

or invoke the Reflect object as a function. All properties and methods of Reflect are static (just like the Math developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math object).

I guess that this is repetition, but there's no wrong in saying this again. IMO. was bad typed by me there. By logical instance I mean that it should remove code with logical operators, which uses the existing variable, to reassign it with an logical operator as a fallback value.

About the Reflect instance, that is wrong, should be revised, indeed. I used it as outside JavaScript context. And no, Reflect doesn't become a constructor, both of us know that, so I don't know why you brought it up. Fail in this context means that the object returned with an error, null or undefined. I disagree. People understand the relationship between error, null and undefined as similar, meaning if things go south, this is where we put our try/catch as an function object.

The examples are to show the use of undefined without the "proposal". ( It chronological, so last example would be natural in this use case ) .

To Bergi:

Yeah, it serves its purpose, but I think that var value = value || "another value"; is bad as opposed to how I'd tackle it with Reflect. I always think that you don't need to write things as-they-are in forums where people have worked with JS quite some time. I tried to explain why I mean that this isn't a real object by saying that it doesn't contain prototype or constructor and thereby people got the analogy. Often when I say things are not things, as by objects are not objects, I assume people manage to reason without having to pin facts straight into their faces. Often I and people find that disrespectful( people try to teach you like a kid). Anyways, Reflect cannot be created as Object.Reflect, and that is what I mean by you having to assign it like: var Value = Reflect.create()

I'd like us to make a thread/ issue on the repo, so we avoid spamming people if that is fine? Also, if you have any other questions regarding how things are written, please, do file a PR, I bet you are better at explaining things in text than I am. :)

# Bergi (9 years ago)

… was bad typed by me there.

Indeed it was.

I tried to explain why I mean that this isn't a real object by saying that it doesn't contain prototype or constructor and thereby people got the analogy. Often when I say things are not things, as by object is not objects, I assume people manage to reason without having to pin facts straight into their faces.

Sorry, but this approach isn't going to work on this mailing list here or when you are going to write a technical document like a spec proposal. Don't talk in (bad) metaphors, state facts and use precise language.

We still don't understand how your Reflect.create is supposed to work or be implemented, how it is different from the old approach, and what exactly its advantage(s) will be.

Kind , Bergi

# even stensberg (9 years ago)

That's one of the reasons why GitHub is a better place to discuss this ;)

As I tried to say, this is work in progress, meaning I'd like input on this as well as improvements on the actual proposal.

As by last line, what is it that you don't understand? Hit me up at GitHub and I'll try to clear things up.

For future discussions, I'd like to keep things such as this on GitHub, so if you got any replies you want to take, do it there.

# Renki Ivanko (9 years ago)

Everything about this is confusing; you should slow down and think things through more.

R.

# even stensberg (9 years ago)

Is there anything bad about getting feedback before reiteration? This was meant for having some feedback and improvements, not getting a complaint storm in return. The intent of ES Discuss is about discussing the ECMA/ JS language, and it seems that you forgot about that, its not only a place to submitt stand-alone proposals, but to discuss and get some precious feedback. If you got some input, you are free to join by submitting a issue on GitHub!

On Fri, May 27, 2016 at 2:59 AM, Renki Ivanko <fatalis.erratum at gmail.com>

wrote:

# even stensberg (9 years ago)

If you got any other messages, please lets take this on GitHub, we avoid spamming the email list, I won't reply on comments from now on, other than on GitHub.

# G. Kay Lee (9 years ago)

I think everyone who has replied above has all been offering some very constructive feedbacks for you to chew on. The key takeway, if you haven't noticed already, is that your understanding of the language is flawed, and people simply cannot help you or continue their discussions with you because of that.

We're here to discuss really technical things and every tiniest detail has the need to be clarified, but that doesn't mean we're being harsh at you. However, you need to bring your knowledge of the language up to a certain level before jumping into the water. This is something only you can help yourself.

# even stensberg (9 years ago)

I've refactored the project, more yet to come, but have a look: ev1stensberg/proposal-reflect-or. Still need to put up an example and implementation details ( currently on the to-do list)