Re: [Cbor] CDDL Module Design

Carsten Bormann <cabo@tzi.org> Wed, 01 July 2020 21:57 UTC

Return-Path: <cabo@tzi.org>
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 D42963A0E1C for <cbor@ietfa.amsl.com>; Wed, 1 Jul 2020 14:57:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.897
X-Spam-Level:
X-Spam-Status: No, score=-1.897 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 3d57MA5R3EZg for <cbor@ietfa.amsl.com>; Wed, 1 Jul 2020 14:57:29 -0700 (PDT)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id C4BB93A0E1A for <cbor@ietf.org>; Wed, 1 Jul 2020 14:57:28 -0700 (PDT)
Received: from [172.16.42.112] (p5089ae91.dip0.t-ipconnect.de [80.137.174.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 49xw7V4k0rzyjd; Wed, 1 Jul 2020 23:57:26 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <26498.1593639639@localhost>
Date: Wed, 01 Jul 2020 23:57:26 +0200
Cc: cbor@ietf.org, Jim Schaad <ietf@augustcellars.com>
X-Mao-Original-Outgoing-Id: 615333446.2779469-671f50105a836c2d5bce3325284c5182
Content-Transfer-Encoding: quoted-printable
Message-Id: <C38C9147-3824-4651-92D8-3E3C57D596E7@tzi.org>
References: <03c701d64f41$e1763fa0$a462bee0$@augustcellars.com> <24433.1593575640@localhost> <51575EAF-1090-4989-A124-D19CE5553494@tzi.org> <32409.1593617439@localhost> <26498.1593639639@localhost>
To: Michael Richardson <mcr@sandelman.ca>
X-Mailer: Apple Mail (2.3608.80.23.2.2)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/oSpyW19CbF4jm6Ag3eaj8JXXjao>
Subject: Re: [Cbor] CDDL Module Design
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, 01 Jul 2020 21:57:32 -0000


> On 2020-07-01, at 23:40, Michael Richardson <mcr@sandelman.ca> wrote:
> 
> 
> Michael Richardson <mcr+ietf@sandelman.ca> wrote:
>>> On 2020-07-01, at 05:54, Michael Richardson <mcr+ietf@sandelman.ca> wrote:
>>>> 
>>>> I prefer that the statement not be a pre-processor-like hack.
> 
>>> The C/C++ preprocessor may be considered a hack because it operates at
>>> a lexical level.  We should not make that mistake.  Apart from that, it
>>> does useful things.
> 
>>> Or, in other words, your hack may be my perfect layering.
> 
>> I agree.
>> As has been pointed out in
>> https://www.goodreads.com/book/show/44919.Working_Effectively_with_Legacy_Code
> 
>> the preprocessor is a really good tool for inserting shims.
> 
> The word I wanted was "seams", not shims.
> C gives you pre-processor seams, and link seams.
> Java lets you have neither.
> 
> A seam is a way to replace some function, usually something low-level like
> "open(2)" or "socket(2)" so that in a unit test you can feed in test data
> rather than live data.

We call that a “mock” (see [1] for another take of this, which involves “fake”s).  (Which may be implemented as a shim, i.e., recurring on the real function, which when made into an art form is also known as “advising” or “advice” [2].  Or as a “stub”.)

Real programming involves the use of linker scripts, where you often can rearrange some of the symbols or map one to the other.  I think it would be good if we have some isolation between the world of external names (and name references) and the internal symbols in a specification.  If this is not to become too tedious, some optional automation of setting up the mapping (and a way to gradually escape that automation) is desirable.

Hacking some of this functionality together at the lexical level (as the preprocessor makes you do) usually provides leaky abstractions, where the leak eventually bites you.  That’s why CDDL has generics, not macros (not that macros would be wrong, if done hygienically instead of lexically).

Grüße, Carsten

[1]: https://www.infoworld.com/article/3143104/my-two-cents-on-fakes-stubs-mocks-and-shims.html
[2]: https://en.wikipedia.org/wiki/Advice_(programming)