[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: format compact and loose
From: |
Ben Abbott |
Subject: |
Re: format compact and loose |
Date: |
Thu, 08 Sep 2011 07:45:25 -0400 |
On Sep 7, 2011, at 8:57 PM, Jordi Gutiérrez Hermoso wrote:
> 2011/9/6 John W. Eaton <address@hidden>:
>> On 6-Sep-2011, Jordi Gutiérrez Hermoso wrote:
>
>> | Also, for anyone checking my C++: I made the compact_format
>> | variable visible in two more TUs besides its original
>> | pr-output.cc. Yes! A global variable! ;-) But I think it's ok to
>> | pollute the global namespace a little here.
>>
>> I'd rather avoid the global if possible.
>
> I tried to avoid it, but it involved changing the API for several
> classes derived from octave_base_value. The changes cascaded far, and
> in the end, I still made several mistakes that gave runtime errors. I
> decided against it finally because all ini all the compact_format
> state is really global state anyways, so why not use a global variable
> for global state?
>
>> If it is necessary to make compact_format global, then please
>> declare it in pr-output.h instead of adding individual extern
>> declarations in multiple places.
>>
>> Though we are not editing ChangeLog files directly, the preferred
>> format still has some merit,
>
> That's what I ended up doing:
>
> http://hg.savannah.gnu.org/hgweb/octave/rev/969ed305dde5
>
> It now appears that "format compact" produces output without blank
> lines, as requested by Zbigniew.
>
> I hope I wasn't too rash to push this change. But it seems to work for
> me.
>
> - Jordi G. H.
Jordi,
I'm out of my comfort zone, but I had a thought that may be useful ... or just
noise.
For testing, I'd planned to do something like ...
format loose
x = rand (3, 3, 3);
loose = disp (x);
format compact
compact = disp (x);
assert (strrep (disp (loose), "\n\n", "\n"), compact)
Might there be a specific place in the code where a single if-block could be
placed to convert from loose to compact format? I don't know how to convert
"os" on the c++ side, but I'm thinking of an equivalent to ...
if (compact_format)
output = strrep (output, "\n\n", "\n");
endif
Ben
Re: format compact and loose, Zbigniew Komarnicki, 2011/09/07