Sorry, but your second example is no more valid than the first one.
In both cases, as @Hlaaftana said, you need to declare the proc before
referencing it.
Hello,
Flask seems to be a popular python web framework. I was wondering if there was
something similar for nim. I know of jester and rosenkrantz, but I am looking
for something a bit more "batteries included".
Anyone working on anything like this?
You can forward declare procs to reference them before they are defined.
type
Something = object
act*: proc()
name*: string
proc someaction*()
var something = Something(act: someaction)
proc someaction*() =
something.name = "boo"
Looks like you need the `all` function from `asyncfutures` module
[https://nim-lang.org/docs/asyncfutures.html#all%2Cvarargs%5BFuture%5BT%5D%5D](https://nim-lang.org/docs/asyncfutures.html#all%2Cvarargs%5BFuture%5BT%5D%5D)
Until when can we procrastinate with talk submissions?
I am basically looking for Nim's alternative to Go's `WaitGroup`
package main
import (
"fmt"
"sync"
"time"
)
func main() {
messages := make(chan int)
var wg sync.WaitGroup
// you can also add these one at
Here it is:
[https://github.com/ingchips/ING918XX_SDK_SOURCE/blob/master/examples-nim/smart_home_hub/src/panicoverride.nim](https://github.com/ingchips/ING918XX_SDK_SOURCE/blob/master/examples-nim/smart_home_hub/src/panicoverride.nim)
I can't test it at present. Even through, why 1.0.x is OK?
https://github.com/planety/prologue
In my code I kept making calls to async functions that return future types from
inside a loop. How can I prevent the main thread from finishing before all of
those futures to finish? Note that it's inside a loop that creates are multiple
futures that need finishing.
proc main()
## INVALID
type
Something = object
act* : proc()
name*: string
var something = Something(.act : someaction)
proc someaction*()=
something.name = "boo"
Run
## VALID
type
Something = object
act* :
@jxy I've used deallocHeap in the past:
deallocHeap(runFinalizers = true, allowGcAfterwards = false)
Run
Nim is a state of the art programming language well suited for systems and
application programming
Its clean Python like syntax makes programming easy and fun for beginners,
without applying any restrictions to experienced systems programmers.
Nim combines successful concepts from mature
No, it does not work for me with your `panicoverride.nim`.
nim -v
Nim Compiler Version 1.2.0 [Windows: amd64]
Compiled at 2020-04-03
Copyright (c) 2006-2020 by Andreas Rumpf
git hash: 7e83adff84be5d0c401a213eccb61e321a3fb1ff
active boot switches: -d:release
> Each time there a pain in Nim, always look for a cure in C.
I have to get rid of "==" and call `memcmp` for a cure.
That seems to expect a `vararg`.
I don't exactly know how many times I will be calling a new coroutine before
the loop. The best I can do is add the future to a seq everytime I call a
coroutine:
futures: seq[Future[void]]
for node in parseJson(j)["posts"]:
if
> Is there any way to convert a seq to vararg?
Array types can be implicitly converted to `varargs`:
[https://play.nim-lang.org/#ix=2ilk](https://play.nim-lang.org/#ix=2ilk)
In fact, `varargs` is a syntactic sugar for `openArray` :)
> A `varargs` parameter is an `openarray` parameter that
`--os:standalone` has been deprecated I think, the replacement is now
`--os:any`:
[https://nim-lang.org/docs/nimc.html#nim-for-embedded-systems](https://nim-lang.org/docs/nimc.html#nim-for-embedded-systems)
This cool code worth a package IMHO.
It seems like your issue is elsewhere, I tried myself with your cfg and code,
and with this panicoverride.nim:
proc rawoutput(s: string) = discard
proc panic(s: string) = discard
Run
This is a bug Python never fixed, because on Python it can implicitly
concatenate different strings, like F-Strings, non-Unicode strings, Raw
strings, ASCII strings, etc, often a crash at run-time is the result.
You can use a C++ code beautifier, like astyle, and skip the mangling with
exportc pragma, but for reading only not for code thats actually used.
If all of your procs are going to look like newFooBar above there, it's
possible to generate with a macro.
import macros, tables
type
Tensor[T] = object
discard
Model = object
field1: string
field2: string
field3: int
Applications are now officially open, please register via [this
form](https://forms.gle/6TKMiRZ2bP5DyUyZA).
> I'll look into your solution since I may need to adapt a few things (I've
> simplified the real uses cases to summarize it into a single problems). The
> goal is also to learn Nim's macro as well. I've now spent probably as much
> time on macros than it would have took to write the solution
ok, big thanks for answering so fast! :)
> If all of your procs are going to look like newFooBar above there, it's
> possible to generate with a macro.
Yes, it's exactly what I'm looking for. A way to generate several procedure
that follow a pattern.
I've been trying my hand at writing macros that generate proc but there is a
lot to
I have an `AsyncHTTPClient`. It
1\. Gets content from a server that returns a json formatted string
2\. From that string, my script looks for specific json nodes that describes
the media the `AsyncHTTPClient` should download. And then the client downloads
the file.
Now I am using the await
var j: string = getContent(webClient, link)
Run
should be
j: string = await getContent(webClient, link)
Run
Oh...
Thanks might as well delete the thread. This is why I was talking about having
a newbie section
29 matches
Mail list logo