Other option, with compile time errors:
import macros
template final_sort2(v: bool): int = 3
macro final_sort2(v: typed): int =
error("Incompatible type: " & repr(getTypeInst(v)), v)
echo final_sort2(true)
echo final_sort2("hi") # Error: Incompatib
You should also be able to do
template final_sort2(v: typed) =
raise newException(Exception, "Incompatible type: " & $v)
Run
Because type overloading does not include return types
Replying myself to my question.
Even if the flow of control is supposed to stop because of the exception, as
the template is declared to return a typedesc, the last instruction **must** be
a typedesc else the compiler prints another error... So to get the expected
behaviour, the correct last te
I have a bit involved NimScript:
[https://github.com/kaushalmodi/nim_config/blob/master/config.nims](https://github.com/kaushalmodi/nim_config/blob/master/config.nims)
See if going through it and referring to docs helps you.
I'm using Nim type system and templates to build a table of allowed types in a
DSL language, like the following:
template final_sort2(v: bool): typedesc =
AST_bool
template final_sort2(v: int): typedesc =
AST_int
...
template final_sort2(v: typed): typedesc =
As far as I know, the default has not changed in 1.2. Itβs better as some
programs will not work with `--gc:arc` without changes (if you have created
cycles). I suppose the default is likely to change with 2.0.
I looked at the documentation. It is too hard for me to decode. I googled for
nimscript tutorial. Yielded nothing. That is why I am here just to have a head
start. Hopefully this spoon feeding will nourish us to become pro someday.
https://nim-lang.github.io/Nim/nimscript.html
Honestly I supposed that --gc:arc is the new default gc for Nim 1.2. I'm
surprised a bit. So, what is the default gc for Nim 1.2 ?
Report bugs on github please. Having said that, I think your solution without
concepts is fine and all you need to do is to use `method` rather `proc` to get
dynamic dispatch.
I use Linux. So, will the file extension be a factor here?
I have few more questions:
How do we take arguments?
How do we read stdin?
How do we write to stdout?
How do we pipe?
How do we use Linux commands like pwd / ls / cd / sed / grep etc inside the
script?
Will '#!/usr/bin/env nim' take
using wrk benchmark
wrk http://localhost:5000
wrk http://localhost:5000/param
Aside from putting that shebang line at the top of the file you want to run as
a script, the file has to be saved as a NimScript file, namely use a .nims file
ending.
someScript.nims
#!/usr/bin/env nim
echo "Hello from NimScript!"
echo defined(NimScript)
i mean somthing like compiled with d:release : import jester
routes :
get "/@id":
> let val = @let val = "id" resp "hi
get Requests/sec: 16536.58
> * * *
>
> import jester
routes :
get "/":
resp "hi"
get Requests/sec: 40102.21
I am looking for a bash alternative to write scripts. I came to know that Nim
can do this.
[https://github.com/nim-lang/Nim/issues/3301](https://github.com/nim-lang/Nim/issues/3301)
says:
#!/usr/bin/env nim should work now.
I went through Nimscript page, and also some documentations. I could n
Probably best to open an issue on github (
[https://github.com/dom96/jester](https://github.com/dom96/jester)/ ) with an
example
I'm trying to make a generic Spline type for my splines in NumericalNim and the
behavior I want is that all splines should have a eval proc acting on a single
float. What I then wanted was to just write one proc that works for all splines
that instead act on a seq[float] and uses the individual
hi, i am new here
weird behaviour from jester params are very slow is even slow than database
query i mean somtheing like @ " param" . any solution to that
Note that I have been able to get the right result by compiling your example
with `--gc:arc`.
in the browser via js. Natively i'm not aware of any ready to use libraries for
webrtc. There is status-im/libp2p, though.
u9898287@pop-os:~/proj/nimbed$ cat nim.nim
echo "hello world"
u9898287@pop-os:~/proj/nimbed$ nim c -r nim.nim
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: nim [Processing]
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: nim.n
Thanks. I will. I didn't know whether it was an issue or me doing something
wrong.
Please report issues on github.
Any suggestions about WebRTC support in Nim?
24 matches
Mail list logo