3 ms·
Or use Scala :)
by halfmatthalfcat 6y ago
Or use Scala :)
- kaba0 6y agoWhich doesn’t have value types because it should be implemented in the JVM?
- halfmatthalfcat 6y agoIt has Value Classes which are essentially the same thing. They transpile down into the value itself but wrap the value in extra functionality if you so choose.
- kaba0 6y agoThey can only wrap a single primitive type - it’s a nice feature but nothing extraordinary. When Java implements primitive types, Scala will probably use this same construct. But the change have to come from the runtime level.
- chrisseaton 6y agoDoes Scala have value types?
- halfmatthalfcat 6y agohttps://docs.scala-lang.org/sips/value-classes.html https://docs.scala-lang.org/sips/value-classes.html
- chrisseaton 6y agoAh right - that's not really what we're talking about here, even though they have the same name.
- halfmatthalfcat 6y ago“Codes like a class, works like an int!” - Taken from the top of the page. This is exactly what Value Classes are in Scala. You supply an underlying value which is then interpreted as the value itself, not a reference.
- bcrosby95 6y ago> must have exactly one parameter, Huge limitation. Not anywhere near the same thing.
- chrisseaton 6y agoWhat you're talking about is just wrapping a single value. It's a type-system thing. What we're talking about are wrapping compound values. It's a VM implementation thing. They're not really comparable.