From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id B2F844696C3 for ; Tue, 21 Apr 2020 16:38:34 +0300 (MSK) Date: Tue, 21 Apr 2020 16:38:29 +0300 From: Alexander Turenko Message-ID: <20200421133829.sxxmbhxloopuhxxi@tkn_work_nb> References: <20200420005740.GV8314@tarantool.org> <20200420063840.azqawj2qep7ozpv4@tkn_work_nb> <20200420115742.GY8314@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200420115742.GY8314@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 2/2] popen: add popen Lua module List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org > > > > +static int > > > > +luaT_push_string_noxc(struct lua_State *L, char *str, size_t len) > > > > +{ > > > > + lua_pushcfunction(L, luaT_push_string_noxc_wrapper); > > > > + lua_pushlightuserdata(L, str); > > > > + lua_pushinteger(L, len); > > > > + return luaT_call(L, 2, 1); > > > > +} > > > > > > Minor: IMHO luaT_pushstring_* is more Lua-like naming. > > > > It is from past agreements too: we discussed this with Vladimir D. and > > agreed to split 'foo' and 'bar' in 'lua*_foo_bar_baz()', when there is > > 'baz'. When there is no 'baz', it is 'lua*_foobar()'. > > Are there any docs/guides/notes as a result of this discussion? Nope. > > > > + > > > > + lua_getfield(L, 2, "timeout"); > > > > + if (!lua_isnil(L, -1) && > > > > + (timeout = luaT_check_timeout(L, -1)) < 0.0) > > > > + goto usage; > > > > + lua_pop(L, 1); > > > > > > Minor: I see this passage only in two similar places, so I propose to > > > move everything to a timeout-related helper. > > > > luaT_check_timeout() is already this helper. Don't sure it worth to add > > one more wrapping level. > > I mean you can also move there all table manipulations and checks. But fail branch do a function specific logic. I don't sure here. It seems we can pass an error string to the function. However lua*_check_foo() pattern is used across tarantool (see luaL_checkibuf() for example) and timeout helper may become common sooner or later. WBR, Alexander Turenko.