From nobody Wed Dec  1 16:02:54 2021
Return-Path: <emile.cormier.jr@gmail.com>
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 A13093A0D17
 for <cbor@ietfa.amsl.com>; Wed,  1 Dec 2021 16:02:52 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.097
X-Spam-Level: 
X-Spam-Status: No, score=-2.097 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, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, 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=gmail.com
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 EQ5u-MB2qd5t for <cbor@ietfa.amsl.com>;
 Wed,  1 Dec 2021 16:02:47 -0800 (PST)
Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com
 [IPv6:2607:f8b0:4864:20::b2f])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by ietfa.amsl.com (Postfix) with ESMTPS id 3B7C43A0D09
 for <cbor@ietf.org>; Wed,  1 Dec 2021 16:02:47 -0800 (PST)
Received: by mail-yb1-xb2f.google.com with SMTP id q74so68309470ybq.11
 for <cbor@ietf.org>; Wed, 01 Dec 2021 16:02:47 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to; 
 bh=MgTPq0czc5m0UnDwq+hi//LTC2Tf6uYq8lKsTVvVVTw=;
 b=AcYMZa2ihzLWgJISRXBh8FiTSFZfy9/B5HUMwBLvtMNcva/RiEmUVWlaRoluKfpyH0
 bMbvtAbHDbud+mnV6PcbuOLRw0RZIaProa1f4AVhMUVZ1yLcrtoK/xmh1FHtx+129yE+
 khEo9cYsMFiGukwBf/aIYouRyxYUiawzP6TZ+zrEqy+jrPG5owgL6Jz/6efYwVGS36xk
 HEo3hhtgs1j0iTbWpNiQst6TSbvfM6cxmfmFIgmoyRwrsN0VEpMZ0YIUmAOQ8v/PXFck
 rq4nhsIejgDWXQmLfl6hKwYDIoPKl7XCw1/9lCG8TV/+AkAWxuBXsbC4zcmb/RCCH15m
 nhrg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to;
 bh=MgTPq0czc5m0UnDwq+hi//LTC2Tf6uYq8lKsTVvVVTw=;
 b=wgeJOl7L8wO0iHxGro9I2n3JnPU8PlglqERQf3J2l0fgWLHGXXv5xr5J7EQjaPR6Xd
 1bAYw5OCpKtAiIAZnvxiCO9T+D3cCOiDeKxDWMzBJBJWX502/St4g1gI3++l4s7gCzxT
 eWG1dqsaHuwTdDKxJf6yjbIu7ud1kWWWQVu3ndiFbsEAA3JyHZmctg69Ks3FD+hU9A7q
 pGwo7tFGZOgehj7pXgbrQE22ZGd3W/T7qiIaE5YUqSRr366c0RNPufstg+qWySRoS5ek
 BXkbxtQ6AS5BLNS1hZijTtFf3RZHDtsr6cckdBI2ojRET0eQmMFgJf9oPZ0o1frarCpv
 6AqQ==
X-Gm-Message-State: AOAM533YzrPq6izRr2J1db89OZk4Fy+T+Uifa22xahUlsl2tUB1fCQ9o
 eb2X9eVCuPEvpm+Ib1L/+xlm7vZkfmoSCDO1uoo=
X-Google-Smtp-Source: ABdhPJyil1w7Gsc/q7xl/MIDibV0ANeISJT9xn99oUDx5JYXAJ3XiGozbaXZ1dwfkhrdW33ZDSsrtDqGZSVd4Rvi60g=
X-Received: by 2002:a25:bfca:: with SMTP id q10mr10689134ybm.68.1638403365049; 
 Wed, 01 Dec 2021 16:02:45 -0800 (PST)
MIME-Version: 1.0
References: <CAM70yxC_6JnG+CbumDs+-maOcMYyRZXAD1QJgXJQsG2tYFVVdQ@mail.gmail.com>
In-Reply-To: <CAM70yxC_6JnG+CbumDs+-maOcMYyRZXAD1QJgXJQsG2tYFVVdQ@mail.gmail.com>
From: Emile Cormier <emile.cormier.jr@gmail.com>
Date: Wed, 1 Dec 2021 20:02:34 -0400
Message-ID: <CAM70yxCznYR4BtNxrpe6can6Y57A+3EAjkjkQBmKNDY6XXAL=A@mail.gmail.com>
To: Carsten Bormann <cabo@tzi.org>, cbor@ietf.org
Content-Type: multipart/alternative; boundary="0000000000009299d405d21e82e3"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/cWXAsKzxaFWF9oUGnPOLQPEYcwQ>
Subject: Re: [Cbor] CBOR tag proposal for enumerated alternatives (tagged
 unions)
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: Thu, 02 Dec 2021 00:02:53 -0000

--0000000000009299d405d21e82e3
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I don't know where we are with this proposal, but I'd like to point that it
suffers from the same problem I've mentioned recently for bignum and
records: too much information is embedded in the tag, which results in the
data items being unusable when transcoded to JSON (or when a CBOR decoder
discards the tags).

Cheers,
Emile Cormier

On Wed, Apr 7, 2021 at 6:37 PM Emile Cormier <emile.cormier.jr@gmail.com>
wrote:

> On Wed, Mar 31, 2021 at 9:38 AM Carsten Bormann <cabo@tzi.org> wrote:
>
>> I=E2=80=99m not sure we discussed this one yet in detail:
>>
>>
>> https://docs.google.com/document/d/16aiDEBhJj3kipj_7PVppEhxAr5E6QhQreN61=
eCxvBjU/edit#
>>
>> This is a (cbor-tags) registration request, so the WG does not have to
>> have an opinion, but the designated expert would be interested in it
>> nonetheless.
>> (I=E2=80=99m personally pretty convinced of the use case; this is more o=
f an
>> issue of keeping tabs on available tag numbers and looking out for relat=
ed
>> use cases.)
>>
>
> As I had mentioned in the interim meeting, a related use case is
> optional<T> (aka Nullable<T>). The meeting host (Christian?) was
> questioning whether separate tags would be more appropriate to represent
> the optional<T> semantic.
>
> It would indeed be possible for the enumerated alternatives tags to be
> used for representing an optional<T>. For instance, alternative 0 would
> represent the "no value" state, followed by a null data item (0xF6),
> whereas alternative 1 would represent the "has value" state followed by t=
he
> actual value. However, this is just an arbitrary convention and the
> enumerated alternatives tags used in this fashion don't explicitly expres=
s
> the "optional" semantic (it has to be assumed by the application). I
> therefore agree that separate tags would be preferable for the optional<T=
>
> use case.
>
> I communicated with one of the co-authors of the enumerated alternatives
> proposal about the possibility of including extra tags for the optional<T=
>
> use case. They declined, not wanting to expand the scope of their proposa=
l,
> which is perfectly understandable.
>
> My idea of tags for representing optional<T> might be overkill. One can
> simply encode an optional value as either null (0xF6) or the actual value=
.
> A contrived example where this would not work is encoding
> optional<null_type> (i.e. "optional null").
>
> Anyway, the idea of tags for optional values is out there for the
> designated expert to consider. I cannot say if it's an idea actually wort=
h
> pursuing. I don't currently need them for encoding/decoding
> std::optional<T> in my C++ work (I just check for null when deserializing
> an optional value). However, I could definitely make use of the enumerate=
d
> alternatives tags for encoding/decoding std::variant<T0, T1, T2...>,
> especially when the alternative types are ambiguous once converted to CBO=
R.
>
> Cheers,
> Emile Cormier
>

--0000000000009299d405d21e82e3
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I don&#39;t know where we are with this proposal, but=
 I&#39;d like to point that it suffers from the same problem I&#39;ve menti=
oned recently for bignum and records: too much information is embedded in t=
he tag, which results in the data items being unusable when transcoded to J=
SON (or when a CBOR decoder discards the tags).</div><div><br></div><div>Ch=
eers,</div><div>Emile Cormier<br></div></div><br><div class=3D"gmail_quote"=
><div dir=3D"ltr" class=3D"gmail_attr">On Wed, Apr 7, 2021 at 6:37 PM Emile=
 Cormier &lt;<a href=3D"mailto:emile.cormier.jr@gmail.com">emile.cormier.jr=
@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr" cla=
ss=3D"gmail_attr">On Wed, Mar 31, 2021 at 9:38 AM Carsten Bormann &lt;<a hr=
ef=3D"mailto:cabo@tzi.org" target=3D"_blank">cabo@tzi.org</a>&gt; wrote:<br=
></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;=
border-left:1px solid rgb(204,204,204);padding-left:1ex">I=E2=80=99m not su=
re we discussed this one yet in detail:<br>
<br>
<a href=3D"https://docs.google.com/document/d/16aiDEBhJj3kipj_7PVppEhxAr5E6=
QhQreN61eCxvBjU/edit#" rel=3D"noreferrer" target=3D"_blank">https://docs.go=
ogle.com/document/d/16aiDEBhJj3kipj_7PVppEhxAr5E6QhQreN61eCxvBjU/edit#</a><=
br>
<br>
This is a (cbor-tags) registration request, so the WG does not have to have=
 an opinion, but the designated expert would be interested in it nonetheles=
s.<br>
(I=E2=80=99m personally pretty convinced of the use case; this is more of a=
n issue of keeping tabs on available tag numbers and looking out for relate=
d use cases.)<br></blockquote><div><br></div><div>As I had mentioned in the=
 interim meeting, a related use case is optional&lt;T&gt; (aka Nullable&lt;=
T&gt;). The meeting host (Christian?) was questioning whether separate tags=
 would be more appropriate to represent the optional&lt;T&gt; semantic.</di=
v><div><br></div><div>It would indeed be possible for the enumerated altern=
atives tags to be used for representing an optional&lt;T&gt;. For instance,=
 alternative 0 would represent the &quot;no value&quot; state, followed by =
a null data item (0xF6), whereas alternative 1 would represent the &quot;ha=
s value&quot; state followed by the actual value. However, this is just an =
arbitrary convention and the enumerated alternatives tags used in this fash=
ion don&#39;t explicitly express the &quot;optional&quot; semantic (it has =
to be assumed by the application). I therefore agree that separate tags wou=
ld be preferable for the optional&lt;T&gt; use case.<br></div><div><br></di=
v><div>I communicated with one of the co-authors of the enumerated alternat=
ives proposal about the possibility of including extra tags for the optiona=
l&lt;T&gt; use case. They declined, not wanting to expand the scope of thei=
r proposal, which is perfectly understandable.</div><div><br></div><div>My =
idea of tags for representing optional&lt;T&gt; might be overkill. One can =
simply encode an optional value as either null (0xF6) or the actual value. =
A contrived example where this would not work is encoding optional&lt;null_=
type&gt; (i.e. &quot;optional null&quot;).<br></div><div><br></div><div>Any=
way, the idea of tags for optional values is out there for the designated e=
xpert to consider. I cannot say if it&#39;s an idea actually worth pursuing=
. I don&#39;t currently need them for encoding/decoding std::optional&lt;T&=
gt; in my C++ work (I just check for null when deserializing an optional va=
lue). However, I could definitely make use of the enumerated alternatives t=
ags for encoding/decoding std::variant&lt;T0, T1, T2...&gt;, especially whe=
n the alternative types are ambiguous once converted to CBOR.<br></div><div=
><br></div><div>Cheers,</div><div>Emile Cormier<br></div></div></div>
</blockquote></div>

--0000000000009299d405d21e82e3--

