Re: libXO-ification - Why - and is it a symptom of deeper issues?

From: Allan Jude <allanjude_at_freebsd.org>
Date: Sun, 15 Nov 2015 13:14:57 -0500
On 2015-11-15 13:10, Garrett Cooper wrote:
> 
>> On Nov 15, 2015, at 10:05, Allan Jude <allanjude_at_freebsd.org> wrote:
>>
>>> On 2015-11-15 07:54, Dan Partelly wrote:
>>>
>>> Hi all,
>>>
>>> I was looking at the new facility of dumping JSON,XML from many utils in base and after some funny minutes, I couldn't stop ask myself g Ok, this is funny , but why ? g And I couldn't find a real answer. Ill outline what I think:
>>>
>>>
>>> 1. Undoubtedly, it makes base code slightly harder to understand and maintain.
>>
>> I am not sure that libxo actually makes the code any harder to
>> understand and maintain. It might actually make it slightly better.
>>
>> replacing:
>>
>> printf("%s %s %d\n", foo, bar, number);
>>
>> with:
>>
>> xo_emit("{:foo/%s} {:bar/%s} {:number/%d}", foo, bar, number);
>>
>> it not really hurting much.
> 
> That's by and large true, but there are other APIs that need to be called on exit (xo_finish?) and in other scenarios where flushing, etc is needed. If you don't do that, you don't get the output you expect (which broke uptime/w several months ago..).

You can setup an atexit() call to call xo_finish automatically when the
program exits. The original changes to uptime had a few other issues,
which I fixed.

> 
> Also, typos with the meta language into the xo_emit calls have bit is more than once ;(.
> 

Yes, but, a typo in any change is likely to cause a problem. This is not
a problem unique to libxo.

-- 
Allan Jude


Received on Sun Nov 15 2015 - 17:14:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:01 UTC