Re: [Json] JSON Schema Language: int53

Ulysse Carion <ulysse@segment.com> Sat, 24 August 2019 18:34 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 910F812006E for <json@ietfa.amsl.com>; Sat, 24 Aug 2019 11:34:59 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2
X-Spam-Level:
X-Spam-Status: No, score=-2 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] 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 I0NctLgREVK5 for <json@ietfa.amsl.com>; Sat, 24 Aug 2019 11:34:57 -0700 (PDT)
Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 7D3E0120020 for <json@ietf.org>; Sat, 24 Aug 2019 11:34:57 -0700 (PDT)
Received: by mail-io1-xd31.google.com with SMTP id j4so19464436iog.11 for <json@ietf.org>; Sat, 24 Aug 2019 11:34:57 -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=4K1S5uX3YWG6hKVjISaY6GhM5RY3AZL9caS8/B5+O+U=; b=E705uqiP6tn5h5Pxy6ULy6I/z223X6wncd7rHpOQRulT7G68xrdwMWOm0LblOSqmKx xKg1BzUq3m3zdIkq21x3Vp+wYz6lhdmBqe6mMBbES0KM7OrSavJiH2e6vPwZh6VAZR7A XGtRW8oLyRuXGQvmPPt9ted+/2IbJl2tGS0w8=
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=4K1S5uX3YWG6hKVjISaY6GhM5RY3AZL9caS8/B5+O+U=; b=bLWoVupnTcbuCRnv4AT4K3FCM9bzO23V7B/SD1CLP7Fz6R+DFpCvg4HEpU5NhajV31 m9NvwBCKnEpBxdhQToODzVkF8Hmp4fT7vJwdd0ki+HwhFlwcvIS++QsLS9YUjHl8eJMV lAEi3cq8m2OgdCZx4j3aRN4at3Vb+p6arfySo3lZDoLSUODJSIQdi/gmJgzf/atUYAi4 7erj61+OJOIOPGCh7cvF8Xb7Of9JmjQWrvzoq8enz7GpLBOvtjzquK4/YbZLFrSD0/e2 Nb4MnkBwLOmUZ7lHCwkLjZAlQ1ztoIY4Nr4A05xKyF9/zVIt6zRzjBiYKHRgBgXB+MGV gPmA==
X-Gm-Message-State: APjAAAXeANH+NHxFuUI+L5eiAHc18peNHH48CmFlfwFeXcfFGwiJQlR5 czOweF/XraUJtkDbM1yjtqKOMGow7BmUDENs1YSmrVFBK48=
X-Google-Smtp-Source: APXvYqxA5pW8LOtjZm8QXJjPQfvecHKqwc4GZgxdWS7Hz5XpzwGeyyl5JPEUi+02nzF4L11Wi3dbT4hXjZZ7H53z+h4=
X-Received: by 2002:a02:a518:: with SMTP id e24mr10623899jam.44.1566671696410; Sat, 24 Aug 2019 11:34:56 -0700 (PDT)
MIME-Version: 1.0
References: <SY2PR01MB2764698C2B0DE6811B9FDAFBE5AA0@SY2PR01MB2764.ausprd01.prod.outlook.com> <CAJK=1RiDf6SpWEad4w05ihHCAXviprzS_EXTv+aGmCWpkkoRGg@mail.gmail.com> <E1702435-9D6F-484F-B291-F5CFCDC343B1@tzi.org>
In-Reply-To: <E1702435-9D6F-484F-B291-F5CFCDC343B1@tzi.org>
From: Ulysse Carion <ulysse@segment.com>
Date: Sat, 24 Aug 2019 11:34:45 -0700
Message-ID: <CAJK=1RhSKQtOL9zpw8v6GP-4x2Rit1-vcnkK3SPJMAxfcwLrbA@mail.gmail.com>
To: Carsten Bormann <cabo@tzi.org>
Cc: "Manger, James" <James.H.Manger@team.telstra.com>, 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/s0KwxhVMsup2ziOUBPfXYcx0KYk>
Subject: Re: [Json] JSON Schema Language: int53
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: Sat, 24 Aug 2019 18:35:00 -0000

> I’m not quite sure what “implementing a pseudo-type” means, but is that hard?

Not hard. It means creating some sort of type/struct/class that has
ToLong/FromLong as methods, and at runtime checks that the values are
in range.

The problem with this approach (I've tried it, briefly) is that for
real-world code that means you end up needing to jump through these
ToLong/FromLong hoops in order to get work done. If added, this would
be the only such inconvenient hoop to jump through. The fact that
there's this hoop to jump through also reduces the strength of James's
point -- that without int53, you would never codegen "long" from
schemas. In fact, even with int53, you still don't generate "long",
you generate a type that's similar but inconveniently different from
it.

Or, as James suggests, you can generate "long" and not worry about
doing bounds checks. But then you lose the property that if you
generate some datatype X from a schema S, that all instances of X,
when serialized as JSON, satisfy S.

> Now you are in the prescriptive area — you no longer describe JSON formats, but you impose your own rules on what these data formats can be.  Not so good.

I agree. I mentioned this only to clarify what I felt was a better
approach for reconciling our desire for int64_t with the realities of
I-JSON. There is no good way to have something that produces int64_t
in the spec, in my view (gRPC inherited int64 from Protobuf, and
that's why they were forced to be prescriptive). Better to be
unopinionated, and have people implement int53 themselves on top of {
"type": "float64" }. I'd prefer to miss a feature than to include a
wart.

I think that a lot of this conversation might be clarified if I just
publish an I-D with what I have so far. Expect another thread soon.

P.S.: I recognize your point about the type perhaps being better named
"int54", Carsten. For the sake of continuity of conversation, I here
used the "misnomer". Happy to change what we're calling it, as long as
it doesn't confuse anyone.

On Thu, Aug 22, 2019 at 10:02 PM Carsten Bormann <cabo@tzi.org> wrote:
>
> On Aug 22, 2019, at 23:54, Ulysse Carion <ulysse@segment.com> wrote:
> >
> >> If you omit int53, then your code generation will never create a long despite this being a widely available & useful type.
> >
> > The issue, in my view, is that int64/uint64 is the widely-available
> > and useful type. Not int53. To support int53 would require that code
> > generators implement this psuedo-type at runtime.
>
> I’m not quite sure what “implementing a pseudo-type” means, but is that hard?
>
> > Consider that gRPC, which has a canonical representation in JSON and
> > which also has int64/uint64, unconditionally renders these types as
> > strings. I feel that this approach is more reasonable, as it removes
> > the footgun of a datatype that most users will assume is equivalent to
> > the familiar int64, but is not.
>
> Now you are in the prescriptive area — you no longer describe JSON formats, but you impose your own rules on what these data formats can be.  Not so good.
>
> Grüße, Carsten
>