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

elsif and else attribute #1350

Open
dalance opened this issue Mar 6, 2025 · 0 comments
Open

elsif and else attribute #1350

dalance opened this issue Mar 6, 2025 · 0 comments
Labels
lang Language design

Comments

@dalance
Copy link
Collaborator

dalance commented Mar 6, 2025

#1349 will add the way to judge define's exclusivity.
So the way to express exclusivity becomes important.

For example, the following code is multi-drive error, because FEATURE_A, FEATURE_B and FEATURE_C are not exclusive.

#[ifdef(FEATURE_A)]
assign a = 1;
#[ifdef(FEATURE_B)]
assign a = 2;
#[ifdef(FEATURE_C)]
assign a = 3;

The following code can express exclusivity.
In this case, each assign 's define context is exclusive, and not multi-drive error.
But this is too complicated.

#[ifdef(FEATURE_A)]
assign a = 1;
#[ifndef(FEATURE_A)]
#[ifdef(FEATURE_B)]
assign a = 2;
#[ifndef(FEATURE_A)]
#[ifndef(FEATURE_B)]
#[ifdef(FEATURE_C)]
assign a = 3;

So elsif and else is useful like below:

#[ifdef(FEATURE_A)]
assign a = 1;
#[elsif(FEATURE_B)]
assign a = 2;
#[elsif(FEATURE_C)]
assign a = 3;

elsif and else have some ambiguity.

#[ifdef(FEATURE_A)]
assign a = 1;

let x: logic = 1; // this statement is not in both `ifdef` and `elsif`.

#[elsif(FEATURE_B)]
assign a = 2;

Such case should be treated as error.

@dalance dalance added the lang Language design label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang Language design
Projects
None yet
Development

No branches or pull requests

1 participant