Re: [Cbor] A CBOR tag for alternatives/unions, request for comments

Michael Richardson <mcr+ietf@sandelman.ca> Wed, 23 February 2022 23:30 UTC

Return-Path: <mcr+ietf@sandelman.ca>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6D6823A10BA for <cbor@ietfa.amsl.com>; Wed, 23 Feb 2022 15:30:48 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.099
X-Spam-Level:
X-Spam-Status: No, score=-2.099 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=sandelman.ca
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b3neW4E16Rbs for <cbor@ietfa.amsl.com>; Wed, 23 Feb 2022 15:30:43 -0800 (PST)
Received: from tuna.sandelman.ca (tuna.sandelman.ca [209.87.249.19]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id AAEC93A10D8 for <cbor@ietf.org>; Wed, 23 Feb 2022 15:30:42 -0800 (PST)
Received: from localhost (localhost [127.0.0.1]) by tuna.sandelman.ca (Postfix) with ESMTP id 59FFD38F6D; Wed, 23 Feb 2022 18:39:16 -0500 (EST)
Received: from tuna.sandelman.ca ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with LMTP id VcRcsxVSM1QL; Wed, 23 Feb 2022 18:39:14 -0500 (EST)
Received: from sandelman.ca (obiwan.sandelman.ca [IPv6:2607:f0b0:f:2::247]) by tuna.sandelman.ca (Postfix) with ESMTP id 5532A38F67; Wed, 23 Feb 2022 18:39:14 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sandelman.ca; s=mail; t=1645659554; bh=vun0ctZPRGfmGXt7glk/BxeItfApB6clWFhUrNmRsEg=; h=From:To:Subject:In-Reply-To:References:Date:From; b=NQbfOfA9CnVHH0Cmz1Su1fNtNV4IdslLgORH7KqyDmcuOjt3fQKKTF8JU8Zbb7VuV yQpzZz9CZBv5Ls7GprpYg6zhKd1w7Qm6VPxtW2ZLE9XO8jc9sqpR4YxaGmrEMwvupm sZ9ecV10/3+LnfiOY7Ccf2t0QcN1AZ26rsDqvjMUq7VQ9J9veqlDDgmhGBhAxNmyFU WrtxgcqxM7+VrV8gNgo/XdX5MWTPDzrEd/J14tiG/OgZxaQz3YG7ZqBtO7FK0z3tBY EUw2lCk2yj1Dovll/pRAT9fOLe8baqsFUTsRuImBNOsdgZwP1PB9+7vQW7vHUDewWX Ioxb2V+V23kKA==
Received: from localhost (localhost [IPv6:::1]) by sandelman.ca (Postfix) with ESMTP id F2119537; Wed, 23 Feb 2022 18:30:38 -0500 (EST)
From: Michael Richardson <mcr+ietf@sandelman.ca>
To: Carsten Bormann <cabo@tzi.org>, Michael Peyton Jones <michael.peyton-jones@iohk.io>, Duncan Coutts <duncan@well-typed.com>, cbor@ietf.org, Jared Corduan <jared.corduan@iohk.io>, Alexander Byaly <alexander.byaly@iohk.io>
In-Reply-To: <4B47F4D7-ADE3-4A22-8A5B-97F4E5FCD933@tzi.org>
References: <9300a81abc33a45a9f3c7c1c62da88908280e54a.camel@well-typed.com> <1D3EF118-0223-43BC-81B2-369D4515DB21@tzi.org> <1ce2c092d3214d5fdce59435fc10b084c1ba48ca.camel@well-typed.com> <DFCBE61C-35B2-42A2-8D1A-A633CF939154@tzi.org> <2e10456c5791a422bf7218e7b84051f2b7121b66.camel@well-typed.com> <CAKoRMYGcwrhVWd-J3dX75WZfc+T_oyb6NCUNaeCXMW5_-VYdTw@mail.gmail.com> <52EDB93C-827A-465F-B644-51B3EF590D06@tzi.org> <C9D895BB-40E6-431F-958F-AC031DE4FB58@tzi.org> <CAKoRMYG9X0JF4ehkMc30_UNi0JtT2YMeG4RgxznS6O3Di6pkRA@mail.gmail.com> <CAKoRMYHwewaYxkX=CsfETBbdV7c9U97jfbd9xg=PyrMX5vJhnA@mail.gmail.com> <3B3B7EF0-152B-4015-8485-B204F7AEFFBC@tzi.org> <CAKoRMYFbEG=TkuZPPOiXv2DjEh23Ujd_Q44kQqiWPGc_0GMTuQ@mail.gmail.com> <CAKoRMYHnF6fGJp1dTrJnRHFTBOhreLRwzR_=cCckW1nBXOEz0A@mail.gmail.com> <E8A9E016-2248-4BB9-9864-C6C7D52A4AE5@tzi.org> <CAKoRMYE+gmWyCL9zYDa-O-c3KV_iuzgYuS+Q4fi=U7VHDNDtkQ@mail.gmail.com> <CAKoRMYFdAr1YY3mtmY0NU5X9Bk8_4WYh7bC0CtXpZc3toLSu8g@mail.gmail.com> <7FA54553-5421-4C45-B7DD-E9B2 D379F46F@tzi.org> <CAKoRMYH3MTMi_tX5KHF-O-DTKzopiGqe3fi6XjkPaGCM4823OQ@mail.gmail.com> <7dfd62ccb6c089af90c90f26a8945f23232ecbc1.camel@well-typed.com> <CAKoRMYEOo1Gqfc4W4k3NOLKpFa97Q9YzLCm3r0PJ13V2HJPf3A@mail.gmail.com> <2BBF6463-FDB2-4A8A-B20D-7A1AD976A90D@tzi.org> <CAKoRMYFi8uo2GfHA9s1n+-rMO8Ja9=2qMMzjS9Z=F9r3LFozRQ@mail.gmail.com> <8EA89504-C176-4850-9BB8-C7E7206374FF@tzi.org> <CAKoRMYGmOa0hzEFsJh8kpz0bU5x56Yc9P=DBK-ghU83gXxPv7A@mail.gmail.com> <CAKoRMYGUvmxufQUVyvX2mciq5LCmV0Nz-uE2MJn54GDBB+9DRw@mail.gmail.com> <CAKoRMYF_19V6mu4S9GVqfiNzyQVvvOzX6eYwHp_DtZQoG0xTKg@mail.gmail.com> <4B47F4D7-ADE3-4A22-8A5B-97F4E5FCD933@tzi.org>
X-Mailer: MH-E 8.6+git; nmh 1.7+dev; GNU Emacs 26.1
X-Face: $\n1pF)h^`}$H>Hk{L"x@)JS7<%Az}5RyS@k9X%29-lHB$Ti.V>2bi.~ehC0; <'$9xN5Ub# z!G,p`nR&p7Fz@^UXIn156S8.~^@MJ*mMsD7=QFeq%AL4m<nPbLgmtKK-5dC@#:k
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-="; micalg="pgp-sha512"; protocol="application/pgp-signature"
Date: Wed, 23 Feb 2022 18:30:38 -0500
Message-ID: <26378.1645659038@localhost>
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/HK5wvSYG2eZZnpA1Zh3aVuvjFtQ>
Subject: Re: [Cbor] A CBOR tag for alternatives/unions, request for comments
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 23 Feb 2022 23:30:49 -0000

{why haven't we adopted this document yet?}

Hi, I've reviewed section 9 of notable-tags-06.
I raised a minor PR: https://github.com/cabo/notable-tags/pull/1
because I had to stare at the [uint,value] part really hard before I
understood things.  Part of the issue is that the "value" in the previous two
cases was just "obvious", and then I couldn't understand what it meant in the
third case.

I understood from the meeting this morning that tag 101 'e', is not actually
available.  But, actually it looks like it is according to IANA.org.
Or was it that another draft wanted it?
How about 'x' (NOPE) 'X' YES. 'u' YES.
https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml#cbor-tags

I think that the document might explain why we optimize the first 7 (0..6),
rather than the first 3 or 5 or 9.  Are the next 128 worth it?
I wonder if there are more than 7, are there typically more 100s?
If it turns out that 9 is the sweet spot, I'd be okay with more 1+1
and no 1+2.  I don't have any data on this.
I wonder if Michael, Duncan, Jared or Alexander do?

I agree with the discussion that tag 101 could just encode 0..x
rather than uint+128.  I think that the simpler encoder might be worth it
here.  Particularly in some cases where I suspect which ones are the lower
numbered onces might not be known until later, and some code wants to come
back and fill in the alternatives afterwards, having left 1+4 for the uint or
something like that.

--
Michael Richardson <mcr+IETF@sandelman.ca>   . o O ( IPv6 IøT consulting )
           Sandelman Software Works Inc, Ottawa and Worldwide