Thursday, December 19, 2013

Re: first parsing steps : request for comments


On Dec 19, 2013 9:02 PM, "Marcin Szamotulski" <mszamot@gmail.com> wrote:
>
> On 17:37 Thu 19 Dec     , Nikolay Pavlov wrote:
> > On Dec 19, 2013 5:21 PM, "Marcin Szamotulski" <mszamot@gmail.com> wrote:
> > >
> > > On 13:23 Thu 19 Dec     , Alexandre Hoïde wrote:
> > > >   Hello,
> > > >
> > > >   Still working my way to yellow belt in the Vim Scripting Art, I come
> > > > to you with a little piece of code I wrote to later serve in a plugin
> > > > I'm trying to write (to work with GNU Gettext PO files). I would be
> > > > interrested in comments from >= yellow belt Vim Scripters to improve my
> > > > code and my skills. And I have to say, i find my 'get_line' function
> > > > ugly. ^^
> > > >
> > > >   I think (hope) the attached code is rather self-explanatory, and
> > > > there's also a small sample 'po' file on which this code is supposed to
> > > > work. This will be the plugin first step at parsing a PO file.
> > > >
> > > >   Regards,
> > >
> > > It is better to not use regular expressions when there are not really
> > > needed so I would change this line:
> > >     if a:key !~# '^\(first\|last\)$'
> > > into
> > >     if a:key != 'first' && a:key != 'last'
> >
> > Never use ==/!=/=~/!~ for string comparison. The OP is absolutely right
> > using !~# and you should change this to !=# or isnot#. Otherwise you are
> > depending on &ignorecase option value.
>
> Maybe you right, since even:
>     echo 0 == 'a'
>     1

It is the case for "is" ("0 is 'a'" returns 0), but "'a' is 'A'" is 1 if you did "set ic". I am telling about hashes.

> Best regards,
> Marcin
>
> --
> --
> You received this message from the "vim_use" 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_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: