There is a contradiction in the description of [[getPrototypeOf]] and its algorithm.

Let me introduce the term description. This is the text from the “Description“ cell of the internal method [[setPrototypeOf]] in the specification table Table 4: Essential internal methods.

Also, below I use the term target from the specification clause.

The target of an internal method is the object upon which the internal method is called.

I only recently started reading the specification. I think I'm confused by the description.

var obj_proto = {};
var obj = {};
Object.setPrototypeOf(obj_proto, null);
Object.setPrototypeOf(obj, obj_proto);

I've included this code solely to illustrate the operation of the internal method [[setPrototypeOf]] algorithm works, because it is used in the algorithm of the internal method [[setPrototypeOf]] of the built-in Object constructor, and the built-in Object constructor is present in the implementation (or host, I'm not sure). This question isn't about the implementation (or host).

  1. The obj_proto object is the prototype for the obj object. obj_proto has no prototype. If I understand correctly, the obj_proto prototype does not provide any shared properties for the obj object.

  2. According to the description, if I pass an object as the [[setPrototypeOf]] argument, it means that the object provides inherited properties to the target. If I pass null, it means that the target has no inherited properties.

  3. No one provides inherited properties for obj. This means, according to the description, I passed null to [[setPrototypeOf]].

I see a contradiction between what is written in the description and how the algorithm of the internal method [[setPrototypeOf]] is written.

I have no issues with the algorithm. It's wonderful. But if my reasoning is correct, I think it would be better to change the first sentence of the description from “Associate this object with another object that provides inherited properties.“ to “Associate this object with another object.“.

PS (23.03):
I was wondering. From a specification standpoint, a prototype is an object that provides shared properties for other objects.

If obj_proto doesn't provide any shared properties for obj, is it a prototype for obj?

I think I see where you got confused:

The obj_proto object is the prototype for the obj object. obj_proto has no prototype. If I understand correctly, the obj_proto prototype does not provide any shared properties for the obj object.

The thing is: for obj_proto both own methods and prototype methods would become available on obj.

var obj_proto = { protoMethod() {} };
var obj = { objMethod() {} };

Object.setPrototypeOf(obj_proto, null);
Object.setPrototypeOf(obj, obj_proto);

// This exists because it exists on obj_proto
obj.protoMethod; // [Function]

// Not here because of setPrototypeOf(obj_proto, null)
obj.hasOwnProperty; // null

Hi!

  1. The obj_proto object is the prototype for the obj object. obj_proto has no prototype. If I understand correctly, the obj_proto prototype does not provide any inherited properties for the obj object.

And yet, at the same time, obj_proto does provide all inherited
properties for the obj object. This is a vacuous
truth
if obj_proto does
(currently) have no properties at all.

Notice that once you modify obj_proto by adding some properties, one
of the statements stays true and the other becomes false.

  1. No one provides inherited properties for obj. This means, according to the description, I passed null to [[setPrototypeOf]].

No, you cannot infer that. The description is not a statement of formal
logic, and if it was, it would not be biconditional.

I think it would be better to change the first sentence of the description from “Associate this object with another object that provides inherited properties.“ to “Associate this object with another object.“.

No, by that change the description becomes meaningless, if it does not
state the type of the association.

kind regards,
Bergi

1 Like

Thank you very much. I didn't know empty truth existed. Now everything becomes clear.