RFR: json patches introduced to the OpenJDK copy in JDK-8246435

Erik Helin ehelin at openjdk.java.net
Thu Jun 4 05:47:17 UTC 2020


On Wed, 3 Jun 2020 14:34:38 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

>> To me there's no deeper semantic difference between "append" and "concat". To be precise, this method do a flattening
>> append/concat, and should probably be named something like addAndFlatten to be completely unambiguous. But that kind of
>> naming did not seem to fit in with the rest of the design here.  If you insist that "concat" means "flatten while
>> adding" but "append" does not, sure, I can rename it.
>
> Ah, sorry, now I see what you mean. You want a concat(JSONArray a) instead. Well, it might be good to have, but that
> does not really solve my problem, does it? :-)

Well, if you have `append(JSONValue v)` and `concat(JSONArray a)` then code using such an API can easily have the code:

void appendOrConcat(JSONArray a, JSONValue v) {
    if (v.isArray()) {
        a.concat(v.asArray());
    } else {
        a.append(v);
    }
}

I'm fine with having `appendOrConcat` in `JSONArray` as well, but then I want it named `appendOrConcat`, not `append`.
I agree that `append` is shorter, but it is too misleading of a name IMHO for a method that really does
`appendOrConcat`.

-------------

PR: https://git.openjdk.java.net/skara/pull/636


More information about the skara-dev mailing list