On 12/04/08 19:57, Steve Hall wrote:
> On Sat, 2008-04-12 at 16:58 +0200, Bram Moolenaar wrote:
>> I would still like feedback on the format of floating point numbers:
>>
>>    &123.456
>>    &1.23e-3
>
> I don't understand the ampersand, why not something more mnemonic:
>
>      f123.456
>      .123.456
>      f.123.456
>      .f123.456
>      +123.456
>
>

The way I see it, it's to both avoid ambiguity and avoid breaking 
compatibility:

1) f123.456 is the variable f123 concatenated with the constant 456

2) .123.456 is just as arbitrary as &123.456, and maybe more ambiguous 
depending what comes before. Example:

        :echo foobar .123.456

doesn't mean "echo the variable foobar separated by a space from the 
number one hundred twenty-three point four five six" but "echo the 
variable foobar concatenated with the strings '123' and '456' (with no 
spaces since it is just one expression).

3) f.123.456 is the variable f concatenated with two strings - it 
amounts to f concatenated with the string '123456'

4) .f123.456 (see 2); if preceded by a string it would concatenate the 
variable f123 and the string 456 to it

5) +123.456 applies the concatenation operator to two numbers so both 
are converted to strings and we end up with 123456 (the string '123456', 
that is).

OTOH, with & there is no ambiguity because the various uses of & are 
strictly separated:

&& is the "and" logical operator. Vim (unlike C etc.) has no bitwise 
operator. The use of & in 'nomagic' patterns applies only in a strictly 
delimited context.

&option (where the option name always starts with a letter) is an option 
used as a variable, in the LHS of the ":let" command or as all or part 
of an expression.

&number (where the number always starts with + - or a digit) is a 
floating-point literal.


Best regards,
Tony.
-- 
ARTHUR:   Ni!
BEDEVERE: Nu!
ARTHUR:   No.  Ni!  More like this. "Ni"!
BEDEVERE: Ni, ni, ni!
                  "Monty Python and the Holy Grail" PYTHON (MONTY) 
PICTURES LTD

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui