Skip to content

Initialize type param-dependent types in a generic factory function. #1167

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

Merged
merged 1 commit into from
Oct 27, 2022

Conversation

nevkontakte
Copy link
Member

Instead of being initialized at the package level, they are initialized inside a generic factory, where type params are available.

Example:

// Go:
func _F[T any](t T) {
  _ = []T{}
}

// JS:
_F = function(T){
  var sliceType = $sliceType(T);
  return function(t) {
    $unused(new sliceType([]));
  };
};

Updates #1013.

@nevkontakte nevkontakte requested a review from flimzy October 24, 2022 12:20
@nevkontakte
Copy link
Member Author

/cc @paralin

Copy link
Contributor

@paralin paralin left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks as always @nevkontakte :)

Instead of being initialized at the package level, they are initialized
inside a generic factory, where type params are available.

Example:

```
// Go:
func _F[T any](t T) {
  _ = []T{}
}

// JS:
_F = function(T){
  var sliceType = $sliceType(T);
  return function(t) {
    $unused(new sliceType([]));
  };
};
```
@nevkontakte nevkontakte merged commit fe3f70e into gopherjs:generics Oct 27, 2022
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.

3 participants