Well you cannot create types at runtime.
type
VariantKind = enum
vkString
vkInt
VariantType = object
case kind: VariantKind
of vkString:
strValue: string
of vkInt:
intValue: int
proc getArg(typeNa
Updated the first post with the deadline.
Static types, by definition, have to be known at compile time, so there is not
much you can do for that.
What you **can** do is mimic what dynamic languages do and write a wrapper type
using [object
variants](https://nim-lang.org/docs/manual.html#types-object-variants). You can
see an example
Is [typeinfo](https://nim-lang.org/docs/typeinfo.html) lib that you need?
I am a novice in nim and don't know much about the type system. I went through
the documentation and found this out
> All expressions have a type which is known at compile time. Nim is statically
> typed.
Is there any way I can create typed variables at runtime? Here is what I am
trying to ach
I change lib/system/excpt.nim(362)
quit(1)
to
raise newException(SystemError, "SystemError")
and the following codes works
var a: int = 0
try:
var b: int = 5 div a
echo b
except SystemError:
echo "Exception: " &
I found lib/system/except.nim catch most signals and just print signal message
then quit. Is it possible to raise an exception instead of immediately quit?
This gives more choice to users I think.
1. C lang: passing (void *) as an parameter (typed *) seems legit for the gcc
compiler (apparently not so for g++)
2. the Nim to C backend _might_ actually consider the type of the message
variable and create the proper/compatible parameter for the C call
both work in your favor and this s