vlang / vinix

Vinix is an effort to write a modern, fast, and useful operating system in the V programming language
https://vlang.io
GNU General Public License v2.0
1.89k stars 120 forks source link

C.event__trigger call in modules/time/time.v #126

Closed hyperfocusaurus closed 6 months ago

hyperfocusaurus commented 8 months ago

Hi there! I'm using VINIX to learn how to write an operating system, and in the process of porting the event subsystem into my own OS I spotted a bit of a strange calling convention in the event.v file.

On line 79, there's a C function declared called event__trigger, which is then called on line 94. I believe this is actually calling the V function event.trigger from the event module, however it is doing it using the calling conventions used for calling into C code for some reason. It gets away with it because of the way Vlang clobbers function names (module.function -> module__function) making it actually a "valid" call, but this exposure of V's internals is potentially unstable so I thought I'd bring it to your attention.

If there's an actual reason behind this, or if I'm misunderstanding something, I'm happy to be corrected!

mintsuki commented 6 months ago

The reason is that sometimes I did this to get around V's cyclic importing restrictions.

hyperfocusaurus commented 6 months ago

Ah gotcha, ok. I'll close this now then, but hopefully it'll serve as a reference if anyone else gets confused by the same thing.