@@ -74,9 +74,13 @@ remove-duplicates: func(offset: i32, length: i32) -> [i32, i32]
7474supposing that ` remove-duplicates ` is a function
7575to create a new string consisting of the unique characters
7676in its argument.
77- The return type is a pair of 32-bit integers,
78- reflecting that the function must return
79- the new offset for the newly allocated string, as well as its length.
77+ The return type is a list of two 32-bit integers.
78+ The first integer is an offset into one of the linear memories
79+ declared by the module—where the newly allocated string starts—and
80+ the second integer is the length of the string.
81+ After calling the function,
82+ the caller has to reach into the appropriate linear memory
83+ and read the output string, using the returned offset and length.
8084
8185For this to work, the module defining the ` remove-duplicates ` function
8286would also need to include
@@ -98,6 +102,15 @@ import "strings" "string_mem"
98102also needs to declare the size of the memory being
99103imported.)
100104
105+ Note that there is nothing in the type system to prevent
106+ the returned length from being confused with the returned offset,
107+ since both are integers.
108+ Also, the name of the memory used for the input and output strings
109+ must be established by convention,
110+ and there is also nothing in the type system to stop client code
111+ from indexing into a different memory
112+ (as long as the sum of the offset and length is within bounds).
113+
101114We would prefer to write a pseudocode type signature like this:
102115
103116```
0 commit comments