Loading ...
Sorry, an error occurred while loading the content.

50457Re: Floating point syntax

Expand Messages
  • Ilya Bobir
    Jun 4, 2008
    • 0 Attachment
      Bram Moolenaar wrote:
      > [...]
      >> The second was a proposal to represent floats as numbers with decimal
      >> points but no additional punctuation which was implicit in this report
      >> from Ilya Bobir:
      >> - I did a search for vim scripts that use concatenation operation
      >> between two numbers without interleaving space. It appears that
      >> Google Code Search was able to find only 39 matches and all were
      >> false positives.
      >> Nobody gave any reply to the message.
      > I wonder how you do that search.
      I've explained how I did the search in my email on that thread.
      Probably you missed it, so I include this email here. Here it goes:

      Ilya Bobir wrote:
      > Bram Moolenaar wrote:
      >> [...]
      >> I would still like feedback on the format of floating point numbers:
      >> &123.456
      >> &1.23e-3
      > I did a search for vim scripts that use concatenation operation between two
      > numbers without interleaving space. It appears that Google Code Search was
      > able to find only 39 matches and all where false positives.
      > Here is the query:
      > http://www.google.com/codesearch?hl=ru&q=+lang:vim+%5E%5Cs*%5B%5E%22%5C+%5D(%22(%5C%5C.%7C%5B%5E%22%5D)*%22%7C%27%5B%5E%27%5D*%27%7C%5B%5E%22%5D)*%5Cs%5Cd%2B%5C.%5Cd%2B%5Cs+-menu&start=30&sa=N
      > And here is a regex I've used (along with explanations). Maybe someone will
      > double check to make sure I did not mistake.
      > lang:vim | Vim script language.
      > ^\s*[^"\ ] | In order to exclude comments the line should
      > | start with anything but ".
      > ( | Catches different kind of strings.
      > " ( \\. | [^"] )* " | Double quoted strings along with escapes
      > | inside the string.
      > | ' [^']* ' | Single quoted strings.
      > | [^"] | All the rest is OK. And there maybe some
      > | staff preceding the digits.
      > )* |
      > \s\d+\.\d+\s | A pattern that I was looking for - two numbers
      > | concatenated without an interleaving space
      > | that are not part of a longer sequence.
      > -menu | menu command uses dot separated numbers to set
      > | priority. There are plenty of them and all
      > | are false positives, so remove all lines with
      > | "menu" string in them.

      If something is hard to understand, please ask, I'll try to explain
      another way. English is not my native language and sometimes I really
      have no clue whether what I write is understandable at all =)

      > And if you manage to come up with the
      > right pattern, what the number of matches actually means.

      The number of matches is the number of lines that have two numbers
      concatenated without interleaving spaces. A real match would mean that
      adding a "common" syntax for floats into Vim script would break a script
      with the match.
      It appeared that all 39 matches was false positives meaning that all of
      them was really something else and was matched only because the pattern
      I've used it not perfect. I checked all 39 matches by hand. You can
      easily see them by following a link in my original e-mail that I've
      quoted above.
      To sum it up, it appears that among all the vim scripts that are indexed
      by Google there are none that use the "common" float syntax to
      concatenate two numbers. This means using the "common" syntax for
      floats will not break any of these scripts.
      There still is a chance that some scripts use dynamically generated
      expressions that have two numbers concatenated without interleaving
      spaces but it is unlikely as one does not need a concatenation operation
      to concatenate numbers when building a dynamic expression - you can just
      put them in the result side by side.

      > Ben Schmidt wrote:
      >> I would like to note, though, that this doesn't solve the problem for
      >> exponent notation. However, I suspect a search of vim scripts containing
      >> numbers of that form would yield even less results, though I have not
      >> tried it. The search also doesn't take into account expressions that may
      >> be built dynamically in vim scripts rather than being hard coded, but
      >> again, I doubt many if any of these exist.

      If there are no scripts that use two numbers with a dot in between
      without interleaving spaces then it follows that there are none that
      have these kind of numbers with an exponent appended. And it means that
      if the float syntax will be smart enough to tell a float without an
      exponent from a concatenation then adding an exponent as a suffix will
      not introduce any ambiguity. Am I missing something?

      Ilya Bobir

      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 15 messages in this topic