Is possible to have shared structs in Webassembly?
WebAssembly (often abbreviated as Wasm) is a low-level compiled target language designed for stack-based virtual machines, enabling code written in different languages to run efficiently within web browsers. The design of Wasm emphasizes performance, security, and portability.When discussing "shared structures," this may refer to several concepts:Memory Sharing: Wasm modules can create and manipulate linear memory, which is a contiguous byte array, but this memory is allocated to a single Wasm module. However, the WebAssembly threading proposal introduces , allowing memory to be shared among multiple Web Workers and enabling concurrent execution. This facilitates a shared memory structure accessible by multiple threads or Wasm modules.Inter-module Sharing: Wasm modules can import and export functions, memory, and global variables, enabling modules to share code and data. For example, one module can export a function or memory reference, which other modules can import and utilize. This approach supports building shared structures, such as utility libraries or shared data structures.Object Sharing: If referring to concepts like sharing complex objects (e.g., JavaScript object literals or class instances), Wasm itself does not directly support such high-level features. However, through the JavaScript interface of WebAssembly, complex data structures can be passed between Wasm modules and the host environment (e.g., the JavaScript environment in a web browser).In future WebAssembly updates, new features may support more sophisticated sharing mechanisms. For instance, the Interface Types proposal will simplify sharing and exchanging high-level data structures across modules written in different languages, without requiring JavaScript intermediaries.Please note that WebAssembly's features and proposals are continuously evolving, so future developments may introduce richer shared structures and enhanced cross-module interactions.