You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When transpiled to ECMAScript, names should be in ECMAScript's idiomatic camelCase, at least by default. That means that, unlike Nim, helloworld (no word separators) can't be evaluated as identical to the variants listed above, as the transpiler must be able to separate the words.
More troubling, any uppercase abbreviations within names would lose their case. E.g. encode-uri would become encodeUri instead of encodeURI. The same goes for ECMAScript classes and constructors, starting with an uppercase letter, like Error, Date, Math, etc. The compiler would need to keep a lookup table of normalized names of ECMAScript globals and their fields, e.g. encode-uri-component should transpile to encodeURIComponent(), not the incorrect encodeUriComponent().
External JavaScript/TypeScript code would also have this issue. Any snake_cased names spotted in the wild too. When importing incompatible names from a non-kesh module, one could rename it using a string to reference exported values as named by the module.
import ['RouterLink' asrouter-link]: 'vue-router'
For direct field access on objects, one could similarly use a string.
An alternative and much simpler approach is to transpile only kesh idiomatic kebab-cased names to ES idiomatic camelCase. All other forms are transpiled verbatim.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Suggestion
Extend na's naming rules to also support
camelCase
andPascalCase
.Unlike Nim's identifier equality, have all names be case insensitive, no special exception for the first character (kesh doesn't have classes).
In other words, the following being equal:
Issues
There are some issues with this approach:
When transpiled to ECMAScript, names should be in ECMAScript's idiomatic camelCase, at least by default. That means that, unlike Nim,
helloworld
(no word separators) can't be evaluated as identical to the variants listed above, as the transpiler must be able to separate the words.More troubling, any uppercase abbreviations within names would lose their case. E.g.
encode-uri
would becomeencodeUri
instead ofencodeURI
. The same goes for ECMAScript classes and constructors, starting with an uppercase letter, likeError
,Date
,Math
, etc. The compiler would need to keep a lookup table of normalized names of ECMAScript globals and their fields, e.g.encode-uri-component
should transpile toencodeURIComponent()
, not the incorrectencodeUriComponent()
.External JavaScript/TypeScript code would also have this issue. Any
snake_cased
names spotted in the wild too. When importing incompatible names from a non-kesh module, one could rename it using a string to reference exported values as named by the module.For direct field access on objects, one could similarly use a string.
Is it worth the trouble?
Alternative suggestion
An alternative and much simpler approach is to transpile only kesh idiomatic kebab-cased names to ES idiomatic camelCase. All other forms are transpiled verbatim.
Basically,
-
becomes a modifier uppercasing the following character.Issues
None?
Conclusion
Simple is better. The alternative suggestion it is.
Beta Was this translation helpful? Give feedback.
All reactions