4 ms·
You may choose whatever storage duration you feel like for your own types, but built in types are globally declared and therefore shared between VM instances.
by codr7 6y ago
You may choose whatever storage duration you feel like for your own types, but built in types are globally declared and therefore shared between VM instances.
- matheusmoreira 6y agoI see, so it refers to the C storage class. There can be several virtual machine instances referencing the same built-in integer type instance. This imposes on users the need to call lg_init() and lg_deinit() before and after using the library. I feel like this could have been avoided by statically enumerating the built-in types instead of initializing a data structure dynamically. The data type structure contains pointers to functions that implement operations such as addition, subtraction, copying and cloning. An integer type instance is initialized with addition and subtraction functions. The integer value representation is part of the value data structure though. So how could a user of the library define new data types? It seems like it would be necessary to modify the library's source code in order to add new members to the tagged union. Also, perhaps the virtual machine could be optimized further by using tagged pointers to make integer values immediate, avoiding the need to dereference the pointer.
- codr7 6y agoYou would either have to reuse one of the existing representations or modify the union atm. I'll add a void *as_any to the union eventually which means you're just one level of indirection from supporting any representation without touching the union.