-
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
Add aoid and update calling conventions for directed operations #955
Conversation
Is StringValue singled out because it's special, or is it just the first of many? |
First of many. |
Is "polymorphic references" explained somewhere? |
(Also, the change to calling conventions relates back to open issue #311.) |
"polymorphic references" is not an ECMA262 term but how I call them for Ecmarkup purposes. For ECMA262, I will be updating the algorithm conventions to include these conventions both for syntax-directed operations and type-directed operations (where type might be any ECMAScript spec or language value). |
The word "references" made me wonder if they had something to do with the Reference specification type. Instead, it sounds like you're unifying (or at least bring closer together) the concepts of "concrete methods" (for Environment Records + Module Records) and syntax-directed operations. What they have in common (so far) is:
You could almost fit internal methods into the same scheme. Were you intending to do so? |
Yeah my plan is to do this with internal methods as well. Can you elaborate on "almost"? 😛 My thinking in terms of algorithm conventions updates is that "directed operations" [editorial note: awkward name] are algorithms that take an implicit parameter of the receiver (but provides no way to access it "by default"). Syntax directed operations expose the receiver as parse nodes named by the receiver's non-terminals, internal methods expose it as an object O, and "concrete methods" (record-directed operations?) have the "Let thing be this Thing" convention. My only concern is that "directed operations" is awkward... |
Ah, then you'll need to be careful about the word "receiver", as
I just meant that with 'concrete methods' and syntax-directed operations, the dispatching is based on an inherent/intrinsic aspect of the 'receiver', whereas with internal methods, the dispatch is just to execute whatever's in the appropriate internal slot of the 'receiver' (which isn't necessarily different in an implementation, but is different in the spec's model). But I didn't mean that that should stop you from putting them all into the same general category.
I would say that for an SDO, the receiver is a parse node. (More specifically, within an algorithm for an SDO, the receiver is an instance of one of the productions that that algorithm is associated with, and it is referenced via the form
Note that currently they don't all use the name
Currently, some also use the form
I don't think it would be incorrect to call them "polymorphic operations", but I'm not sure it would be clear. Maybe "dispatched operations"? "overloaded operations"? |
Hmm, can you think of a different name?
I wanted to say this as well, but to further point out that the receiver is effectively destructured into various aliases the algorithm can access. I don't think the
I want to get rid of these instances - the convention for module records is superior for terseness reasons :) |
Nothing great so far. You might instead rename [[Get]] and [[Set]]'s
So you could rename it to (say)
I definitely wouldn't use that wording (because it doesn't feel like destructuring to me, and we're not talking about aliases in the sense that's been defined), but we can certainly talk about the forms that an SDO algorithm can use to access the children of the parse node that is the receiver.
What would you change such uses to?
Did you think I was suggesting we do away with that? (I wasn't.) |
spec.html
Outdated
@@ -16743,7 +16743,7 @@ <h1 id="ao-issuperreference">IsSuperReference ( _V_ )</h1> | |||
</emu-alg> | |||
<emu-grammar>ContinueStatement : `continue` LabelIdentifier `;`</emu-grammar> | |||
<emu-alg> | |||
1. If the StringValue of |LabelIdentifier| is not an element of _iterationSet_, return *true*. | |||
1. If the |LabelIdentifier|.StringValue() is not an element of _iterationSet_, return *true*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably “If |LabelIdentifier|.StringValue()...” (extraneous “the”).
The current spec has “StringValue of ...” in some places and “the StringValue of ...” in other places.
An alternative for "receiver" might be "subject". |
fwiw, "receiver" is an established term for the "this value" of a function; it'd be ideal to stick with that definition. |
4fadde2
to
7564af4
Compare
When the phrasing was: Let _x_ be the result of evaluating |Foo|. we needed "the result of", because you can't say: Let _x_ be evaluating |Foo|. But now that we have: Let _x_ be the result of |Foo|.Evaluate(). we can trim that to just: Let _x_ be |Foo|.Evaluate().
Just wondering what the status of this PR is. |
ping? |
|
||
<emu-clause id=sec-algorithm-conventions-object-directed-operations> | ||
<h1>Object-Directed Operations</h1> | ||
<p>Blah blah blah</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
</emu-alg> | ||
<emu-clause id=sec-algorithm-conventions-directed-operations> | ||
<h1>Directed Operations</h1> | ||
<p>Some abstract operations, called <dfn>directed operations</dfn>, are implicitly parameterized with a target and have multiple definitions that may be selected depending on the value of the target. The target is referenced by callers of a directed operation using the method-like reference form `target.Operation()`. The target value may be referenced by the algorithm in a manner defined for that type of directed operation.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh using something like the bind operator might work better, like target::Operation()
, if we had that available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec is already using the syntax target.Operation()
, and this PR generalizes its use (i.e., extends it in a compatible way).
Conversely, PR #1515 (BigInt) is proposing a target::Operation()
syntax with different semantics from what you're suggesting. (In that PR, target
is a type rather than a value.)
So why do you think that the ::
syntax might work better for this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn’t making it as a concrete suggestion, since the bind operator isn’t a thing yet - more saying that using a dot, for a method that isn’t attached to the receiver, is confusingly non javascripty- so using an operator designed for this purpose seems nicer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really following you. Can you clarify what you mean by "attached to"? E.g., give cases where you think an abstract method is/isn't attached to a spec value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s entirely possible I’m misreading this PR. It seemed to me that a standalone function was being called with an object as the implicit receiver, but perhaps these aren’t standalone functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An abstract operation is a standalone function - it isn't attached to any object. It doesn't have a receiver, just like a strict-mode non-bound JS function invoked with parens without using member access doesn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think you're saying that you'd prefer to limit the spec notation X.Foo(args)
to cases where Foo
is defined to be a component / attribute / "property" of X
, and use something other than dot (e.g., ::
) when it isn't. This PR introduces notation like |RelationalExpression|.Evaluate()
, but a syntax directed operation (like Evaluate
) is not a component of a Parse Node, so you'd prefer the non-dot punctuation instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that sounds right :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. So, applying that to existing constructs would go like this?:
_object_.[[InternalMethod]](...)
would stick with the dot (because the spec tends to talk about internal methods as if they're "attached" to the object)._envRec_.EnvRecMethod(...)
would switch to the non-dot punctuation (because specific env record methods seem more like they belong to a particular env rec type)._moduleRec_.ModuleRecMethod(...)
ditto EnvRecMethod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Perl user in me is suggesting:
envRec →EnvRecMethod(...)
and:
|ParseNode|→Evaluate()
where |ParseNode| is implicitly blessed into main
.
@bterlson is no longer editor and the current editor group doesn't intend to pick this up, so I'm going to close this for the moment. If anyone is strongly in favor of this change and is inclined to do the work, open a new issue where we can discuss it. |
I made a PR against this PR a couple years ago, but it never got incorporated. I suppose I'll re-mount the whole thing as a PR against master sometime. |
@jmdyck Check with the editors before re-doing the work (by opening an issue); we weren't clear on whether we were in favor of the change. |
ok |
This is the ECMA262 changes necessary to use the upcoming support for polymorphic references. I've got a rendering of this here: https://bterlson.github.io/ecma262/#sec-declarative-environment-records. Sending this in case there are any thoughts on this approach before I convert the entire document and commit the ecmarkup change as well.