Re: [Json] JSON Schema Language: extensibility and unspecified properties

Ulysse Carion <ulysse@segment.com> Tue, 20 August 2019 19:05 UTC

Return-Path: <ulysse@segment.com>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 0CC461201DE for <json@ietfa.amsl.com>; Tue, 20 Aug 2019 12:05:50 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.999
X-Spam-Level:
X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 (1024-bit key) header.d=segment.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 8twKedUYC6vL for <json@ietfa.amsl.com>; Tue, 20 Aug 2019 12:05:46 -0700 (PDT)
Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 8F20A120180 for <json@ietf.org>; Tue, 20 Aug 2019 12:05:46 -0700 (PDT)
Received: by mail-io1-xd2b.google.com with SMTP id p12so12056220iog.5 for <json@ietf.org>; Tue, 20 Aug 2019 12:05:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=segment.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=pQyL3PNIodtDTdeqdiEH/RF6E11rosvjB4S80O+V/L4=; b=qgnvPtgN1/wEpUsyMjxufsfowGSYqffgMJalkCRd8taNI9Eelwm6CmSk01aS9P5FZE ADN4gi92bqDDjgM2Q/NaqQPj34bD5Z+oL0GBaX6n0GlyHgJiHiKO6+auo6Mw8ZNoXYWD e+nWvf/FwXBVBEDC6dA9fSC68FJi1dHmjv3Lo=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=pQyL3PNIodtDTdeqdiEH/RF6E11rosvjB4S80O+V/L4=; b=JSODHZeT+XJNRqM/l4JGy3h+/F/KMPjNKB4JbXv1eX56HOE1yR28BYcXAw1fUPqo98 SI+Gb0yvD7jQnqFI2dMQyFzqRslEn+0Df99JjbUb3vin3IM6nN5828Radz8EqAsmj7zo u+dFuuw48atN/it+Y38KEzlr5rp91YCsiZC5zBtFSkoSKFpgX0LHCz0XPvVeuN/g9bo8 KL/Me4Hd/MYOpWa5j1vrlF8kxzqYCXc0RLd/SjeCqDgsVxAuN3tmMZGOrLVFCteyMK4Q A0FcZizqSrg/L40sbF7kFvORxkZbBV62wFdI8RmjejkqUQF5JOyQL/jj3YeUD5NCf15h j0Ig==
X-Gm-Message-State: APjAAAUCQ8obtH1xM5E4SPVrx88aQelJ+eWyUOaifIk8WNEu/Ktnmyxm bBzDqNNMWhDnpksXL825Us62L7NUEiMCfL6yI04Vqg==
X-Google-Smtp-Source: APXvYqzTG/aGBGL54vA0uuZgq8QDZUqb3rvp/GEVbbpyXGNB6ZjOkxF76x7W45iz2ATKwPESp0spJattPjYRceNkdPM=
X-Received: by 2002:a6b:630b:: with SMTP id p11mr21134366iog.284.1566327945739; Tue, 20 Aug 2019 12:05:45 -0700 (PDT)
MIME-Version: 1.0
References: <CAJK=1RhXp85cz-pOAQPw2JM=CYHgGSygj4Hw0spht56jbzQE2g@mail.gmail.com> <53094378-B559-49E1-B42B-54FBA8BC35AA@tzi.org> <CAJK=1Rj6Q3CvpF9aYML=47SF_XP49=O2hLhcBo8gZCb73C0RAw@mail.gmail.com> <FDB93E41-9D7D-4BF2-8D01-F4D075774848@tzi.org> <CAJK=1RiE_+nHkeB77DericN498w1v9mf2hsBgnQtgsZTVM9N9A@mail.gmail.com> <118F844A-453D-497D-8107-CF2BD05AC313@tzi.org> <CAJK=1Rgqek+rh+dj2xNWD7WKS48oQoHiqhj5dDT2D3dD7OZs1Q@mail.gmail.com> <CALH+fvpwM1hRByXv1y0UwUYPwKcb2JZT4v5qqZVeySFvEo-Z7A@mail.gmail.com> <CAJK=1RjJUzrpL+=t+5sXAnkYBDKpNazZCViY=PZt7qFFcN2t3g@mail.gmail.com> <CALH+fvqsn_purpNR8KHRe9GtdVizzDCbOSDTK8SMJc-8of-x8w@mail.gmail.com> <CAJK=1RjFaopyCWonU8kgkhowWzB8KXdVNQp_W+A3S7XFdz0fsg@mail.gmail.com> <e1f6f8e9-2bdb-d4e9-3a87-13869adfc8cc@codalogic.com> <CALH+fvqXZV54Rf8QX_m_vkrgoto8+5U0_wFYds7TTp45Rd8rAw@mail.gmail.com>
In-Reply-To: <CALH+fvqXZV54Rf8QX_m_vkrgoto8+5U0_wFYds7TTp45Rd8rAw@mail.gmail.com>
From: Ulysse Carion <ulysse@segment.com>
Date: Tue, 20 Aug 2019 12:05:34 -0700
Message-ID: <CAJK=1RjYjjjT1UVtiopNM5Qg4JFgzqEHcrPXutfc6+CFiardbw@mail.gmail.com>
To: Richard Gibson <richard.gibson@gmail.com>
Cc: Pete Cordell <petejson@codalogic.com>, Carsten Bormann <cabo@tzi.org>, JSON WG <json@ietf.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/zBzKos7oIumWodGxMyPTg7YkWhM>
Subject: Re: [Json] JSON Schema Language: extensibility and unspecified properties
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/json/>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 20 Aug 2019 19:05:50 -0000

> IMO, the schema should be about representing what the protocol needs
> rather than how it is represented on a target machine.

This is a reasonable stance. But I don't think it's what I'm trying to
solve for. My focus has continually been on code generation from
schemas; the spec's expressive power is intentionally limited
specifically to enable code generation. Optimizing for code generation
is why I *am* concerning myself with how things are represented on
target machines.

There are lots of good options for schemas languages that are focused
on being as expressive as protocols are complex -- you've written one
of these good options, Pete -- but I've been concerned with making a
schema language as inexpressive as mainstream type systems are simple.

I'm not debating whether there are ways of representing int53 in many
languages. My objection is that I would be making up a type that
doesn't exist in existing programming languages natively or
idiomatically. If someone wants to do int53 bounds checks, they can
always use the float64 type, and then do bounds checking after schema
validation. Or they can write an extension.

On Tue, Aug 20, 2019 at 7:34 AM Richard Gibson <richard.gibson@gmail.com> wrote:
>
> Exactly. binary64 is an obvious option since it is the source of the bounds, but int64 is equally capable of fulfilling the role. Just like int8 imposes constraints on a value without requiring any particular machine-local treatment or representation (which should remain irrelevant to the schema language itself), so too would int53.
>
> On Tue, Aug 20, 2019 at 7:54 AM Pete Cordell <petejson@codalogic.com> wrote:
>>
>> On 20/08/2019 04:26, Ulysse Carion wrote:
>> >> An "int53" type or other means of requiring that a JSON number have zero fractional part and magnitude no greater than 2^53.
>> >
>> > Ah -- in that case, I think it fails the other part of the criterion I
>> > put forward: having "a clear mapping to programming languages in
>> > widespread use today." In case the language is unclear, my thinking
>> > was that both (1) and (2) need to be satisfied for something to be
>> > included in the spec.
>> >
>> > At least on my view, int53's correspondence is unclear -- should it be
>> > a double/f64, or a long/int64_t, with a runtime check to make sure
>> > it's in-bounds? That's not very idiomatic. Better, in my view, to
>> > stick to uncontroversial things?
>>
>> IMO, the schema should be about representing what the protocol needs
>> rather than how it is represented on a target machine.
>>
>> An implementation may choose to store an int8 in a 32-bit integer. As
>> long as it does suitable bounds checking at the appropriate points
>> nothing outside the machine need know that it has chosen to do that.
>>
>> There may be cases where there is a need for something that is larger
>> than int32 but more inter-operable than int64. int53 satisfies that need
>> in many cases.
>>
>> Mapping it to either double/f64 or long/int64_t is a local
>> implementation choice.
>>
>> Pete.
>> --
>> ---------------------------------------------------------------------
>> Pete Cordell
>> Codalogic Ltd
>> C++ tools for C++ programmers, http://codalogic.com
>> Read & write XML in C++, http://www.xml2cpp.com
>> ---------------------------------------------------------------------