Thursday, December 19, 2013

Re: first parsing steps : request for comments

On Thu, Dec 19, 2013 at 05:37:35PM +0400, Nikolay Pavlov wrote:
> On Dec 19, 2013 5:21 PM, "Marcin Szamotulski" <mszamot@gmail.com> wrote:
> >
> >
> > 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.
>
> > or
> > if index(['first', 'last'], a:key) == -1
> > which is nice if you have more items than just two, but it's maybe worth
> > to mention.

5/5 !

> > You can avoid using eval in the line:
> > let ldict = eval('self.' . a:key)
> > with:
> > let ldcit = self[a:key]

5/5… i first tried self[{a:key}] and self.{a:key}, which failed, and
for some reason i did not even think about this straightforward
version. ^^


> > I also would not store an expression in a dictionary (like 'deferred')
> > but move it to get_line to avoid using eval.

3/5. I came with this idea fighting with order of evaluation (I would
have liked to use s:po_dom_1.get_line('last') directly as 'number').
When you say "move it to get_line" you mean implementing the logic
inside get_line function ? (i.e. automatically hook up with
previous/next entry in s:sorted_domains ?)

Anyway, thanks much to both of you for your input.

Best regards,

--
 ___________________
| $ post_tenebras ↲ |       waouh !
| GNU        \ /    |      /
|          -- * --  |     o
| $ who ↲    / \    |_-- ~_|
| Alexandre Hoïde   |  _/| |
 -------------------

--
--
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:

Post a Comment