Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alex Khatskevich <avkhatskevich@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH][vshard] Check self passed to object methods
Date: Fri, 1 Jun 2018 20:24:34 +0300	[thread overview]
Message-ID: <89742575-b0ce-899f-9881-d64deac8c57c@tarantool.org> (raw)
In-Reply-To: <a1da9b35-0b34-f405-28e7-fb4eac636206@tarantool.org>

Hi.

> 1. Please, put links after --- below the commit message. Not before and
> not above your own ---.
>
ok
>
> 2. Why can not you just iterate over replicaset metatable? Your way
> requires to update this test each time a new method is added.
I thought, that it can create a lot of pain in case someone adds method 
which do not take
self attribute.
Anyway, fixed adding this helper:
-----------------------
get_object_method_names = function(object)
     local res = {}
     for name, _ in pairs(getmetatable(object).__index) do
         table.insert(res, name)
     end
     table.sort(res)
     return res
end;
-------------------------
>> +        connect_replica = function(rs, r)
>> +            assert(type(r) == "table",
>> +                   'Use replicaset:connect_replica(...) instead of ' ..
>> +                   'replicaset.connect_replica(...)')> +            
>> return replicaset_connect_to_replica(rs, r)
>
> 4. You have no checked rs. This check_self_arg is broken - you must 
> have two functions:
> check and generate checker. Now you have only generate checker that 
> you have named
> check_self_arg.
>
> In this function you do manual check_self_arg for 'r' and 'rs'. For other
> functions you do the same as now - generate checker.
Fixed this way:
             assert(type(rs) == "table" and type(r) == "table",
>
> 5. Describing a function you may omit 'this function does', 'this 
> function
> is needed to' etc. Function comment must look like a commit title:
> imperative text describing what this function shall do.
> 7. 'This function takes' must be moved to the corresponding @param.
Rewritten a little.

> 6. anguments?
> 8. modele?
> 9. You do not need extra new line after each @param.
Fixed

Here is a new version
--
-- Wrap a given function to check that self argument is passed.
-- New function returns an error in case one called a method
-- like object.func instead of object:func.
-- Returning wrapped function to a user and using raw functions inside of a
-- module improves speed.
-- This function can be used only in case the second argument is not of the
-- "table" type.
--
-- @param obj_name Name of the called object. Used only for error message
--        construction.
-- @param func_name Name of the called function. Used only for an error 
message
--        construction.
-- @param func A function which is about to be wrapped
--
-- @retval Wrapped function.
--

> 10. Why no just 'return function wrapped_func(... ' ?
Fixed

  reply	other threads:[~2018-06-01 17:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-01 12:49 [tarantool-patches] " AKhatskevich
2018-06-01 14:51 ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-01 17:24   ` Alex Khatskevich [this message]
2018-06-01 18:11   ` Vladislav Shpilevoy
2018-06-02 10:01     ` Alex Khatskevich
2018-06-03 16:56       ` Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=89742575-b0ce-899f-9881-d64deac8c57c@tarantool.org \
    --to=avkhatskevich@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='[tarantool-patches] Re: [PATCH][vshard] Check self passed to object methods' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox