Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tml <tarantool-patches@dev.tarantool.org>
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v17 1/2] box/cmod: implement cmod Lua module
Date: Wed, 10 Feb 2021 15:38:47 +0300	[thread overview]
Message-ID: <YCPT16WoU3lufDIa@grain> (raw)
In-Reply-To: <20210210122448.66941-2-gorcunov@gmail.com>

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


  reply	other threads:[~2021-02-10 12:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 12:24 [Tarantool-patches] [PATCH v17 0/2] box: " Cyrill Gorcunov via Tarantool-patches
2021-02-10 12:24 ` [Tarantool-patches] [PATCH v17 1/2] box/cmod: " Cyrill Gorcunov via Tarantool-patches
2021-02-10 12:38   ` Cyrill Gorcunov via Tarantool-patches [this message]
2021-02-10 12:24 ` [Tarantool-patches] [PATCH v17 2/2] test: box/cfunc -- add cmod test Cyrill Gorcunov via Tarantool-patches

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=YCPT16WoU3lufDIa@grain \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v17 1/2] box/cmod: implement cmod Lua module' \
    /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