Skip to content

Generic and New API #203

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

Closed
dannypsnl opened this issue Aug 28, 2021 · 2 comments
Closed

Generic and New API #203

dannypsnl opened this issue Aug 28, 2021 · 2 comments
Labels
Milestone

Comments

@dannypsnl
Copy link
Member

dannypsnl commented Aug 28, 2021

Generic(a.k.a. parametric polymorphism) added into Go, let's explore how would it change our codebase, this issue is created to track related discussion.

@dannypsnl dannypsnl added this to the v0.4 milestone Aug 28, 2021
@mewmew
Copy link
Member

mewmew commented Aug 29, 2021

Great that you started to track the discussion @dannypsnl!

Just to clarify, we will evaluate how using generics would change the llir/llvm API, and based on this evaluation of benefits and drawbacks, we would then decide whether to actually update the API to use generics or not. It is also a possibility that generics brings with it more cons than pros in our specific case. Experimentation and evaluation will tell! :)

Cheers,
Robin

@mewmew mewmew added the API label Aug 29, 2021
@dannypsnl
Copy link
Member Author

Just thinking, maybe #59 (comment) is not hopeless now with Generic concept in Go(actually union part).

Previously, we must write

type Function interface {
    // ...
}
var _ Function = &function{}
type function struct {
    // ...
}

To let users have their own Function, now we can have

type Function struct {
    // ...
}

type Func interface {
    LLString() string
    // anything we need internally
}

// use point of Function
func foo[F *Function | Func](f F) {
    // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants