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

add __c_code{ } and __go_code{ } direct embed proposal #20117

Open
2 tasks
Jimmy2099 opened this issue Dec 7, 2023 · 1 comment
Open
2 tasks

add __c_code{ } and __go_code{ } direct embed proposal #20117

Jimmy2099 opened this issue Dec 7, 2023 · 1 comment
Labels
Feature Request This issue is made to request a feature.

Comments

@Jimmy2099
Copy link

Jimmy2099 commented Dec 7, 2023

Describe the feature

Because this project already includes c2v and go2v projects, so I think it will be very easy to Integrate this function. Many languages ​​have the function of integrating other languages. Similar to go, you can integrate C code into the Go source code,example:
main.v

module main

__c_code{
#include <stdio.h>
int main1(){
printf("Hello world from c");
}
}
__go_code{
package main
import "fmt"
func main2(){
fmt.Println("Hello world from go")
}
}
fn main(){
main1()
main2()
println("hello world")
}

Use Case

be more convenient for using c and go source code libraries

Proposed Solution

No response

Other Information

No response

Acknowledgements

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

Version used

0.4.3

Environment details (OS name and version, etc.)

V full version: V 0.4.3 cd337e2
OS: windows, Microsoft Windows Server 2022 Datacenter v20348 64-bit
Processor: 16 cpus, 64bit, little endian,

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.

@Jimmy2099 Jimmy2099 added the Feature Request This issue is made to request a feature. label Dec 7, 2023
@exapsy
Copy link

exapsy commented Dec 8, 2023

Wouldn't that require to have Golang's tooling? I think it would make it probably co-dependent on Golang, which means, what version of Golang do you want exactly? Would you define that as @latest? What if you don't want the latest. What if you want to download modules, now you have to have a vendor dir as well?

Honestly it seems like a great feature in a Utopian Vlang, but in real life from my perspective it probably would come with many uncertainties, unneeded dependencies for many, Vlang's resources would start getting invested into integrating it with Golang.
I mean, C is pretty much established and without much tooling involved and the tooling is usually pre-installed in every system. But Golang?

Also, what if you want headers, like use other libraries, how would that be managed. Seems that even C comes with its own challenges as well.

Even in Golang, an already established for more than a decade language, the way you use C inside it is like this

package main

/*
#include "mycfile.h"
*/
import "C"

func main() {
    C.mycfunction()
}

* Which is already supported in Vlang .

It's not like you write C inside Golang. You write C files which you just depend on in your Golang code.
Writing C inside Vlang or even worse for the matter of complexity, Golang, seems like an unnecessary added complexity to maintenance to me I don't know.

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

No branches or pull requests

2 participants