Re: [Cbor] Use of cuts in maps

Jim Schaad <ietf@augustcellars.com> Thu, 08 August 2019 04:54 UTC

Return-Path: <ietf@augustcellars.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 6D3B1120096 for <cbor@ietfa.amsl.com>; Wed, 7 Aug 2019 21:54:22 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 cGGixcpWaw6k for <cbor@ietfa.amsl.com>; Wed, 7 Aug 2019 21:54:20 -0700 (PDT)
Received: from mail2.augustcellars.com (augustcellars.com [50.45.239.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 43A6D12000E for <cbor@ietf.org>; Wed, 7 Aug 2019 21:54:20 -0700 (PDT)
Received: from Jude (73.180.8.170) by mail2.augustcellars.com (192.168.0.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 7 Aug 2019 21:53:51 -0700
From: Jim Schaad <ietf@augustcellars.com>
To: 'Carsten Bormann' <cabocabo@gmail.com>
CC: cbor@ietf.org
References: <001301d54d69$722a3050$567e90f0$@augustcellars.com> <36B01785-0024-40B3-9CC8-3D28F19174F5@gmail.com>
In-Reply-To: <36B01785-0024-40B3-9CC8-3D28F19174F5@gmail.com>
Date: Wed, 07 Aug 2019 21:53:49 -0700
Message-ID: <006301d54da5$468d36e0$d3a7a4a0$@augustcellars.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQFPTtQqZfsVk0/CGivvvF6n5rHJJwDctWEqp/XFNQA=
Content-Language: en-us
X-Originating-IP: [73.180.8.170]
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/TOXPSmNv3nd-j_u7bTPqny0OaNc>
Subject: Re: [Cbor] Use of cuts in maps
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, 08 Aug 2019 04:54:22 -0000

Carsten,

Thanks.  I was really more worried about the conceptual idea than I was about the exact syntax.

I would suggest that this idea become part of the idiom wiki as this solves the major problem that I had with the entire idea of how cuts have been implemented in the language.  

It should probably have two expansion points, one for values and one for types, that is "foo": int is separated from int: int.  

Jim


-----Original Message-----
From: Carsten Bormann <cabocabo@gmail.com> 
Sent: Wednesday, August 7, 2019 9:41 PM
To: Jim Schaad <ietf@augustcellars.com>
Cc: cbor@ietf.org
Subject: Re: Use of cuts in maps

Hi Jim,


> On Aug 7, 2019, at 23:45, Jim Schaad <ietf@augustcellars.com> wrote:
> 
> One of the issues that I have always had with the way that cuts are 
> specified in CDDL is that they don't behave the way that I think they 
> should in terms of going from the most specific to the most general.  
> I think that I have found a way around this problem and want to verify 
> that it would work.
> 
> 
> Start I start with
> 
> map-example = {
>   ? "optional-key" : int,
>   map-example-extensions,
>   * tstr => any
> }
> 
> map-example-extensions = ()
> 
> The next document comes along and does
> 
> map-example-extensions /= (

This would need to be a »//=«.

>   "another-optional-key" : tstr,
>  “and a third": bstr
> )

And these would need a »?« each to be independently optional; right now you are saying they need to be both there.

> 
> If I compile the two modules together, do you believe that this would 
> be a match or not?
> 
> { “and a third" : 15 }

With the above changes, this would match the »”and a third”:« and then fail on the bstr post-cut, so the whole map would not match.

I would probably restructure this to:

map-example = {
  ? optional-key : int,
  * map-example-extension,
  * tstr => any
}

map-example-extension = ()

map-example-extension //= (another-optional-key : tstr,) map-example-extension //= (“and a third”: bstr,)

so further additions can be made without excluding the ones already made.

Grüße, Carsten