On 7 February 2016, Bram Moolenaar <[email protected]> wrote:
> 
> Patch 7.4.1285
> Problem:    Cannot measure elapsed time.
> Solution:   Add reltimefloat().
[...]

    This is useful, thank you.

    Going on a tangent: it would be nice if floating point numbers had
automatic stringification.  Example:

        :let a = 1.1
        :echo a
        1.1

        :echo ' ' . a
        E806: using Float as a String
        E15: Invalid expression: ' ' . a

    To handle that you have to go through printf():

        :echo printf(' %g', a)
         1.1

    There's also a small inconsistency between %g (and echo), and %f:

        :echo printf(' %f', a)
         1.100000

    reltimefloat() is a good illustration why all this matters, and how
doing things the old way might still be less awkward than using the new
function:

        if has('float') && exists('*reltimefloat')
            echo printf('staring for %g seconds', reltimefloat(reltime(delta)))
        endif

    Compare that to the old trick:

        echo 'staring for ' . split(reltimestr(reltime(delta)))[0] . ' seconds'

    Summary: it would be nice if floating point numbers in a string
context would be stringified to printf('%g', number).

    /lcd

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui