Comments (5)
The problem is that a normal =
can't work for most cases.
(I don't see any mention of .get
and .set
in the documents for vectors. (Which is probably an oversight))
For example, take the example of a vector.
var a = #[1, 2, 3, 4]
Now, of course, it should be possible to easily read values:
a[0] === 1
But you can't use assignment to update the vector:
a[0] = 9 // Doesn't work
This is because, by definition, these data structures are immutable.
a = a.set(0, 9) // sadly there is no mentions of a .set in the docs so far.
This is actually the same way that strings work in Javascript:
var str = 'abc'
str = str + 'def'
str[1] === 'b'
str[1] = 'c' // doesn't work
The only way to assignment work reliably would be to create a new value on every assignment. This can technically work, but seems to be complicated and confusing for Javascript.
from ecmascript-immutable-data-structures.
Actually I apologize I wrote this late before I forgot about it but I don't think set is as important, just being able to get without explicit .get
would be nice.
from ecmascript-immutable-data-structures.
@natew I agree with the subscript based get. But It would only work for vectors and records, as Maps take non-string, non-number strings as well.
from ecmascript-immutable-data-structures.
As much as I'd like to be able to do avoid using .get
and .set
, I think that it's quite important to be able to polyfill this feature. Even though you could transform vector[0]
to vector.get(0)
the impossible part is to know when a variable is an immutable vector and not an array, which means that it cannot be polyfilled.
Index and property access without get/set can always be added at a later stage.
from ecmascript-immutable-data-structures.
I agree that .get
is something that would need to be kept around. That said subscripts would be a huge benefit as well.
from ecmascript-immutable-data-structures.
Related Issues (15)
- ImmutableSet literals HOT 1
- Combine Record and ImmutableMap HOT 3
- Ability to set multiple values at once HOT 4
- Delete key in Record
- How is the progress going on the Stage 0 Proposal? HOT 5
- Way to create a Record from an Object HOT 1
- All imutable data structures also need a subtraction operations HOT 6
- Immutable all the way HOT 5
- Difference with Object.freeze HOT 2
- Easy conversion between mutable and immutable with prototype methods.
- New JSON method
- Some examples please.
- Possibility of creating an immutable-js based polyfill? HOT 3
- Some more details about Records. HOT 1
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 ecmascript-immutable-data-structures.