Don’t underestimate the effect of small paper-cuts repeated many times. After all, there’s a reason it is fn and impl instead of function and implementation.
Haha, sure why not
Time will tell?
Yes. Why would they not be able to?
This is no different than the following, which is legal today:
trait Bar { type Assoc; }
type Foo<T> = Box<dyn Bar<Assoc = T>>;
type Baz = Foo<u32>;
The only difference is that the kind of Foo would be type -> trait (trait = type -> constraint) instead of type -> type.
This is effect polymorphism, which is different than mut polymorphism. See Do be do be do, Conor McBride et. al for a discussion on such things.
Presumably there would be some light weight syntax to say when you want what.
You could also do:
?async fn foo() -> u32 { .. }
async fn bar() -> u32 { foo() } // we decide that `foo` is async here.
fn baz() -> u32 { foo() } // we decide that `foo` is sync here.
True; for ?async saying such a thing is impossible. However, once you use an ?async function inside an async function, then it is possible as seen above.
It is not just weird, it is meaningless.
However, await!ing inside ?async with await!(expr) when it has been made into sync could perhaps be considered the same as { expr } (provided that expr came from another ?async fn).
That’s not true. Rust has two forms of polymorphism, a) parametric polymorphism, for example fn id<A>(x: A) -> A { x } is polymorphic but involves no traits. b) ad-hoc polymorphism in the form of traits. The point of polymorphism is reuse (by specifying reasoning about data and algorithms generally without extraneous details). Consider const fn for example – unless you want to repeat logic once for const fn and once for fn, then some way to avoid that is necessary. Effect polymorphism is one answer. However, I leave the question of whether I believe in (a)sync polymorphism for Rust unresolved for now.
PS: Maybe we should continue further discussion on async-polymorphism (if you are interested that is…) in a separate thread so it doesn’t clutter up this one…