Checked addition generated from tools/dsl/decls.json.
The native wrapper decodes the terms and calls checked_add in
native/examples/arith_user.mojo. This module does not declare the NIF entry.
Summary
Functions
Adds a and b as signed 64-bit integers.
Both arguments are required integers. There is no optional argument.
Returns
{:ok, sum}when the sum fits{:error, :overflow}when it does not
Raises
ArgumentErrorwhenaorbis not an integer in signed 64 bits
Examples
iex> Mojoler.Dsl.Arith.add(20, 22)
{:ok, 42}
iex> Mojoler.Dsl.Arith.add(9_223_372_036_854_775_807, 1)
{:error, :overflow}
iex> Mojoler.Dsl.Arith.add(1, :nope)
** (ArgumentError) argument error
@spec load_nif() :: :ok | {:error, term()}
Loads priv/native/libdsl_arith.so.
A second call returns {:error, {:reload, charlist}}.
Examples
iex> Mojoler.Dsl.Arith.load_nif()
{:error, {:reload, ~c"NIF library already loaded (reload disallowed since OTP 20)."}}