2 ms·
- Implicit calling: `foo.bar` calls `foo.bar()` and `foo.bar = 123` calls `foo.setBar(123)` Wuhh. Why wouldn't you use JS defineProperty here?
by untog 11y ago
- Implicit calling: `foo.bar` calls `foo.bar()` and `foo.bar = 123` calls `foo.setBar(123)`
Wuhh. Why wouldn't you use JS defineProperty here?
- judofyr 11y agoThere's one historic reason (it wasn't widely available when Imba was started). Another reason is performance: the last time we benchmarked this `defineProperty` was slower than regular function calls. Maybe it's improved now. Semantically the biggest difference is that you don't need to do anything special for marking a method as a property: class List def length # … In this case `list.length` just works. The disadvantage of this is that if you want to get the function itself, there's a separate syntax (`list:length`). Other than that, this is mostly about taste/style.