Re: [Cbor] cbor-packed: Circumfix expansion

Christian Amsüss <> Mon, 01 February 2021 18:22 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id EA83B3A138C; Mon, 1 Feb 2021 10:22:16 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -1.899
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 ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id kEW_XGW8Qz_d; Mon, 1 Feb 2021 10:22:14 -0800 (PST)
Received: from ( [IPv6:2a01:4f8:190:3064::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by (Postfix) with ESMTPS id 777183A138B; Mon, 1 Feb 2021 10:22:11 -0800 (PST)
Received: from (unknown [IPv6:2a02:b18:c13b:8010:a800:ff:fede:b1bd]) by (Postfix) with ESMTPS id E1B2C407CF; Mon, 1 Feb 2021 19:22:08 +0100 (CET)
Received: from ( []) by (Postfix) with ESMTP id 152AAFD; Mon, 1 Feb 2021 19:22:07 +0100 (CET)
Received: from (unknown [IPv6:2a02:b18:c13b:8010:7502:722c:4e86:561f]) by (Postfix) with ESMTPSA id 9C53E44; Mon, 1 Feb 2021 19:22:06 +0100 (CET)
Received: (nullmailer pid 139403 invoked by uid 1000); Mon, 01 Feb 2021 18:22:06 -0000
Date: Mon, 01 Feb 2021 19:22:06 +0100
From: Christian Amsüss <>
To: Carsten Bormann <>
Message-ID: <>
References: <> <>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="uQTJpSE/bOK7sl+h"
Content-Disposition: inline
In-Reply-To: <>
Archived-At: <>
Subject: Re: [Cbor] cbor-packed: Circumfix expansion
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Mon, 01 Feb 2021 18:22:17 -0000

On Mon, Feb 01, 2021 at 01:24:26PM +0100, Carsten Bormann wrote:
> is the most general form of this that I have written up.
> This assumes that the SCHC environment does the referencing, so it
> only defines the referee (template), not the referent (invocation).
> The example has only one parameter, but could have more.
> Can we package that in a way that is useful for cbor-packed?

Possibly we may first want to do this the other way round -- for what is
a CBOR template other than a CBOR snippet that can be expanded to a full
CBOR item?

The only difference is that unlike in the regular case, the compressor
and uncompressor may not agree on the precise values to be expanded (but
still must on their semantics). The static context would define these
semantics, and the concrete table entries are set from the data the SCHC
environment picks out of whereever.

On a tangent, this opens questions about the applicability to core-href.
(If we can have compressed items that are only semantically but not
contentually agreed on, can core-href semantically always encode full
URIs but have packing tables prepopulated with "the current base
origin", "the current base uri without query parameters" etc?).

> (I do see the complexity issue.)

Come to think of it, if this is done smart, all the complexity of such
an expansion could sit in additional tags that build on cbor-packed.

For a strawman example, a For-Each-Tag could be defined in relatively
simple terms by making it an array [a_0, a_1, ..., a_n], with a_0 used as a
template, and it expands to an m long array (where m is the equal length
of all a_i). Before a_0 is expanded (as it WILL PROBABLY contain Tag-6
items), n-1 shared items are taken from a_1..a_n and injected at the
start of the Current Set.

Such a For-Each tag is clearly more complex in processing than all the
other packing substituion -- but (even if it turns out we want it, which
I don't consider settled) it wouldn't need to be part of cbor-packed,
and wouldn't scare users.

All we'd need to get "right" for this is to be clear about which scoping
rules apply in the recursive expansion for the case that something
between table-setup and item-use meddles with the Current Set. (AFAIU
it's implied by overriding dictionaries being useful, but words like
"dynmaic scoping" and examples should help).


To use raw power is to make yourself infinitely vulnerable to greater powers.
  -- Bene Gesserit axiom