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 $if work everywhere #23836

Open
2 tasks
kbkpbot opened this issue Mar 1, 2025 · 7 comments
Open
2 tasks

allow $if work everywhere #23836

kbkpbot opened this issue Mar 1, 2025 · 7 comments
Labels
Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.

Comments

@kbkpbot
Copy link
Contributor

kbkpbot commented Mar 1, 2025

Describe the feature

$if conditional compile can work only on some code regions.

Use Case

some use case :

module main

$if x64 { 
	pub type Digits = u64
} 
$else {
	pub	type Digits = u32
}


fn main() {
	y := []Digits{}
	dump(y)
}

Proposed Solution

Generate #ifdef at $if.

Other Information

No response

Acknowledgements

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

Version used

V 0.4.9 ab2eb00.2cd1f6e

Environment details (OS name and version, etc.)

V full version V 0.4.9 ab2eb00.2cd1f6e
OS linux, Ubuntu 24.04.2 LTS
Processor 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
Memory 11.79GB/15.51GB
V executable /media/HD/github/kbkpbot/v/v
V last modified time 2025-03-01 11:56:45
V home dir OK, value: /media/HD/github/kbkpbot/v
VMODULES OK, value: /home/mars/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /media/HD/github/kbkpbot/v
Git version git version 2.43.0
V git status weekly.2025.09-24-g2cd1f6e9
.git/config present true
cc version cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
gcc version gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
clang version Ubuntu clang version 18.1.3 (1ubuntu1)
tcc version tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
tcc git status thirdparty-linux-amd64 0134e9b9-dirty
emcc version N/A
glibc version ldd (Ubuntu GLIBC 2.39-0ubuntu8.4) 2.39

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Copy link

Connected to Huly®: V_0.6-22241

@kbkpbot kbkpbot added the Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one. label Mar 1, 2025
@larpon
Copy link
Contributor

larpon commented Mar 1, 2025

Hear. We need top level support for comptime logic, also for import statements

@JalonSolov
Copy link
Contributor

... and consts. :-)

@medvednikov
Copy link
Member

Yeah I'd like that very much

@enghitalo
Copy link
Contributor

enghitalo commented Mar 2, 2025

And struct fields...

@medvednikov
Copy link
Member

For sure. I actually needed custom struct fields like that a couple of times.

@Wajinn
Copy link

Wajinn commented Mar 3, 2025

Maybe, the extent to which this implemented, could use some caution or be done in steps, to make sure it doesn't cause other unforeseen issues. Sometime too much of a good thing, can be bad for us too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants