> 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:
> 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:
Geez, you are right! Thank you! I spent entire day with this and didn't see the
typo...
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
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
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]
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
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.
try latest stable?
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
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
Its 1.0.2 [Linux: amd64] Compiled at 2019-10-22
doesn't compile for me.
Error: implementation of 'test.get_descriptions() [declared in test.nim(3,
6)]' expected
Run
whats your nim version?
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
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
> 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.
or with psutils module (
[https://github.com/johnscillieri/psutil-nim](https://github.com/johnscillieri/psutil-nim)
)
import psutil
echo net_if_addrs()
Run
> 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
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:
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
Thanks for the answer; I'll give that a try...
{ 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. }
[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
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".
Locked duplicate of
[https://forum.nim-lang.org/t/5795](https://forum.nim-lang.org/t/5795)
25 matches
Mail list logo