Skip to content

Mixed types #3

@bengl

Description

@bengl

From #1:

  1. The API needs to appropriately consider the differences in interpretation of different TypedArray types. Specifically, it should be possible to concat only like-types (e.g. Uint8Array + Uint8Array, Float64Array + Float64Array, etc). Mixing types should likely be forbidden.

and from the slides:

Typical use case is concat'ing same type (u8 + u8, u32 + u32, etc) so handling mixed unnecessary

A common thing I do is encode data of multiple different numeric types into the same buffer. For example, an ArrayBuffer that's composed of data originating in a sequence looking like [Uint8Array[1], Float64Array[2], Int32Array[1], ...]. This also comes up when attempting to create or manipulate C structs within ArrayBuffers. Today, this usually involves something like a DataView or having multiple TypedArray views on the same ArrayBuffer and indexing appropriately. If I already have the sequence of TypedArrays of various types handy, which is often the case, it would be nice to let the language implementation take care of the concatenation bookkeeping, and even handle it lazily where possible.

In short, yes, mixing types for concatenation is useful. Perhaps, depending on the conclusion of #2, an ArrayBuffer.concat could be provided, taking in an iterator of arbitrarily-typed views.

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