Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

Q: Using records in function signatures #120

Open

Description

@mikevoronov

My question is related to Record type. Am I right considering Record as an analog of structs in high-level languages? If so, lets consider simple example of such struct and function that use it:

pub struct S {
    pub a: String,
    pub b: String,
}

fn foo(arg: S) -> S { arg }

How could signature of generated foo look like (keeping in mind, that Wasm supports 5 basic types)? Record.lower unlike string.lower_memory only just unwraps values on a stack. It doesn't write this type in Wasm memory anyhow and so on. So, this signature could look like fn foo(arg_0: String, arg_1: String) -> (String, String) {...}, but this behaviour is hard to obtain on languages like Rust/C++.

Activity

  1. changed the title [-]Q: Passing records in function types[/-] [+]Q: Using records in function signatures[/+] on Jul 10, 2020
  2. fgmccabe commented on Jul 13, 2020

    @fgmccabe
    Contributor

    not completely sure I understand this question.
    there will be an Interface Types analog for record types. It has not been completely nailed down, but the IT type signature for your function will be allowed to mention record types directly:
    (type $s (record
    ($a string)
    ($b string))
    (func foo (param $arg (type $s)) (result (type $s)))
    Hope this helps

  3. jgravelle-google commented on Jul 13, 2020

    @jgravelle-google
    Contributor

    Would it be able to use the record types directly from core-wasm, or just at the IT layer?
    Because I interpret this question as being about "how do core wasm and IT match up?"

    My understanding of that would be that it is going to be ABI-dependent, so the toolchain that generates the function will also be responsible for passing that information up to the IT adapters. But that's just my model of how the tools will interact here.

  4. mikevoronov commented on Jul 13, 2020

    @mikevoronov
    Author

    @jgravelle-google yes, exactly, thank you for clarifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions