-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some more questions around struct kinds. #32
Conversation
src/misc/8.md
Outdated
|
||
This means that `struct bar` only gets inserted into the type namespace, and `fn | ||
bar` only gets inserted to the value namespace (as functions in rust are first | ||
class values [^not]). Therefor both of these declarations can co-exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class values [^not]). Therefor both of these declarations can co-exist. | |
class values [^not]). Therefore both of these declarations can co-exist. |
when are they not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because they can't be higher ranked wrt type params.
IE I can write
fn identity<T>(t: T) -> T {
t
}
// Ok
let x: fn(i32) -> i32 = identity;
but not
let y: for<T> fn(T) -> T = identity;
Not sure if this is worth including.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whereas in haskell you can do
foo :: forall a b. (forall t. [t] -> t) -> [a] -> [b] -> (a, b)
foo sel as bs = (sel as, sel bs)
or to be higher kinded also:
foo :: forall a b f. (forall t. t -> f t) -> a -> b -> (f a, f b)
foo sel a b = (sel a, sel b)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the questions, good job Alona :3
some typos and small comments, and another thing: you inserted linebreaks after a set amount of characters. I'd prefer to instead let the lines get a bit longer but only insert linebreaks in semantically relevant places like after periods or commas. That makes it easier to change the sentences in the future and also makes the diffs nicer (semantic linebreaks).
that appears to be the existing style of the explanations too
uwu |
These probably wont get people who worked on the compiller, but it's still a kinda dark corner with non-intuitive behavior if you don't know about the separate type/value namespace.
Probably worth re-ordering at some point so they're not right next to eachother.
Also IDK if the explanation makes sense.