On 8 February 2016, Bram Moolenaar <[email protected]> wrote:
>
> Lcd wrote:
>
> > Summary: it would be nice if floating point numbers in a string
> > context would be stringified to printf('%g', number).
>
> Yes and no. There have been cases where automatic conversion causes
> unexpected behavior. I think the main one is converting a string to a
> number. We have to be careful not to add automatic conversion where
> it's not expected.
>
> Most likely it's OK when explicitly using the "." operator for string
> concatenation. Unfortunately "." is also used in floats, and in a few
> case in an unexpected way:
> echo "a" . 1.1
> a11
>
> But if we make this work:
> let a = 1.1
> echo "a" . a
> a1.1
>
> Don't we get confused?
Hmm. I think the root problem is 1.1 --> '11'. One way around it
might be to do what Perl does:
$ perl -E 'say "a".1.1'
a1.1
$ perl -E 'say "a". 1.1'
a1.1
$ perl -E 'say "a". 1 .1'
a11
$ perl -E 'say "a".1.1 .1'
a1.11
However, this is quirky at best, and even perl gets confused:
$ perl -E 'say "a".1.1.1'
a
(with perl 5.22.0).
On the other hand, there is a precedent for space being relevant in
expressions, with : in foo[... : ...].
> Anyway, I rather have things work in a sensible way than throwing error
> messages. It's going to be some work to do this right.
/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.