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

Introduce builtin function: type #553

Open
xushiwei opened this issue Aug 17, 2020 · 3 comments
Open

Introduce builtin function: type #553

xushiwei opened this issue Aug 17, 2020 · 3 comments

Comments

@xushiwei
Copy link
Member

In Go, we use reflect.TypeOf to get type of a value:

tyInt := reflect.TypeOf(int(0))
tyEmptyInterface := reflect.TypeOf((*interface{})(nil)).Elem() // no easy way to get an interface type

We may can introduce a type function to simplify it:

tyInt := type(int)
tyEmptyInterface := type(interface{})
@JessonChan
Copy link
Member

JessonChan commented Aug 20, 2020

mayb be typeOf is an alternate choice. But I'm not very sure about this feature, it seems not very necessary.

@JessonChan
Copy link
Member

we can move this faction to another lib package, like "reflects".

@xushiwei
Copy link
Member Author

we can move this faction to another lib package, like "reflects".

Because we use types as parameters, it is not a normal function. It has to be a builtin function like new.

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

No branches or pull requests

2 participants