Re: Is there a default initializer that can be overloaded?

2020-01-11 Thread mashingan
> Error: overloaded 'initElement' leads to ambiguous calls You tried to overload using generic but actually proc overload usually done with argument types. When you defined generic, it's actually creating overload proc based on argument type, for example proc add[T:

Re: I wrote some nim code that works, but I don't understand how/why it works.

2020-01-11 Thread mashingan
> template/generic instantiation of + from here This means + is generic and the real operation/error is elsewhere. Error: type mismatch: got but expected one of: iterator items[T](a: seq[T]): T first type mismatch at position: 1 required type for a:

Re: Forward declaration results in SIGSEGV?

2020-01-11 Thread readysloth
Geez, you are right! Thank you! I spent entire day with this and didn't see the typo...

Re: I wrote some nim code that works, but I don't understand how/why it works.

2020-01-11 Thread spip
10 months later, MrZoraman's sample code now compiles without errors with nim 1.0.4. But I have the same strange error about type error on `items`, and like MrZoraman I don't understand how it can happen. I have 2 modules, `bb.nim` and `cc.nim` that imports `bb.nim`. When compiling `cc.nim`, I

Re: How to create and manage a http users sessions?

2020-01-11 Thread mrhdias
When the code is compiled gives the following warning message: template/generic instantiation of newTable from here and Warning: Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit] How can I fix this? $ nim c -r test.nim

Re: How to create and manage a http users sessions?

2020-01-11 Thread mrhdias
Thanks, now it works. This is a prototype. I need to store the session in a cookie and check if it already exists. import asynchttpserver, asyncdispatch import tables import times import oids type Session = object map: TableRef[string, string]

Re: How to create and manage a http users sessions?

2020-01-11 Thread enthus1ast
I would create a browser cookie with a session id and also store the session id somewhere on the server (database, memory, etc) then on every request check if the transmitted session id is still in your datastore. To invalidate session keys you could register a function with asyncCheck that

Re: How to create and manage a http users sessions?

2020-01-11 Thread dom96
That code looks like it does what you intend. One thing to keep in mind is: never ever discard the result of an `async` call. You need to use `asyncCheck` already otherwise you'll be swallowing exceptions in your sessions_manager function.

Re: Forward declaration results in SIGSEGV?

2020-01-11 Thread SolitudeSF
try latest stable?

Re: Forward declaration results in SIGSEGV?

2020-01-11 Thread solo989
You never assigned result.act when act is not nil. if act == nil: result.action = () => desc Run should be if act == nil: result.action = () => desc else: result.action = act Run

How to create and manage a http users sessions?

2020-01-11 Thread mrhdias
I'm trying to create a session manager for a asyncrounous http server. I have a table with all created sessions. Each session should be deleted after a certain time if there are no user requests. The following prototype code (I don't know if it's correct) creates the sessions, but then when the

Re: Forward declaration results in SIGSEGV?

2020-01-11 Thread readysloth
Its 1.0.2 [Linux: amd64] Compiled at 2019-10-22

Re: Forward declaration results in SIGSEGV?

2020-01-11 Thread SolitudeSF
doesn't compile for me. Error: implementation of 'test.get_descriptions() [declared in test.nim(3, 6)]' expected Run whats your nim version?

Re: Is there a default initializer that can be overloaded?

2020-01-11 Thread spip
Thanks **mashigan**. If I understand correctly, the `Error: overloaded 'initElement' leads to ambiguous calls` message was created because the `initElement` proc signature in the client module in the original code was not exactly the same as the one used in the generic module. For future

Re: Goto based exception handling

2020-01-11 Thread federico3
I think we are conflating two types of exceptions: recoverable ones, that can be safely catched and enable granular error management, and fatal ones that Nim cannot handle, where the only safe option is a restart. I would argue that the second type should be exceedingly rare by default, due to

Re: Is there a default initializer that can be overloaded?

2020-01-11 Thread mashingan
> I have to provide an initElement proc in the generic module in order to > compile foo[T] (line #10). That's the reason there's a forward declaration of > initElement (line #7). I tried your code, removed the forward-declaration and fixed your initElement definition and it's working fine.

Re: Get local ip address

2020-01-11 Thread enthus1ast
or with psutils module ( [https://github.com/johnscillieri/psutil-nim](https://github.com/johnscillieri/psutil-nim) ) import psutil echo net_if_addrs() Run

Re: Is there a default initializer that can be overloaded?

2020-01-11 Thread spip
> If I understand you correctly, you wanted the client/user of the module to > provide their own initElement proc of their type, didn't you? Yes > In that case, you're able to ensure the compiler to check whether the user > provide their own initElement using compile proc. The problem is not

Forward declaration results in SIGSEGV?

2020-01-11 Thread readysloth
Hello folks. I was playing with nim around for a couple of weeks, but and now i struggle with forward declaration and later use of the function pointer. Here is minimal example: proc get_descriptions():string; type Function = object description:

missing rules in grammars.txt

2020-01-11 Thread Ogromny
Hi, I recently started to create a plugin for intellij. I did the Lexer but in [https://github.com/nim-lang/Nim/blob/27b081d1f77604ee47c886e69dbc52f53ea3741f/doc/grammar.txt](https://github.com/nim-lang/Nim/blob/27b081d1f77604ee47c886e69dbc52f53ea3741f/doc/grammar.txt), the typeDescK is

Re: Compilation error after upgrade to 1.0.2 from 0.19

2020-01-11 Thread axben
Thanks for the answer; I'll give that a try...

Re: Introducing --gc:arc

2020-01-11 Thread cblake
{ I should have said (but I am sure Araq probably knows but others may not) that `--gc:arc --exceptions:setjmp` works fine even for `--help` for `cligen` apps. So, probably a topic for another thread or a github issue if I can maybe shrink the example size. }

Re: Accessing selectors from dispatcher ? why?

2020-01-11 Thread mashingan
[getIoHandler](https://nim-lang.github.io/Nim/asyncdispatch.html#getIoHandler%2CPDispatcher) will returning IOCP Handle on Windows or [Selector[AsyncData]](https://github.com/nim-lang/Nim/blob/devel/lib/pure/asyncdispatch.nim#L1137-L1138) on Unix

Re: a survey on warnings reported by GCC

2020-01-11 Thread Araq
You don't have to "trust" anything, you can benchmark and look at the produced assembler code. Now locking this thread because I still have the "wrong attitude".

Re: selector-action

2020-01-11 Thread mratsim
Locked duplicate of [https://forum.nim-lang.org/t/5795](https://forum.nim-lang.org/t/5795)