octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New format() options "uppercase"|"lowercase"


From: Rik
Subject: Re: New format() options "uppercase"|"lowercase"
Date: Tue, 15 Oct 2019 09:18:45 -0700

On 10/15/2019 08:14 AM, Kai Torben Ohlhus wrote:
>
> Dear Rik,
>
> Thank you for this improvement, I just tried it out and like it =)
>
> My following examples might be caused by misunderstanding the new
> options.  In a fresh Octave session, without custom settings regarding
> the format, I get:
>
> octave:1> [FORMAT, FORMATSPACING, UPPERCASE] = format
> FORMAT = short
> FORMATSPACING = loose
> UPPERCASE = lowercase
>
> octave:2> format long e uppercase
> octave:3> [FORMAT, FORMATSPACING, UPPERCASE] = format
> FORMAT = longe
> FORMATSPACING = loose
> UPPERCASE = lowercase   % "uppercase" ignored without error/warning?
>
>
> octave:4> format long uppercase
> error: format: unrecognized option 'long uppercase'
>
> % Does the order matter?

Not order, but format accepts only one option at a time.  The syntax is
really "format FORMAT | SPACING_OPTION | UPPERCASE".  The other software
behaves similarly.  Trying "format shorte compact" throws an error.  Now,
there really isn't any need to be so restrictive about things.  I would
file an issue report about this on Savannah.  It seems that either we
should just accept multiple arguments, or we should error when multiple
arguments are present, but silence is bad.

>
>
> octave:5> format uppercase
> octave:6> [FORMAT, FORMATSPACING, UPPERCASE] = format
> FORMAT = longe
> FORMATSPACING = loose
> UPPERCASE = uppercase
>
> % Above is what I expected to obtain by both calls:
> %   format long e uppercase
> %   format uppercase long e
>
> octave:7> format
> octave:8> [FORMAT, FORMATSPACING, UPPERCASE] = format
> FORMAT = short
> FORMATSPACING = loose
> UPPERCASE = uppercase
>
> % Calling "format" without arguments and return values should reset the
> default, but isn't that "UPPERCASE = lowercase"?

To be Matlab-compatible, format with no arguments should reset the format
to "short" and the spacing to "loose".  The UPPERCASE keyword is an Octave
extension so we can choose what we want.  In my own experience, I found
that I wanted UPPERCASE to be sticky.  If I turn it on in my .octaverc I
want it to stay on for the entire session.  As an example, I would start
Octave, do a calculation, realize I wanted to see a few more significant
digits and so execute "format long; ans", and then switch back to regular
display with "format".  If UPPERCASE was not sticky then I would also have
to execute "format uppercase" again each time I switch between formats. 
But, if I'm really the only one who wants it this way we could change it.

--Rik

>
> When looking at the test cases, I think those options must be called one
> by one, right?  In this case I wished to receive errors for my stupid
> input, rather than silent ignorance.  And the resetting of the default
> state is surprising to me.
>
> Anyways this new type is a much more intuitive syntax than "longE" and
> "longe".
>
> Kai
>
>
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]