Comments (10)
I think I agree the latter is better.
Nit: should probably be "length" instead of "size" as is traditional for strings.
from infra.
I think maybe just as with size, we should use for
to distinguish. So we can have for="JavaScript string"
(code units), for=string
(code points), and for="byte sequence"
(bytes).
We can do the same for sorting, which we also need for byte sequences (see Fetch).
I wanted to start working on this but I'm blocking myself on #73 since I don't want to deal with merge conflicts. Suggestions for how to formally define sorting would be welcome by the way.
from infra.
Hmm. I guess if people are being very good about distinguishing their string types, then just using "length" and linking to the appropriate definition (with for="") should work OK. The benefit of having explicit separate length concepts (e.g. code-unit length and code-point length) is that it makes you re-emphasize the difference at the point at which you determine the length. But if people are careful with their types that's not necessary.
Formally defining sorting: based on https://en.wikipedia.org/wiki/Sorting_algorithm, the key is to define an ordering relation (x <= y) and then state that the sorted version is the unique permutation of the list such that it's in non-decreasing order. This permutation will not be unique if it's possible to have two things that are equal (x <= y && y <= x) but are not truly identical, e.g. if two strings have identity (which I don't believe they should).
Maybe it'd be best to just define ordering relations actually, and leave sorting with its English/computer science definition. Once we have well-defined ordering relations it's pretty obvious IMO.
from infra.
For lists we use "size" rather than "length", contradicting ECMAScript. Using size consistently might be easier (since you just need to remember the correct for value). WDYT?
from infra.
ECMAScript is a bit weird. Most of its data structures (Maps and Sets) use size. I think if arrays were designed today they might use size. Spec "List" type does use length though, it's true.
I think it's best to not blur the line between data structures and strings/byte sequences, and using different words (size vs. length) helps enforce this I think.
from infra.
Given what List does I we should also change lists while we can (or maybe accept both for a while). Having one exception is going to be annoying.
from infra.
I don't understand. What is the exception? What would we change about lists?
from infra.
If we align with ECMAScript on size/length except for lists, lists would be an exception. Therefore we'd change it to use length as well.
from infra.
(Or we consistently use size.)
from infra.
I think it's OK for infra to set its own rules here. For data structures, infra uses size. For strings, it uses length. What ECMAScript does can be separate.
I don't think we should make an exception for lists and say they use length even though all other data structures use size.
from infra.
Related Issues (20)
- Clarify USV handling in "serialize a JavaScript value to JSON bytes" HOT 1
- Consider defining "failure" HOT 2
- Expand on list indexing syntax
- Conditional abort edge case HOT 2
- Forgiving base64 HOT 8
- "do while" loops HOT 5
- Iteration and append methods for byte sequence used in standards are undefined HOT 1
- Skipping an item while iterating is undefined HOT 1
- Define monkeypatching HOT 3
- Consider defining "unique internal value"
- Explicit unions HOT 1
- definitions of "Continue" and "Break" should be clear that they apply to the innermost loop
- Define ordering for sets and maps? HOT 4
- Define remainder (and/or modulo) HOT 2
- Peek operation for stacks
- "Parse JSON to Infra" algorithms shouldn't require a current JS realm HOT 5
- Define set difference
- Give some examples of how to use structs
- Add a clone method for struct
- tracking/icon for features that might expose use of accessibility tools HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from infra.