-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why doesn't the specification describe the creation of built-in objects? #1491
Comments
There isn't much in common between the built-in non-functions. If #1460 goes though, we could say that each one's creation involves a call to |
@jmdyck I think it does not matter whether there is a difference between ordinary and built-in objects or not. The point is that the specification must clearly define the creation of something, in this case the creation of built-in objects. I did not find a step where it is clearly stated that the objects that are defined as "ordinary object" should be created through the "x" algorithm, and the objects that are defined as "exotic object" should be created through the "y" algorithm. In principle, the specification of exotic objects specifically described. But ordinary objects are not described how to create them. For example, the built-in Math object, it is not specified how it should be created, that is, there is no specific algorithm. And how should I know how to create it? |
No, it must clearly define the (observable) behavior of things. You can't observe the specifics of an object's creation, so the spec doesn't have to define it. (It can, but it doesn't have to.)
You can create it in any way that you like, as long as the result has the characteristics that the |
Why? For example ObjectCreate What is wrong then? |
For instance, the step: |
@jmdyck Interesting. It is clear that it does not specifically say how an object should be created, but instead it shows what an object should have. But since |
@dSalieri There is no essential difference between built-in and non-built-in ordinary objects: you could just use ObjectCreate for both. Ditto for the built-in Array exotic object (namely, %ArrayPrototype%): just use ArrayCreate(0, %ObjectPrototype%). — But that would add verbosity, not clarity, because all those individual objects are already sufficiently clearly defined by other means in the spec. |
That was your original question, so we're in danger of going round in circles. Instead, I suggest that you give a definition (header + algorithm) for this operation, and say how it would be referenced. Then we can discuss whether that would be clearer than the status quo. |
@jmdyck It was not difficult, because in my opinion it was necessary to make a change in the function Let's start by changing the function
I suggest:
Well, the function that must match the name
As the easiest option, you can simply write in function
but in this case there is not a word about exotic objects. |
Step 3: It doesn't make sense to ask if Step 3a: Clause 9.4 specifies more than one set of exotic method definitions. And even if you devise a means to indicate just one of them, it becomes unclear whether (e.g.) Step 4: As above, it becomes unclear whether ordinary non-function built-ins should be created according to this operation or Steps 5+6: It isn't guaranteed that a built-in object will have
Right, which is why that option is a non-starter. |
My third step is based on the fact that we understand which object we are creating and if this object belongs to a group of exotic objects, then we apply the rules that I described above. You can create a table that will specifically indicate the desired exotic object. In addition, when creating an exotic object through Yes, probably you are right it would be easier to create with the It is then necessary to somehow identify these slots ( |
I understand what the step is trying to do. What you've written doesn't do that.
Using ObjectCreate doesn't conflict with that goal. Rather, it seems quite useful in meeting that goal.
You could, but (a) you'd have to tell the operation which row is pertinent to any given invocation, and (b) that still wouldn't take care of exotic objects whose semantics aren't defined in 9.4.
You mean pass ArrayCreate (or some other object-creating operation) to CreateBuiltinObject? Okay, then you can scrap the whole table idea. But then you'd basically just have:
Which seems like an unnecessarily complex way to just say:
|
@jmdyck Then how to properly express this step? It does not contradict, but does not reach to cover all objects. No, I didn't mean, but I like your concept (it is almost the same but only the creation method is specified in the algorithm, and not through the argument). In general, I would change your text a bit to the following:
By the way, what did you mean by:
How can I get an exotic object (I read the definition of an exotic object and understand perfectly what it means)? |
(@dSalieri: You should give a bit more context so I know what each thing is responding to.)
(This is presumably about step 3 "If obj is exotic ...".) Currently, I don't think the spec has a convention for expressing it. As I said: "Instead, the test you want is more like
(I think this is about the use of Sure,
We could conceivably put a sentence like the first in CreateIntrinsics. But (a) we'd have to restrict it to non-function objects, and (b) we can't limit exotics to 9.4. As for the second sentence, it's unclear what you mean by ownership.
Well, for one thing, proxy objects are exotic, and they're defined in 9.5. For another thing, implementations can provide built-in exotic non-function objects whose semantics aren't defined anywhere in the spec.
I'm not sure I understand the question. There isn't a single way to "get" an exotic object. You could access a pre-existing exotic object (e.g. |
(@jmdyck this time I will make the context, since it is difficult to understand what specifically refers to, but you understood everything correctly last time :))
That is, it cannot be determined whether the object is exotic or not?
I do not quite understand what you mean by:
I meant belonging to a specific category of objects, in this case, the absence of belonging to any of the categories.
About the proxy object. If I am not mistaken, he does not belong to the group of built-in objects.
I did not notice this, you already answered my question above, when you said that there are proxy objects with definition 9.5. Well, then it is necessary to amend my modified text and it will look like this:
Why not paste this text into item 13 of the |
No, that can be determined, but that's not what your test (in step 3) is trying to do. It's trying to determine whether
I meant that we could put, into CreateIntrinsics, a sentence like the first one you gave. ("All built-in objects that are ordinary objects are created using the ObjectCreate operation, and exotic objects are created using the operations listed in chapter 9.4.")
No difficulty, it would just need to be done.
Listing paragraphs doesn't sound useful. A general sentence might be, but I'm doubtful.
The spec doesn't talk about "categories" of objects either.
An implementation can provide a built-in object that's a proxy object.
I don't think there are any built-in proxy object defined by the ES spec, but ES implementations can provide built-in objects that are not defined by the ES spec, inluding built-in proxy objects.
Clause 2 Conformance says "A conforming implementation of ECMAScript may provide additional types, values, objects, properties, and functions beyond those described in this specification." And a Note in 4.3.9 built-in object says "Standard built-in objects are defined in this specification. An ECMAScript implementation may specify and supply additional kinds of built-in objects."
As I said, you have to restrict this to non-functions, and you can't limit exotics to 9.4.
As soon as you say it's an object, you've specified its type. 'Object' is a type.
All built-ins are created by the implementation, so it's unclear what you mean by saying the for some of them, the creation "depends on" the implementation.
Nope. Whatever you're thinking of is not what the ES spec calls its type.
That's basically just saying that a particular subset of objects are objects, which doesn't seem very useful.
Nope. There's only one Object type, and most of the terms defined by 4.3 don't even refer to objects. |
I then do not understand how to do it. Need help probably :) If you can insert this sentence:
then how to restrict non-functional objects? And what to do with exotic once it can not be restricted?
Yes, I distorted a little when I said about the categories, but I think that you understood what I meant by that, right?
Yeah, well, then the implementation itself can determine its proxy object, regardless of the standard, accepted. About links is also understandable.
Yes, I understood it. But I honestly do not understand what exactly I should do for this.
Well, but what then is the string is an ordinary object? Description of the object? Is an ordinary object not a subtype of an object?
This line was written for cases that are not described by the specification. But you have already answered above 2 links where about it said.
It is clear, but all the "types" of objects are also listed there. I just do not always know how to properly say. |
You can use wording like "For built-in objects that are not functions, ..."
Possibly, but when you're proposing new spec text, it's dangerous to use terms that the spec doesn't define: you can't assume that the reader will understand what you intended.
Not as far as the spec is concerned, because it doesn't define that term. (It does use it once, but that's probably a bug.)
It depends on what you mean when you say "types of objects". For instance, you might think of Array as a "type of object", but "Array object" is not defined in 4.3. |
@jmdyck You can then use a wording of this type: Built-in objects that are ordinary objects and are not functions are created using the ObjectCreate operation. Built-in objects that are exotic objects, but which are not functions, and which are specifically described by the specification are created using the operations listed in chapter 9.4. Creating built-in exotic objects that are not described in this specification is implementation-dependent.
Why is this a bug? In the specification there is a definition ordinary object. And there are matches in this specification for string:
By the way, why is there no Array Object in 4.3 chapter, but is there a Boolean Object? As I noticed there is not all there. |
Yeah, that seems like a plausible addition.
I was referring to the term "subtype": the spec doesn't define it, uses it only once, and that use is probably a bug.
Clause 4.3 doesn't claim to define all terms, or to be complete in any sense. I imagine "Boolean object" is there to distinguish it from "Boolean value". "Array object" doesn't have that problem. |
Interesting
Sometimes, I can not understand what it is about, but now it is clear :) But what about:
|
If you think the addition would be an improvement, you can submit a pull request. |
In chapter 17 ECMAScript Standard Built-in Objects very clearly describes the moments related to built-in objects (a lot has been written about function objects). Especially it concerns the built-in functions, there is a line that says:
But there is no such line about built-in objects that are not functions.
That is, there is a function to create ordinary functions (
FunctionCreate
) and built-in functions (CreateBuiltinFunction
). There is also a function for creating ordinary objects (ObjectCreate
), but there is no function for creating built-in objects.What is the reason for the absence of the function for creating built-in objects?
The text was updated successfully, but these errors were encountered: