On 8 February 2016, Nikolay Aleksandrovich Pavlov <[email protected]> wrote:
> 2016-02-08 21:06 GMT+03:00 LCD 47 <[email protected]>:
> > On 8 February 2016, Bram Moolenaar <[email protected]> wrote:
> >> 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
> >
> > Well, philosophically, I'd say literal numbers should never be
> > promoted to strings, that is:
> >
> > let a = "header: "
> > let b = 1
> > echo a . b --> header: 1
> > echo a . 1 --> error
> >
> > a . 1 looks like an accidental feature, and using it on purpose
> > certainly feels like bad style. However, making it an error would be
> > hard to document, let alone justify, and that would be much worse than
> > the current behaviour.
>
> I would say that both examples should be an error or should not be it.
> The fact that I can use `{string expr} . {number expr}` only in case
> when `{number expression}` is not a number looks like a bad design or
> even error in parser.
Hence why I said it would actually be worse than the current
behaviour. Bram's suggestion seems to be the most balanced trade-off.
> Though you may find this problem in lua:
>
> print("%s":format("test")) -- error
> print(("%s"):format("test")) -- prints test
> local str = "%s"
> print(str:format("test")) -- prints test
>
> I have no idea why they have to have this kind of nonsense (also
> applies to tables, now including the case when you do indexing), but
> neither Python, nor Vim, nor Perl, nor even C99 has same behaviour:
>
> echo $'#include <stdio.h>\nint main(void){printf("%d", (struct
> {int a, b;}) {0, 0}.a);}' | clang -pedantic -Weverything -std=c99 -xc
> -
>
> works fine with no warnings (also with gcc, but replace -Weverything
> with -Wall and note that number of enabled warnings will drop in this
> case), `"str"[0]` works also.
>
> In the mentioned languages if you can have expression of some type in
> some position then this expression can be as well literal.
[...]
/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.