-
-
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
add .args to compile time method #20926
Labels
Feature Request
This issue is made to request a feature.
Comments
There is not:
module main
struct Struct1 {
num f64
}
fn (mut s Struct1) do_thing(a f32) bool {
return false
}
fn register[T](){
$for method in T.methods {
$for arg in method.args {
println("${arg.name}")
}
}
}
pub fn main() {
register[Struct1]()
} |
It is accessible in another way, like: fn register[T]() {
$for method in T.methods {
args := method.args
for arg in args {
match arg.typ {
typeof[f32]().idx {
println('arg [${arg.name}] is f32')
}
else {}
}
}
}
} |
what if we want check whether method.args len is 1 at compile time, and do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the feature
I would like to do:
Use Case
For vgdextension and working with godot, we need a way for godot to call our methods. In order to avoid code generation, we need to be able to loop through args at compile time. We need to build structures defining our methods and create closures that are called by godot that transform the arguments and properly call our methods that are defined in V.
Proposed Solution
add .args to compile time method
Other Information
No response
Acknowledgements
Version used
V 0.4.4 70c277d
Environment details (OS name and version, etc.)
V full version: V 0.4.4 1733dab.70c277d
OS: windows, Microsoft Windows 11 Pro v26058 64-bit
Processor: 24 cpus, 64bit, little endian,
getwd: C:\Users\jcwea\Documents\git\jvnet
vexe: C:\Users\jcwea\Documents\git\v\v.exe
vexe mtime: 2024-02-29 15:47:47
vroot: OK, value: C:\Users\jcwea\Documents\git\v
VMODULES: OK, value: C:\Users\jcwea.vmodules
VTMP: OK, value: C:\Users\jcwea\AppData\Local\Temp\v_0
Git version: git version 2.40.0.windows.1
Git vroot status: weekly.2024.09-6-g70c277d4
.git/config present: true
CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.
thirdparty/tcc status: thirdparty-windows-amd64 b99a453d
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.
The text was updated successfully, but these errors were encountered: