From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id ECE53469719 for ; Mon, 5 Oct 2020 14:51:21 +0300 (MSK) Received: by mail-lf1-f65.google.com with SMTP id d24so6505610lfa.8 for ; Mon, 05 Oct 2020 04:51:21 -0700 (PDT) Date: Mon, 5 Oct 2020 14:51:18 +0300 From: Cyrill Gorcunov Message-ID: <20201005115118.GE2069@grain> References: <20201001135113.329664-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH v4 0/6] box/func: implement cfunc Lua module List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tml , Alexander Turenko On Sat, Oct 03, 2020 at 03:55:23PM +0200, Vladislav Shpilevoy wrote: > Hi! Thanks for the patchset! > > On 01.10.2020 15:51, Cyrill Gorcunov wrote: > > The cfunc module provide a way to execute C stored procedures > > on read only nodes without registring them in `_func` system space. > > > > The series implements a bare minimum. There was a request to make > > cfunc been Lua object with appropriate methods. If this is really > > preferred then I'll implement this wrapping Lua code on top. I mean > > that currently all operations are done via > > > > > require('cfunc').[create|drop|call|reload] > > > > interface while there was a proposal to operate as > > > > > a = require('cfunc').create > > > a:call(args) > > No, the proposal was rather > > cfunc = require('cfunc') > f = cfunc.load('test_box_c_function') > f(1, 2, 3) > > Sorry I didn't describe it properly anywhere. But it is easy to fix > anyway. > > In Lua you can define __call and make an object look exactly > like a function. That is the idea behind making it possible to > use Lua and C functions in the same way. > > if load_c then > f = cfunc.load('test_box_c_function') > else > f = function(a, b, c) return a + b + c end > end > f(1, 2, 3) -- Works and looks the same for C and Lua. > > With this way even IPROTO_CALL should work on such functions, if the > function object is global and the user has access to executing everything > here. OK, so here is a proposal. The module get called cbox, where we will be implementing all C related features. cbox.func.create(name) -- create a function cbox.func.drop(name) -- delete a function cbox.module.reload(name) -- reload module f = cbox.func.create(name) f(1,2,3) -- create and call a function Comments?