var s = new seq[int]
Run
this should work
@Stefan_Salewski I don't know if I understood your intent properly but I tried
doing this,
type
lis = ref object of RootObj
v : ref seq[int]
var s : ref seq[int]
s[] = @[1, 2, 3, 4, 5]
let list = lis()
list.v = s
Run
the runtime
Thanks @araq.
I had tried the bin tarball of 1.2.2 but couldn't install (error: 'nim-gdb
missing' or similar). 1.2.0 however worked.
I've add a bit of documentation to my main example project, with networking
(ethernet):
[https://github.com/elcritch/esp32_nim_net_example](https://github.com/elcritch/esp32_nim_net_example)
Well, yes it is easier. I tried using times module for that, but sadly it
failed to compile. I think it is a bug, as I can see no real reason why times
module can't be used at compile time. On the other hand using random at compile
time that I made for the article seems easier than modifying the
I see you've used similar ideas as I did in
[https://github.com/Yardanico/nim-strenc/](https://github.com/Yardanico/nim-strenc/),
nice :) What do you think about making a Russian Nim forum?
Yeah, sorry, didn't saw it was you, cool that you made your post now :) Anyway
you could check in my strenc lib that my process of getting the seed is easier
[https://forum.nim-lang.org/t/1305](https://forum.nim-lang.org/t/1305) \- here
you go.
Actually I gave him an idea to use term rewriting macro for that if you dig up
his forum post here before the library was released.
> Report it to the antivirus people, Nimble is not a virus :)
Since **WideCStrings** are **UTF16** encoded and standard strings are **UTF8**
encoded, I wonder why **newWideCString(s)** allocates **4 * len(s) + 2** bytes.
The most expensive case would be when each rune is **s** is standard **ASCII**.
In this case each rune would take up _one byte_ in **s**
Why don't you whitelist it?
Thanks for the reply. Since, my antivirus is catching nimble, i am not able to
use it. And i send a message to the author of that library that i would like to
know how to use it without nimble,. :)
I have no idea what shallowCopy(list.v, s) should do in this case.
Your v : seq[int] and your let s = @[1, 2, 3, 4, 5] both defines value types.
Well v is a field of a reference to an object, but v is still seq, and seq are
value types in Nim, when v get filled with data v allocates its own data
https://forum.nim-lang.org/t/4820#30170
But it technically doesn't pass the arguments to echo just a single string that
is constructed from the arguments (`join` does that).
I was thinking a more general case of passing arguments of different types to
the underlying call. Can only be achieved with macros (like the code from
`nimpylib
Perfect. Thank you so much. My noggin had been throbbing over this.
proc lfecho*[T](data: T) = echo '\L', data
Run
only works for a single parameter.
The following is the solution:
import strutils
proc lf2echo(data: varargs[string ,`$`]) =
echo '\L', join data
lf2echo "N", ' ', "I'm"
Run
Thanks. I'll give it a try.
Hey! I've just wrote an article about how to use Nim's powerful metaprogramming
features for simple code obfuscation. The text is in Russian language, but the
code is pretty self explanatory. Here is the link:
[https://wasm.in/blogs/meta-programmirovanie-nim-i-obfuskacija.706](https://wasm.in/bl
Works perfectly! Thanks a lot!
I think your problem could lie in this definition:
XcursorImages* = object
nimage*: cint #* number of images */
images*: seq[ PXcursorImage] #* array of XcursorImage pointers */
name*: cstring #* name used to load images */
and the result of arc is now down to 6.75s, see:
[https://youtu.be/aUJcYTnPWCg](https://youtu.be/aUJcYTnPWCg)
Would something like this work for you?
proc a(x: int): int = x+1
proc b(x: int): int = x+2
var container: proc(x:int):int
if 4 > 5:
container = a
else:
container = b
echo $container(3)
Run
How would one declare a variable that is to contain a procedure later on?
E.g.: instead of testing a condition over and over again in each run of a proc
and branching depending on the condition, I'd create two functions, one for
each of the possible values, check the condition once (which is not
original post here:
[https://forum.nim-lang.org/t/5734#36277](https://forum.nim-lang.org/t/5734#36277)
Also can anyone paste a link to the tree benchmark? Can't find it
It compared the performance of a tree implementiation using gc:arc, boehm, and
something else. Was pretty interesting.
You may have a look of
[https://github.com/jiro4989/monit](https://github.com/jiro4989/monit)
Compile with 1.2.2 and if that fails still, compile with
`-d:nimEmulateOverflowChecks`.
Ok, it's only been a few days of me learning nim, so this may as well be one of
the basic things but, Idk. So my problem is that when I make a sequence and
pass it's shallow copy to a data type and add to it, only the sequence inside
the data type gets added to. To better illustrate this, here's
Chapel uses this interesting C library for its green threads:
[https://github.com/Qthreads/qthreads](https://github.com/Qthreads/qthreads)
Note that a couple of the available schedulers support MxN threading, allowing
you to use all CPU cores, just like with Go.
I hope we'll be able to use it i
Hi all, I am using windows machine. I would like to know how to set and get
text in clipboard. I hope i don't need to use any libraries. Thanks in advance.
Hello. I'm just start out with nim on a RHEL 7 system with gcc installed. I
installed nim from the binary tar ball, wrote the _greetings.nim_ from the
tutorial and tried to compile it with `nim compile greetings.nim`, but I get an
error from the underlying C compiler. Here the complete output of
Besides using a generic, your link is the way to go.
proc lf2echo(x: varargs[typed, `$`]) =
echo x
proc lf2echo(x: varargs[typed]) =
echo x
Run
Same error for both forms.
: invalid type: 'typed' in this context: 'proc (x: varargs[typed])' f
I'm willing to use Nim instead of TypeScript for creating JavaScript frontend
in my hobby project, is there a way to use the compiler in watch mode, which is
present in tsc (TypeScript compiler), so that my code would compile
automatically when i save it? i'm using Visual Studion Code.
PXcursorImages* = ptr XcursorImages
XcursorImages* = object
nimage*: cint #* number of images */
images*: seq[ PXcursorImage] #* array of XcursorImage pointers */
name*: cstring #* name used to load images */
proc Xc
Compiler outputs errors for the lines to be fixed.
The question would be how to declare and pass a varargs set as parameter to a
procedure.
I found a solution by using a generic parameter. I wonder if that introduces
some level of overhead. In any case I'd like to fix those errors.
Something like this?
[https://github.com/Yardanico/nimpylib/blob/master/src/pylib/print.nim#L13](https://github.com/Yardanico/nimpylib/blob/master/src/pylib/print.nim#L13)
I have stumbled upon it in the past. He wants a way to forward varargs to echo,
it is a useful pattern when making libs with generics.
I dont understand what the problem is, if any.
I did a test with and without --gc: arc
with the same parameters
DEBUG mode without: the program is smaller but much slower 1.2 MB with: the
program is larger 1.4 MB but much more fluid PROD mode without: 523 KB very
slightly slower with: 602Kb
I did not find a report on the subject !!! can yo
Is there a way to improve on:
proc lfecho*[T](data: T) = echo '\L', data
Run
How can I fix:
proc lfecho(x: varargs[typed]) = echo '\L', x
proc lf2echo(x: varargs[typed, `$`]) = echo '\L', x
Run
Can I rename a standard library procedure?
42 matches
Mail list logo