Replies: 2 comments
-
Yes, that's planned. |
Beta Was this translation helpful? Give feedback.
-
How would that work with the LSP / intellisense? Would it use the code of your local architecture? I guess this is needed for C interop or something like that, but to me it seems this would complicate quite some things. How do you document this behaviour two struts with the same name based on architecture, but what if the condition is based off of something more complex (osname.contains("buntu"))? Would you need an explicit check at call sites
Will you get an error if you forget the check or only your co-workers / ci-cd on a different architecture will get compiler error? Disclaimer: I am not a regular user of v. I played around with it and I am highly interested in the development of it so take my questions with a pitch of noob salt |
Beta Was this translation helpful? Give feedback.
-
Describe the feature
v's compile time
$if
seems currently not to work on the toplevel of a module. It needs to be nested within a function. This makes it currently impossible to have e.g. alternate structure definitions within the same file.Use Case
I'm currently working on a project where the same structure is required with different fields depending whether the project is compiled for 32bit or 64bit. The situations looks basically like this (heavily simplified):
x64
x86
Proposed Solution
In C it is possible to use pre processor statements to define both structures in the same file but only having one of them being active for the current architecture. A top level
$if
statement in v could provide a similar functionality:What I would even prefer is an attribute syntax as it can already be used for functions. This looks way more elegant:
Other Information
No response
Acknowledgements
Version used
V 0.3.3 d60ceb4
Environment details (OS name and version, etc.)
linux, "Manjaro Linux" (VM)
Beta Was this translation helpful? Give feedback.
All reactions