AFAIK, if you want to run code on a seperate thread, you have to put this code into a function.
I think it would improve things if there were "go blocks" like this:
go {
/* code here */
}
because then you wouldn't have to create a function for every thread you have.
good Idea.
But in case we needed args we would have to use the anonymous function. And we have two expressions. I think supporting anonymous function would be more beneficial.
go fn(mut arg ){
// do somthing with arg
}(arg)
are you going to have to define the type of the value you're working with in an anonymous function?
Also, will the bey like closures in Rust or something different?
go routines in V are patterned after go routines in Go. Syntax that is well-known and has been working for years.
It's really not that bad to "have to" declare a function. Especially if you might want to use it multiple times, instead of having to make multiple copies of your "go block", or an anonymous function, or whatever.
There's no reason not to support an anonymous function.
@JalonSolov I didn't want to say that using a function if you call it multiple times is bad.
My problem is that there are times where you just want to run something once on one or more threads.
Yeah that makes sense. That's exactly why we have defer {}, not defer fn() {} ()
This will most likely be implemented.