-
Notifications
You must be signed in to change notification settings - Fork 82
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 optional fixed length to lists #304
base: main
Are you sure you want to change the base?
Conversation
I'm not too familiar with the ABI, but can a large fixed-size List blow the stack? If so, it might be an idea to fall back to heap allocation after a certain size. |
The |
I’m glad to have fixed-width arrays added to WIT. However from the perspective of an ABI implementer, I struggle with the representation of fixed-length arrays as a variation of
Concretely, I’d vote for a new type, let‘s call it The WIT syntax for
|
I think we shouldn't let the CABI representational concerns determine the WIT- and Component-Model-level names we choose; rather we should just focus on what's the least confusing things to folks reading/writing WIT. Perhaps there is an argument that having both Overall, while I'm not opposed to having |
I don't think Without any numbers, it means that this is a list with unknown capacity (unknown at compile time) That is: list<T> = list<T, ?>
list<u8, 4> = tuple<u8, u8, u8, u8> Mutability needs to be passed via abi options and verified For example
Even though Therefore I suggest adding an abi option Considering that |
How are |
For tuples, according to my classification, the current working mode is In other words, if Unless the input parameters are greater than 16 or the return value is greater than 1, package examples: tests;
world imports {
import tuples;
}
interface tuples {
tuple0: func(x: tuple<>);
tuple1: func(x: tuple<u8>);
tuple2: func(x: tuple<u8, u8>);
tuple4: func(x: tuple<u8, u8, u8, u8>);
tuple16: func(x: tuple<u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8>);
tuple17: func(x: tuple<u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8>);
tuple-r0: func() -> tuple<>;
tuple-r1: func() -> tuple<u8>;
tuple-r2: func() -> tuple<u8, u8>;
} (module
(type (;0;) (func))
(type (;1;) (func (param i32)))
(type (;2;) (func (param i32 i32)))
(type (;3;) (func (param i32 i32 i32 i32)))
(type (;4;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32)))
(type (;5;) (func (result i32)))
(type (;6;) (func (param i32 i32 i32 i32) (result i32)))
(import "examples:tests/tuples" "tuple0" (func (;0;) (type 0)))
(import "examples:tests/tuples" "tuple1" (func (;1;) (type 1)))
(import "examples:tests/tuples" "tuple2" (func (;2;) (type 2)))
(import "examples:tests/tuples" "tuple4" (func (;3;) (type 3)))
(import "examples:tests/tuples" "tuple16" (func (;4;) (type 4)))
(import "examples:tests/tuples" "tuple17" (func (;5;) (type 1)))
(import "examples:tests/tuples" "tuple-r0" (func (;6;) (type 0)))
(import "examples:tests/tuples" "tuple-r1" (func (;7;) (type 5)))
(import "examples:tests/tuples" "tuple-r2" (func (;8;) (type 1)))
)
|
I just created a new MR #384 with the same changes but all conflicts resolved |
824fdc5
to
74bd278
Compare
This PR adds fixed-length lists as a "gated feature" (i.e., features spec'd and ready to implement, but not yet included in a Preview release), as proposed and discussed in #181.