… I can’t think of what you’d even do with a String that “owns” immutable data. That said, maybe you could use capacity == 0 && len != 0 to indicate “my contents are static”, then have it point to static string data. With default type fallback, I can’t think of any immediate issue with it.
Could you use whatever machinery is used to support things like let Blah(x) = *thing;, but just extend the “pointerness” of *thing to x? I’m not sure I like the idea in general, because it can be important to know when you’re aliasing and when you’re not.
My problem with implicit coercions is that you can’t easily tell which parts of an expression are in what type. If we’re going to add them, maybe really aggressive widening that has to widen every input into the expression to the same output type right at the beginning. i.e. if the result of (a + b) * (c / d) is widened to i64, then all of a, b, c, and d get immediately widened to i64 when they’re used. e as T / e: T would block this process. That way, the whole thing is evaluated under the same rules, and it’s at least tractable to work out the types.
This one makes me feel really uneasy. If it’s a significant problem, perhaps explicit clones could be shortened to a new suffix operator?
In D, you could write template S(T) { struct S {} }, which was the same as struct S(T) {}. template could also have multiple items, and functioned like a namespace. So, yeah, I can kinda see mod m<T> { struct A; struct B; } being logically equivalent to mod m { struct A<T>; struct B<T>; }. That said, that could screw with privacy, so maybe a non-namespaced <T> { struct A; struct B; } would be good.
I like something I read once (forget where): allow inference on private stuff, not public stuff. Also, impl Trait isn’t quite the same thing, since it tells you what you can do with the returned value.
As a fan of explicitness, yes please. Heck, just making where clauses on traits checked would help.
Can’t rememeber where I put the draft RFC for it, but I like naming impls so they can be explicitly imported (the sticky part is generics).
That’s a really interesting idea. No idea how you’d go about that, though. 