Skip to content
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

Merged
merged 4 commits into from
Jun 4, 2024

Conversation

aDotInTheVoid
Copy link
Contributor

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.

src/misc/8.md Outdated Show resolved Hide resolved
src/misc/8.md Outdated Show resolved Hide resolved
src/misc/8.md Outdated Show resolved Hide resolved
src/misc/8.md Outdated Show resolved Hide resolved
src/misc/8.md Outdated Show resolved Hide resolved
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.
Copy link
Sponsor Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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)

src/misc/8.md Outdated Show resolved Hide resolved
src/misc/8.md Outdated Show resolved Hide resolved
src/misc/9.md Outdated Show resolved Hide resolved
Copy link
Sponsor Collaborator

@Noratrieb Noratrieb left a 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

@Noratrieb
Copy link
Sponsor Collaborator

uwu

@Noratrieb Noratrieb merged commit 3757b61 into BoxyUwU:main Jun 4, 2024
2 checks passed
@aDotInTheVoid aDotInTheVoid deleted the struct-kinds branch June 4, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants