Remix.run Logo
swaranga 3 days ago

I keep forgetting the reasoning for this part of the design - why is the value semantics baked in the declaration site and not at the use site?

Why does the class author have to declare it as a value type? I know this has been rehashed before many times by Brian but I keep forgetting the reasoning.

cogman10 3 days ago | parent [-]

Call site is tricky because you need safety guarantees about the underlying data for it to be a value type. For example, it needs to be immutable.

If you were to call a function with a site declared value type, the function you call would have to have syntax as well to indicate "this is a value type I'm receiving and not a regular type" so that it doesn't do an illegal operation with the value type.