Ozaki Kiichi wrote:

> I propose new conversion specifier '%v' (and '%V') of printf();
> inspired by golang.
> 
> This spec takes a value of any type and converts into string by echo_string().
> 
> example:
> 
> " list
> :echo printf('%v', [0, 1, 2, 3])
> [0, 1, 2, 3]
> 
> " dict
> :echo printf('%v', {'str' : 'abcdef', 'num' : 123, 'pt' : function('printf', 
> ['%%'])})
> {'str': 'abcdef', 'num': 123, 'pt': function('printf', ['%%'])}
> 
> " funcref
> :echo printf('%v', function('str2nr'))
> str2nr
> 
> 
> '%V' is simular with '%S'.
> 
> patch:
> 
> https://gist.github.com/ichizok/c1ad7759d7a0a0734fb02f5a4d37445c


So, the same would be done with using "%s" and string() on the value?

   :echo printf('%s', string([0, 1, 2, 3]))
   [0, 1, 2, 3]

I suppose golang doesn't have a string() function.

An even simpler way is to do what Swift does:

        "lead \(expression) tail"

With the example above:
        "\([0, 1, 2, 3])"

I'm using this in Zimbu, works quite well.

-- 
Q: How does a UNIX Guru pick up a girl?
A: look; grep; which; eval; nice; uname; talk; date;

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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