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

Editorial: "sequence of code units" != "String" ? #828

Open
jmdyck opened this Issue Feb 27, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@jmdyck
Collaborator

jmdyck commented Feb 27, 2017

The spec defines SV, TV, and TRV to return a sequence of code units. But a String value is a sequence of code units. So why not define SV, TV, and TRV to return a String value?

Note that TemplateStrings appears to assume that TV and TRV do indeed return Strings. E.g., it says

Let _string_ be the TV of |TemplateMiddle|.

and not

Let _string_ be the String value whose code units are the TV of |TemplateMiddle|.
@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Feb 27, 2017

Member

The intent was to distinguish between abstract sequences of code units and actual string values which are ECMAScript language runtime values. You should have to have the full semantics of ECMAScript strings available in order to lex/parse ES code or to validate static semantic rules.

From that perspective, the direct use of TV sequences as string values like shown above is a spec. bug. The fix would be language like that shown as the alternative.

Member

allenwb commented Feb 27, 2017

The intent was to distinguish between abstract sequences of code units and actual string values which are ECMAScript language runtime values. You should have to have the full semantics of ECMAScript strings available in order to lex/parse ES code or to validate static semantic rules.

From that perspective, the direct use of TV sequences as string values like shown above is a spec. bug. The fix would be language like that shown as the alternative.

@jmdyck

This comment has been minimized.

Show comment
Hide comment
@jmdyck

jmdyck Feb 28, 2017

Collaborator

You should have to have the full semantics of ECMAScript strings available in order to lex/parse ES code or to validate static semantic rules.

(Presumably you mean "You shouldn't".) That seems like a plausible reason, except:

  • The "abstract sequence of code units" approach is confined to the definitions of SV, TV, and TRV. Elsewhere, those sequences are 'converted' into String values, and those values are used to validate static semantic rules. E.g., StringValue performs such a conversion, and returns a String value, and it is used in Early Error rules and in other Static Semantics operations. So keeping ES Strings out of SV/TV/TRV doesn't keep them out of static semantics.
  • What's the problem with having "the full semantics" of ES Strings available at 'static' time? Presumably there's no normative effect. I.e., if SV/TV/TRV were defined in terms of Strings, implementations wouldn't be required to do anything differently. Do you think it would mislead implementers into doing something incorrect or inefficient? Do you think it would be harder to understand? (I'm doubtful on both counts.)
  • How are the semantics of ES Strings any different from the semantics of sequences of code units? It's just different terminology for the same (or isomorphic) data models. How is the distinction helpful?
Collaborator

jmdyck commented Feb 28, 2017

You should have to have the full semantics of ECMAScript strings available in order to lex/parse ES code or to validate static semantic rules.

(Presumably you mean "You shouldn't".) That seems like a plausible reason, except:

  • The "abstract sequence of code units" approach is confined to the definitions of SV, TV, and TRV. Elsewhere, those sequences are 'converted' into String values, and those values are used to validate static semantic rules. E.g., StringValue performs such a conversion, and returns a String value, and it is used in Early Error rules and in other Static Semantics operations. So keeping ES Strings out of SV/TV/TRV doesn't keep them out of static semantics.
  • What's the problem with having "the full semantics" of ES Strings available at 'static' time? Presumably there's no normative effect. I.e., if SV/TV/TRV were defined in terms of Strings, implementations wouldn't be required to do anything differently. Do you think it would mislead implementers into doing something incorrect or inefficient? Do you think it would be harder to understand? (I'm doubtful on both counts.)
  • How are the semantics of ES Strings any different from the semantics of sequences of code units? It's just different terminology for the same (or isomorphic) data models. How is the distinction helpful?
@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Mar 2, 2017

Member

I am also curious, it seems fine to me to just always use string values (as long as it's clear that implementations don't need to use actual JS strings, which I think it is, given the existing loosyness @jmdyck points out).

Member

bterlson commented Mar 2, 2017

I am also curious, it seems fine to me to just always use string values (as long as it's clear that implementations don't need to use actual JS strings, which I think it is, given the existing loosyness @jmdyck points out).

@jmdyck jmdyck referenced this issue Aug 3, 2017

Closed

Misc Editorial #964

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment