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

map: add functions new_map and new_map_init_1 #7424

Merged
merged 1 commit into from
Dec 21, 2020

Conversation

ntrel
Copy link
Contributor

@ntrel ntrel commented Dec 20, 2020

Part of #6991. Add functions that take a key_bytes parameter.

Passing T for the key type is more flexible than having a key_bytes parameter that is passed sizeof(KeyType). E.g. we can test T.name == 'string' to see whether to clone a key. (This is easier to implement than making the whole map struct a generic type).

I also hope later to implement taking the address of a generic function, so we can support V's == operator for any types that support it. E.g. m.key_eq_fn = &key_eq<T>.

Generics are not allowed ATM in builtin.

@ntrel ntrel requested a review from ka-weihe December 20, 2020 12:26
@medvednikov
Copy link
Member

generics can't be used in builtin

@ntrel ntrel marked this pull request as draft December 20, 2020 13:03
@ntrel ntrel closed this Dec 20, 2020
@ntrel ntrel reopened this Dec 20, 2020
@ntrel ntrel marked this pull request as ready for review December 20, 2020 15:00
@ntrel ntrel changed the title map: add functions new_map<T> and new_map_init_1<T> map: add functions new_map and new_map_init_1 Dec 20, 2020
@ntrel ntrel closed this Dec 20, 2020
@ntrel ntrel reopened this Dec 20, 2020
@medvednikov medvednikov reopened this Dec 21, 2020
@medvednikov medvednikov merged commit 2147d87 into vlang:master Dec 21, 2020
@ntrel ntrel deleted the new-map branch December 21, 2020 18:02
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