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

set type #19581

Closed
2 tasks
pomid opened this issue Oct 16, 2023 · 1 comment
Closed
2 tasks

set type #19581

pomid opened this issue Oct 16, 2023 · 1 comment
Labels
Feature Request This issue is made to request a feature.

Comments

@pomid
Copy link
Contributor

pomid commented Oct 16, 2023

Describe the feature

builtin set type like python set
can emulate it with map[T]V but having a separate set would be useful and will not waste resources

Use Case

sets have many use cases ....
you can almost build everything with them @

Proposed Solution

mut a := set[int]{0,1,2}
0 in a // true
3 in a // false
a << 3 // add 3 to a
3 in a // true

for i in a{
    println(i)
}

// alternative declarations:
a := {0,1,2} // implied type of set[int]
a := {
    0
    1
    2
} // implied type of set[int]
a := set int{0,1,2}
a := set {
    0
    1
    2
}

Other Information

also when tried to use none as map value i get C error
mut a := map[int]none{}
a[0] = none // error: C:/Users/pomid/AppData/Local/Temp/v_0/mmp.8507532903023194351.tmp.c:12695: error: cannot convert 'extern struct IError' to 'unsigned char'
is this intended ?

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.4.2 c947c14

Environment details (OS name and version, etc.)

V full version: V 0.4.2 c947c14
OS: windows, Microsoft Windows 10 Pro v19045 64-bit
Processor: 8 cpus, 64bit, little endian,

getwd: C:\Users\pomid\Desktop\v
vexe: C:\v\v.exe
vexe mtime: 2023-10-15 10:07:34

vroot: OK, value: C:\v
VMODULES: OK, value: C:\Users\pomid.vmodules
VTMP: OK, value: C:\Users\pomid\AppData\Local\Temp\v_0

Git version: git version 2.41.0.windows.1

Note

You can vote for this issue using the 👍 reaction. More votes increase the issue's priority for developers.

Take into account that only the 👍 reaction counts as a vote.
Only reactions to the issue itself will be counted as votes, not comments.

@pomid pomid added the Feature Request This issue is made to request a feature. label Oct 16, 2023
@Delta456
Copy link
Member

We already have sets in the language via datatypes module.

Plus I am sure you cannot have none as value initialisation like that.

@pomid pomid closed this as completed Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature.
Projects
None yet
Development

No branches or pull requests

2 participants