TemplateLiteral tagged with super

# Michael Ficarra (10 years ago)

Is there any reason why a TemplateLiteral cannot be tagged with super? They can be tagged with a SuperProperty and a SuperCall, so the omission of super itself is strange. I propose we extend CallExpression to allow super TemplateLiteral[?Yield].

# Domenic Denicola (10 years ago)

What semantics would you propose for this extension?

# Michael Ficarra (10 years ago)

Call Construct on the super constructor and the ArgumentListEvaluation of the TemplateLiteral. Maybe like this?

CallExpression : super TemplateLiteral

  1. Let newTarget be GetNewTarget().
  2. If newTarget is undefined, throw a ReferenceError exception.
  3. Let func be GetSuperConstructor().
  4. ReturnIfAbrupt(func).
  5. Let argList be ArgumentListEvaluation(TemplateLiteral)
  6. ReturnIfAbrupt(argList).
  7. Let result be Construct(func, argList, newTarget).
  8. ReturnIfAbrupt(result).
  9. Let thisER be GetThisEnvironment( ).
  10. Return the result of calling the BindThisValue concrete method of thisER with argument result.
# Allen Wirfs-Brock (10 years ago)

On Feb 13, 2015, at 4:56 PM, Domenic Denicola wrote:

What semantics would you propose for this extension?

The semantics are obvious enough, it would be equivalent to: super(callsite, ...substitutionValues)

But what would it be good for. Can anybody think of a practical use case for this?

# Kevin Smith (10 years ago)

But what would it be good for. Can anybody think of a practical use case for this?

I can't. And for what it's worth I didn't find any semantics obvious. I think in general it's best to limit the contexts in which super can occur, since it has different meanings depending on context.

Seems like a "defer" thing to me.

# Gary Guo (10 years ago)

If super TemplateLiteral is added, I will suggest we add new MemberExpression TemplateLiteral, which might be more useful in practice.

# Shinji Ikari (10 years ago)

That case we can simply allow TemplateLiteral in Arguments. It will become more consistent as well and causes less cognitive burden. We don't even need to define MemberExpressionTemplateLiteral and CallExpression TemplateLiteral any more. BTW, the only places where Arguments is referred to are MemberExpression, CallExpression, and SuperCall.

Although it will be a rather breaking change because it will change the precedence of expressions. For example, currently new ax is a NewExpression. ax will be evaluated first. But with this change, it will also be a simple MemberExpression. The a method will be [[Construct]] ed with "x" as arg.