Re: How to raise an exception from a template?

2020-04-05 Thread Hlaaftana
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

Re: How to raise an exception from a template?

2020-04-05 Thread jyapayne
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

Re: How to raise an exception from a template?

2020-04-05 Thread spip
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

Re: How to write shell scripts in Nim

2020-04-05 Thread kaushalmodi
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.

How to raise an exception from a template?

2020-04-05 Thread spip
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 =

Re: Destructor not called for ref object

2020-04-05 Thread lscrd
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.

Re: How to write shell scripts in Nim

2020-04-05 Thread blueray
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.

Re: How to write shell scripts in Nim

2020-04-05 Thread SolitudeSF
https://nim-lang.github.io/Nim/nimscript.html

Re: Destructor not called for ref object

2020-04-05 Thread Sixte
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 ?

Re: Having problems with concepts that won't finish compiling

2020-04-05 Thread Araq
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.

Re: How to write shell scripts in Nim

2020-04-05 Thread blueray
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

Re: jester params

2020-04-05 Thread decigs
using wrk benchmark wrk http://localhost:5000 wrk http://localhost:5000/param

Re: How to write shell scripts in Nim

2020-04-05 Thread Vindaar
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)

Re: jester params

2020-04-05 Thread decigs
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

How to write shell scripts in Nim

2020-04-05 Thread blueray
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

Re: jester params

2020-04-05 Thread geotre
Probably best to open an issue on github ( [https://github.com/dom96/jester](https://github.com/dom96/jester)/ ) with an example

Having problems with concepts that won't finish compiling

2020-04-05 Thread hugogranstrom
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

jester params

2020-04-05 Thread decigs
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

Re: Destructor not called for ref object

2020-04-05 Thread lscrd
Note that I have been able to get the right result by compiling your example with `--gc:arc`.

Re: WebRTC support πŸ‘‘

2020-04-05 Thread enthus1ast
in the browser via js. Natively i'm not aware of any ready to use libraries for webrtc. There is status-im/libp2p, though.

Re: Call for testing of arm64, armhf, and i386 snaps of Nim

2020-04-05 Thread adnan
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

Re: Destructor not called for ref object

2020-04-05 Thread juando
Thanks. I will. I didn't know whether it was an issue or me doing something wrong.

Re: Destructor not called for ref object

2020-04-05 Thread Araq
Please report issues on github.

WebRTC support πŸ‘‘

2020-04-05 Thread BeepBooper
Any suggestions about WebRTC support in Nim?