From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 5BEBD70361; Wed, 10 Feb 2021 15:38:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5BEBD70361 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612960732; bh=EzXlZpUM253pX7DPsM0J/qiBofdxNZXCpg+1gHm/+k0=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gwsBs9XK+plf9x6eI6HXw/040tfrixC+TEHagU0tpTqg/jsRCG841J9PpW+ZD4E+A rQZ5CSZhddITrZRFl+w9IhAerIxW/HNOoQqGKNeaKh7Om/oUGv4swghEbKm/BXmomq dyRrZC+M2BiU0LaCD9QZHd87UewLDWdRAy1ZPTjo= Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 0920B70361 for ; Wed, 10 Feb 2021 15:38:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0920B70361 Received: by mail-lf1-f53.google.com with SMTP id v30so2273386lfq.6 for ; Wed, 10 Feb 2021 04:38:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bDcG6PeLZ0/CxIPJDqNgs6q8qq//UptsUfZKImd9Yo4=; b=OmLuN982In2Nj1qhKkKsQPTOsLwpPltt1r8IindQ74ZrwSm/msJX2o7z7zlELd8DXR H8LV1xql1S3U0XzRowS1hPj1znPcOnS41PWVWZp203HRGe5WnR1XwrgkSrnlXe2XNZ/R TsmJTq7aaKS1uxdSyWfvysOlZDmnwqD/ccE9MZkuKJLqVzBszghhLO1Hofr/jXQcN8yU S3hWlM+LDPBInYIeiN2H75NAfWEDW6iK1BSx82EClAiLhSoGxV+N7OsJn2LVThqLTrLE 32slQdI99lC5MwmBIZYX5ydqOorKNnIib1xlTLACzJgm5FJaBHikyMfhX9O51NLTMZWb BYNA== X-Gm-Message-State: AOAM533Z+qzxH0/7k3+nHyX06yRba6eoQiiQHKtpU7GbT+n/oTFCGAmK QQIILRBfTm3Q1YL1vgmhsMy+Q4itRVs= X-Google-Smtp-Source: ABdhPJw8JDzGTBqa091kpF8Q88Vnx8BHYkBrAVkz2htzBE5dmc1y5dTUibq4kZb7GqB8mnd8QpDbDQ== X-Received: by 2002:a05:6512:3481:: with SMTP id v1mr1674192lfr.333.1612960729927; Wed, 10 Feb 2021 04:38:49 -0800 (PST) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id k22sm463562ljk.90.2021.02.10.04.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 04:38:48 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 13F34560099; Wed, 10 Feb 2021 15:38:48 +0300 (MSK) Date: Wed, 10 Feb 2021 15:38:47 +0300 To: tml Message-ID: References: <20210210122448.66941-1-gorcunov@gmail.com> <20210210122448.66941-2-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210210122448.66941-2-gorcunov@gmail.com> User-Agent: Mutt/2.0.5 (2021-01-21) Subject: Re: [Tarantool-patches] [PATCH v17 1/2] box/cmod: implement cmod Lua module X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Wed, Feb 10, 2021 at 03:24:47PM +0300, Cyrill Gorcunov wrote: > > Once successfully loaded we can execute it. Note that unlike regular > Lua functions the context of `C` functions is different. They never > thrown an exception but return `true|nil, res` form where first value > set to `nil` in case of error condition and `res` carries an error > description. > > Lets call the `cfunc_sum` with wrong number of arguments Typo left in description. I force pushed an update (we always throw an exception. --- First we should load it as ``` Lua m = require('cmod').load('cfunc') cfunc_sum = m:load('cfunc_sum') ``` Once successfully loaded we can execute it. Lets call the `cfunc_sum` with wrong number of arguments ``` Lua cfunc_sum() | --- | - error: invalid argument count ``` We will see the `"invalid argument count"` message in output. The error message has been set by the `box_error_set` in `C` code above. On success the sum of arguments will be printed out. ``` Lua cfunc_sum(1, 2) | --- | - 3 ```