Paolo Bonzini <[email protected]> writes:

> Il ven 5 dic 2025, 13:16 Markus Armbruster <[email protected]> ha scritto:
>
>> > Note however that there is no support for push parsing, therefore this
>> > would not replace the balanced-parentheses machinery in
>> > qobject/json-streamer.c, and therefore QMP would still need a minimal
>> > lexer.
>>
>> That push parser...  I never liked it.  First, it's half-assed: it's a
>> push lexer wed to a pull parser with parenthesis counting.  Second, why
>> complicated & half-assed when you can do simple & quarter-assed instead?
>> We could've required "exactly one complete JSON value per line", or some
>> expression separator such as an empty line.
>
> Hmm not sure I agree, actually I think I disagree. It seems simpler but it
> is also different.

Management applications would be just fine with the different interface.

Human users would be better off.  As is, a missing right parenthesis is
met with silence.  You can then input whatever you want, and get more
silence until you somehow close the last parenthesis.  Quite confusing
unless you already know.

> Push parsing is not rocket science. It would be easy to write a proper one,
> it's just that there is no real reason other than cleanliness.

Me not liking what we have, when what we have works, is no reason to
rewrite it.

Even the lousy usability for humans doesn't justify a rewrite.

>> > Grr... I just remembered about interpolation :/ so no, we still need a
>> > parser for libqmp.c.
>>
>> Right.
>>
>> Interpolation lets us build QObjects from literal templates with
>> variable scalars or QObjects interpolated.  More concise and much easier
>> to read than the equivalend nest of constructor calls.  Drawback: chains
>> us to our own, bespoke JSON parser.
>
> And also, for similar reasons of practicality, single quotes (which IIRC
> also became valid QMP, and that's less excusable).

Single quotes should've been restricted to internal use, just like
interpolation.

> But while it's a pity, we still get a lot from serde, namely making the
> automatic generation of visitor code for structs someone else's problem.
>
>> Out of curiosity: how would we do better than "nest of constructor
>> calls" in Rust?
>
> You'd do that with a quoting macro, i.e.
>
> qobject!({"command": cmd})
>
> where the macro compiles to the nest of constructor calls, like
> QObject::from_iter([(c"command", to_qobject(cmd))]).

Thanks!


Reply via email to