oczor icon indicating copy to clipboard operation
oczor copied to clipboard

update

Open zaoqi opened this issue 8 years ago • 5 comments

y = x with (foo = 2)

What's it compile to?

zaoqi avatar Oct 29 '17 09:10 zaoqi

It's something like

var y = _.clone(x)
y.foo = 2

But only @ptol can answer

nponeccop avatar Oct 29 '17 21:10 nponeccop

@zaoqi It uses cloneObject https://github.com/ptol/oczor/blob/master/libs/std/ff.pre.js and then update foo property.

var y = oc.cloneObject(x)
y.foo = 2

ptol avatar Nov 12 '17 09:11 ptol

It's slow.

zaoqi avatar Nov 12 '17 10:11 zaoqi

Yes, we really need a real persistent map (in the sense of https://en.wikipedia.org/wiki/Persistent_data_structure). The current solution is a sort of a compromise between code simplicity, semantics, performance and generating more or less idiomatic js. This means there is no solution that will satisfy all four.

For example, a mutable STRef-based map (in Haskell sense) has a perfect semantics, preformance and it's possible to get idiomatic JS, but it's pretty ugly on Oczor side (and we don't have rank-2 polymorphism either)

nponeccop avatar Nov 12 '17 21:11 nponeccop

@zaoqi Yes, by default for objects Oczor use basic mutable maps from the target language. Other data structure could be used for better performance.

ptol avatar Nov 13 '17 05:11 ptol