Subject: [Cbor] Next steps for additional data types

From: <[email-masked]>
Date: Wed, 29 Jun 2016 17:19:12 +0000

Hi, has there been any discussion of where these two proposals fit with the existing TypedArray proposal?

Should these be proposed as new tags to IANA or enveloped by the TypedArray proposal?

Just to recap, the two suggestions were mechanisms to provide for 1) multi-dimensional arrays and 2) TypeArrays of other types not provided for in the TypedArray proposal (e.g. bool[], string[], timestamp[], map[]).

1. Multi-dimensional array

Tag: XX
Data Item: array
Semantics: Multi-dimensional array

A multi-dimensional array is represented as a tagged array that contains two arrays.  The first array defines the dimensions of the multi-dimensional array while the second array represents the contents of the multi-dimensional array.  If the second array is itself tagged as a TypedArray then the type of the multi-dimensional array is assumed to be the same type as the TypedArray.   Data in the TypedArray byte string consists of consecutive values where the last dimension is considered contiguous (row-major order). 

uint16_t a[2][3] = {  
  {0, 1, 2},   /* row 0 */
  {3, 4, 5},  
};

<Tag XX>    # multi-dim array tag
   82       # array(2)
      82    # array(2)
         02 # unsigned(2) 1st Dimension
        03 # unsigned(3) 2nd Dimension
     d8 41 # uint16 array
         4a    # byte string(12)
            00 00 # unsigned(0)
            00 01 # unsigned(1)
            00 02 # unsigned(2)
            00 03 # unsigned(3)
            00 04 # unsigned(4)
            00 05 # unsigned(5)

2. Homogeneous Array

Tag: YY
Data Item: array
Semantics: Homogeneous Array

This tag provides a hint to decoders that the following array has elements that are all of the same type.   The type of the array is thus determined by the type of the first array element.  This can be used by strongly typed languages while decoding  to create native arrays of specific types instead of ordered lists.

bool boolArray[2] = { true, false };

<Tag YY>  # Homogeneous Array Tag
   82           #array(2)
      F5        # true
      F4        # false

Regards,

Glenn Engel

---

From: Carsten Bormann <[email-masked]>
Date: Wed, 29 Jun 2016 20:42:57 +0200

> Hi, has there been any discussion of where these two proposals fit with the existing TypedArray proposal?

No, not yet.  There are still a few days up to the Internet-Draft
deadline for the Berlin meeting...

>From the point of view of the work needed, It is probably most
economical to include them in the typed array draft, even if they don't
fit perfectly.

> A multi-dimensional array is represented as a tagged array that contains two arrays.  The first array defines the dimensions of the multi-dimensional array while the second array represents the con…

We probably need to add a little bit more text about what sets of values
should be considered a homogeneous set (e.g., is null included or not;
float vs. int, int vs. uint, ...).  A few more examples would help.  The
guiding principle probably should be what can be represented in a
typical static-type programming language as a homogeneous array.

Grüße, Carsten