Re: Passing a sequence by reference to a data type

2020-06-20 Thread SolitudeSF
var s = new seq[int] Run this should work

Re: Passing a sequence by reference to a data type

2020-06-20 Thread ameerwasi
@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

Re: On my first 'greet.nim' I get a C compiler error on RHEL 7

2020-06-20 Thread halloleo
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.

Re: Experimenting with a FreeRTOS OS Port

2020-06-20 Thread elcritch
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)

Re: New article about Nim meta-programming in Russian

2020-06-20 Thread LeFF
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

Re: New article about Nim meta-programming in Russian

2020-06-20 Thread Yardanico
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?

Re: New article about Nim meta-programming in Russian

2020-06-20 Thread Yardanico
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

Re: New article about Nim meta-programming in Russian

2020-06-20 Thread LeFF
[https://forum.nim-lang.org/t/1305](https://forum.nim-lang.org/t/1305) \- here you go.

Re: New article about Nim meta-programming in Russian

2020-06-20 Thread LeFF
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.

Re: How to get & set text in clipboard ?

2020-06-20 Thread Yardanico
> Report it to the antivirus people, Nimble is not a virus :)

Re: Unicode support for Windows 10 console

2020-06-20 Thread ktamp
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**

Re: How to get & set text in clipboard ?

2020-06-20 Thread Omnomnim
Why don't you whitelist it?

Re: How to get & set text in clipboard ?

2020-06-20 Thread kcvinu
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,. :)

Re: Passing a sequence by reference to a data type

2020-06-20 Thread Stefan_Salewski
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

Re: How to get & set text in clipboard ?

2020-06-20 Thread Stefan_Salewski
https://forum.nim-lang.org/t/4820#30170

Re: First take: parameters

2020-06-20 Thread b3liever
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

Re: Help required: Pointer Vertigo

2020-06-20 Thread catswhiskers
Perfect. Thank you so much. My noggin had been throbbing over this.

Re: First take: parameters

2020-06-20 Thread neo
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

Re: Help required: Pointer Vertigo

2020-06-20 Thread catswhiskers
Thanks. I'll give it a try.

New article about Nim meta-programming in Russian

2020-06-20 Thread LeFF
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

Re: How to declare container variable for proc?

2020-06-20 Thread jf1
Works perfectly! Thanks a lot!

Re: Help required: Pointer Vertigo

2020-06-20 Thread doofenstein
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 */

Re: Is --gc:arc completely independent from the older ownership model?

2020-06-20 Thread pietroppeter
and the result of arc is now down to 6.75s, see: [https://youtu.be/aUJcYTnPWCg](https://youtu.be/aUJcYTnPWCg)

Re: How to declare container variable for proc?

2020-06-20 Thread Tim_H
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 to declare container variable for proc?

2020-06-20 Thread jf1
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

Re: Is --gc:arc completely independent from the older ownership model?

2020-06-20 Thread pietroppeter
original post here: [https://forum.nim-lang.org/t/5734#36277](https://forum.nim-lang.org/t/5734#36277)

Re: Is --gc:arc completely independent from the older ownership model?

2020-06-20 Thread ivankek
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.

Re: Watch mode

2020-06-20 Thread jackhftang
You may have a look of [https://github.com/jiro4989/monit](https://github.com/jiro4989/monit)

Re: On my first 'greet.nim' I get a C compiler error on RHEL 7

2020-06-20 Thread Araq
Compile with 1.2.2 and if that fails still, compile with `-d:nimEmulateOverflowChecks`.

Passing a sequence by reference to a data type

2020-06-20 Thread ameerwasi
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

Re: Comparisons of Nim to the Chapel computer programming language...

2020-06-20 Thread stefantalpalaru
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

How to get & set text in clipboard ?

2020-06-20 Thread kcvinu
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.

On my first 'greet.nim' I get a C compiler error on RHEL 7

2020-06-20 Thread halloleo
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

Re: First take: parameters

2020-06-20 Thread neo
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

Watch mode

2020-06-20 Thread LancerRevX
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.

Help required: Pointer Vertigo

2020-06-20 Thread catswhiskers
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

Re: First take: parameters

2020-06-20 Thread neo
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.

Re: First take: parameters

2020-06-20 Thread juancarlospaco
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)

Re: First take: parameters

2020-06-20 Thread b3liever
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.

Re: First take: parameters

2020-06-20 Thread juancarlospaco
I dont understand what the problem is, if any.

Re: Is --gc:arc completely independent from the older ownership model?

2020-06-20 Thread JPLRouge
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

First take: parameters

2020-06-20 Thread neo
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?