An approach to reduce repetitive code of projections #822
Replies: 2 comments 4 replies
-
|
You don't need to write the |
Beta Was this translation helpful? Give feedback.
-
|
Cool, IMO rules about what can be syntesized from what should be highlighted in the tour.
How is that guaranteed? For example if we have an How could we syntesize the immutable variant from this? Or is this prohibited? |
Beta Was this translation helpful? Give feedback.
-
Hello! I'm looking at the examples in the tour about different kinds of subscript accessors. I find this concept awesome, however I'd like to see code of subscript to be less repetitive. At least for trivial cases.
Let's take a look at the example:
We don't have
sinkhere, however we wrote word "radians" 4 times, wrote the transformation from degrees to radians two times and the inverse transformation 2 times. Would be nice to have another way to express the same code without repetitions.An approach I'm thinking about is to introduce concepts of
source,transformToandtransformFrom(very rough draft):And the real accessors could be synthesized from this definition:
let { transformTo(generatedSourceAccessor) }set { generatedSourceAccessor = transformFrom(new_value) }Beta Was this translation helpful? Give feedback.
All reactions