Call-for-Help: a 128-bit Decimal library expansion

2020-05-08 Thread JohnAD
I have just released a new decimal library for Nim that is based on the IEEE 754-2008 specification. [https://github.com/JohnAD/decimal128](https://github.com/JohnAD/decimal128) It has a pending PR for inclusion in the nimble directory. Examples of use: let a =

I have a problem with GC: ARC move?

2020-05-08 Thread JPLRouge
hello example Vtest = ref object name : string let fldx = new(Vtest) fldx.name = "test" proc setT( val : string) :string= return val var x = setT(fldX.name) Hint: passing 'fldx.name' to a sink parameter introduces an

Re: Terminal based GINTRO(GTK) VTE

2020-05-08 Thread JPLRouge
[https://cygwin.com/packages/summary/vte.html](https://cygwin.com/packages/summary/vte.html) include lib VTE for windows

From seq[] to C array, the safest way...

2020-05-08 Thread spip
I have to call an external API using C arrays from Nim `seq[]`. The API is using the array content for the duration of the call. What would be the safest and future proof way of doing it? **1\. Share seq[] private array for the duration of the call** var s: seq[Obj] # contains the

Re: runnableExamples Question

2020-05-08 Thread kaushalmodi
@timotheecour has this feature addition in a pending PR in [https://github.com/nim-lang/Nim/pull/14278](https://github.com/nim-lang/Nim/pull/14278) . It should be merged soon it seems :)

Best practices for wrapping opaque C pointer types?

2020-05-08 Thread snej
I'm wrapping a C API that uses the typical fake-OOP idiom of opaque reference types as "classes". In this case they're ref-counted. For example: typedef struct Box Box; Box* box_new(int size); void box_release(Box*); void box_retain(Box*); int box_get_size(const

Re: Some problems trying to eliminate 'nil'

2020-05-08 Thread snej
> You are not supposed to use not nil types as Option generic parameters Then how do I make a function that conditionally returns a value of that type, like the `makeFoo` function in my example? "Option(al)" is the canonical way to do this in other languages. I could use a regular ref as the

Re: gintro - glade event problems and multilingualism

2020-05-08 Thread Dankrad
Thank you for your reply. Currently the motivation to solve the multilingualism on windows is gone. Struggled for hours to fix this. I think soon I'll reinvestigate that problem, but currently this is not critical for me. If I find a working solution I'll leave an example here.

Calling proc with [() -> void] as a last parameter

2020-05-08 Thread doongjohn
import std/sugar # if [() -> void] is a last parameter of a proc you can do this(?) proc lambdaTest(a: int, lambdaProc: () -> void) = lambdaProc() lambdaTest(1): echo "[() -> void] as the last parameter." Run Just curious How does ":" syntax

Re: Terminal based GINTRO(GTK) VTE

2020-05-08 Thread Dankrad
But maybe I'm wrong too. It's been a year since I tried to use vte on Windows. I just tried to build an application with vte, but recognized that the vte module does'nt exist under windows.

Re: Terminal based GINTRO(GTK) VTE

2020-05-08 Thread Dankrad
This is a restriction from GTK. They never ported it to windows :s

Re: Byte Order (Endians) Library

2020-05-08 Thread dataPulverizer
> I don't think your code is standard though, usually void are implicit in the > return type, also var are used for in-place mutation, not pointers. Thanks for letting me know, I haven't written a lot of Nim so I'm still learning. I didn't realise that using var means in-place mutation, I've

Re: gintro - glade event problems and multilingualism

2020-05-08 Thread Stefan_Salewski
Fine that it works at all for you. Unfortunately I can not really help for both questions, and I am busy with adapting gintro to latest GTK 3.98.3 which will become GTK4. That adaption is some more work than expected, see

Re: Terminal based GINTRO(GTK) VTE

2020-05-08 Thread Stefan_Salewski
> Keep in mind, that VTE is not supported on windows. Is that an gintro issue or a general GTK restriction? I already asked google, but got no clear answer, maybe we have to ask on GTK forum.

gintro - glade event problems and multilingualism

2020-05-08 Thread Dankrad
Hi, I rebuilt my gui in glade and automatically connecting to signals. Therefore I need to use the lowlevel objects (with 00 suffix). Now I have the problem that i need to access the event parameter. Is there any better solution, to work with the gintro highlevel objects? I've solved it like

Re: Terminal based GINTRO(GTK) VTE

2020-05-08 Thread Dankrad
Keep in mind, that VTE is not supported on windows.

Re: Byte Order (Endians) Library

2020-05-08 Thread mratsim
History. I don't think your code is standard though, usually void are implicit in the return type, also `var` are used for in-place mutation, not pointers. And it's probably much more likely to read from an immutable value (often an int or byte array) to a mutable value (often a byte array or

Byte Order (Endians) Library

2020-05-08 Thread dataPulverizer
Is there a reason why the endians ([https://nim-lang.org/docs/endians.html](https://nim-lang.org/docs/endians.html)) library is written as it is rather than providing a familiar and more user friendly interface? I've written something more conventional and IMO easier to use ...

Re: Cast float64 to sequence of bytes and cast sequence of bytes to float64

2020-05-08 Thread dataPulverizer
Thanks for the advice and the references.

Re: Raylib Forever (4Nim)

2020-05-08 Thread flashchaser
I'm new to nim and am getting `could not load: libraylib.dll` as well. I've got it in the same directory as my .exe. When I clone the repo to my other windows computer it runs fine. Can anyone point this dummy in the right direction?

Re: Runtime generated function with generated constant value

2020-05-08 Thread JohnLuck
It works! Thank you

Re: Runtime generated function with generated constant value

2020-05-08 Thread slangmgh
for i in 0..5: closureScope: let x = i test.add( proc () = echo x ) test[3]()

Re: Runtime generated function with generated constant value

2020-05-08 Thread slangmgh
`import sugar var test: seq[proc ()] for i in 0..5: capture i: test.add( proc () = echo i ) test[3]() ` Run

Runtime generated function with generated constant value

2020-05-08 Thread JohnLuck
When you generate functions at runtime, the variables inside the function are from the closure around it. What I want is to dynamically generate something that becomes constant inside the function. The code explains it way better: var test: seq[proc ()] for i in 0..5:

Re: Some problems trying to eliminate 'nil'

2020-05-08 Thread Hlaaftana
You are not supposed to use `not nil` types as Option generic parameters, Options check if a type is ref or ptr or proc then assume their nil values to be `None` instead of using an extra bool discriminator, so `some(nil)` is also disallowed. You used `Option[Foo]` where `Foo` is not nil. There

Re: I cannot understand ARC

2020-05-08 Thread Araq
> So, I'll ask now. I think the primary reason is different API design.