Replies: 0 comments 20 replies
-
We think implicits might make some kinds of code more ergonomic, but I think "needs" is overstating the case. You can do value-oriented programming in Swift no problem, and there are no implicits. I'm out of time to write it out right now but an idiomatic implementation in Val would be similar to an idiomatic implementation in Swift, which is pretty straightforward. A Quicksort will be more elegant in Val than what Swift people will mostly recommend you do because mutating slices in Swift is inefficient (choose a pivot, partition on it, quicksort both partitions as slices, swap the pivot into place). |
Beta Was this translation helpful? Give feedback.
-
That's a great explanation @kyouko-taiga. The blog post had an interesting example with a name table with strings in it where the external API exposes int handles. The problem posed was to sort a vector of such handles but in the lexicographic order given by the elements they represent. How would that look in Val? By the way, I find Val very interesting, great work :) |
Beta Was this translation helpful? Give feedback.
-
@matklad wrote a very interesting blog post about mutable value semantics: https://matklad.github.io/2023/05/02/implicits-for-mvs.html
I was wondering about the ergonomics around second-class references myself, so this is very timely.
What would an "idiomatic" implementation of a sort function in (a future version of) Val look like?
Beta Was this translation helpful? Give feedback.
All reactions