-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
comptime: support -d ident=value
and var := $d('ident', 0)
#21685
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Co-authored-by: Jose Mendoza <56417208+StunxFS@users.noreply.github.com>
Co-authored-by: Jose Mendoza <56417208+StunxFS@users.noreply.github.com>
vlib/v/checker/tests/comptime_value/use_flag_comptime_values.vv
Outdated
Show resolved
Hide resolved
It is an excellent and long needed addition. |
…rameter handling code
…passed down to modules with -usecache, and invalidate the build cache
Awesome, thanks @spytheman |
What you guys think about use |
It would be The longer name would be more explicit, for sure. |
Currently most, if not all, v flags is denoted via single dash (and you can even use them multiple times interchangeable: Using the plural version (with "s"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@medvednikov what do you think about this new language feature?
I like it. But we do have |
(well, not the same, -d is a subset of this new feature) |
If we decide to remove |
We can also extend For the second case, it can have the new behavior, that is described here for That way, there will be no need for a deprecation, it will continue to work, while having more functionality. |
+1 on keeping |
gcc/clang's |
It seems to work, but I have to do more tests:
|
I'm ok with keeping |
The PR is already updated to allow for |
The syntax of $if is not affected at all by this PR (and it would be a breaking change if it did). It is still The new I think, that it would be too verbose to be used as $if $compile_value('say_hi', false) {
println('say_hi is true')
} $else {
println('say_hi is false')
} always prints |
yes, |
I'm ok with Maybe it will be possible to do: |
Limited HashStmt support is added in e1be3eb. Currently we only support The whole But now this works similar to #flag -I $d('my_flag','flag_value')/xyz
#include "$d('my_include','/usr/include')/stdio.h" |
…d` is parsed as `i64`
…d` is parsed as `i64`
-compile-value key=value
and var := $compile_value/2
-d ident=value
and var := $d/2
Resolved conflict with |
-d ident=value
and var := $d/2
-d ident=value
and var := $d('ident', 0)
…mpiler_errors_test.v` and `./v test-self`
…ject root, instead of /usr/include)
Co-authored-by: larpon <768942+larpon@users.noreply.github.com>
Updated: Initial suggestion was to use
-cv ident=value
and$compile_value('ident', <value>)
, it is now an extension of-d
using$d('ident', <value>)
as retriever.This PR adds support for the following:
v -d my_i64=890 -d my_string="five six" run .
Resulting in:
.. and leaving out the
-d
flags:v run .
, outputs:Supported types are "pure" literals, and can be used also without
const
:I'm suggesting this, primarily, because I need to be able to tweak fixed array sizes at compile time - so that they have a default, but so I can decide to let my users tweak the sizes if they have reasons or needs to do so.
As @spytheman mentioned on Discord; It has potential to replace both (current)
-d
and$env
.I plan on adding support for
#flag -I $d('my_flag','flag_value')/xyz
and#include "$d('my_include','/usr/include')/stdio.h"
when time permits. (DONE)