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'.
Yes, we didn't have floats until recently, before that "." in any
position meant string concatenation.
> 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[... : ...].
There is a balance between being backwards compatible and doing what is
expected. Spaces can be relevant, but that doesn't help for backwards
compatibility.
One thing to keep in mind, why would you ever write:
"a" . 1.1
If you can write:
"a11"
Or:
"a1.1"
This does not seem not so important. What is relevant:
let a = "header: "
echo a . 1.1
I assume most of us are surprised that the result is:
header: 11
Perhaps we should just change that and see who complains?
--
hundred-and-one symptoms of being an internet addict:
181. You make up words that go with the "happy tune" your modem makes
while dialing your ISP.
/// 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.