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

Allow array[..., void] #23555

Open
arnetheduck opened this issue May 1, 2024 · 3 comments
Open

Allow array[..., void] #23555

arnetheduck opened this issue May 1, 2024 · 3 comments

Comments

@arnetheduck
Copy link
Contributor

Summary

Extend void handling to also allow array[..., void].

Description

In #23419 (comment), it is noted that an array of void is not allowed - this unnecessarily burdens generic code since array of void gracefully can be handled the same way as an ordinary void type.

Since void has no data, it follows naturally that array of void also doesn't have any data. We allow void variables, so we should also allow array-of-void variables - they are useful to simplify generic code and can be used as compile-time information carriers for macros, dsl etc.

Alternatives

No response

Examples

No response

Backwards Compatibility

No response

Links

No response

@arnetheduck arnetheduck changed the title Allow array[N, void] Allow array[..., void] May 1, 2024
@litlighilit
Copy link
Contributor

Currently void is only valid for generic argument, function return type, etc, but not for any concrete type.

As a variable of void is invalid, an array of void cannot be valid...

@mratsim
Copy link
Collaborator

mratsim commented May 4, 2024

As a variable of void is invalid, an array of void cannot be valid...

I think @arnetheduck meant parameter

This is valid Nim and compiles

proc foo(v: void) =
  echo "compiles"
  
foo()

@metagn
Copy link
Collaborator

metagn commented May 4, 2024

tuple[] serves a similar purpose but it doesn't get erased in the backend and it doesn't have a special meaning like void that makes it independent from the type system. Some discussion on changing void is on nim-lang/RFCs#508 and #20609.

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

4 participants