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 =
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
[https://cygwin.com/packages/summary/vte.html](https://cygwin.com/packages/summary/vte.html)
include lib VTE for windows
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
@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 :)
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
> 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
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.
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
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.
This is a restriction from GTK. They never ported it to windows :s
> 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
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
> 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.
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
Keep in mind, that VTE is not supported on windows.
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
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 ...
Thanks for the advice and the references.
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?
It works! Thank you
for i in 0..5:
closureScope:
let x = i
test.add(
proc () = echo x
)
test[3]()
`import sugar var test: seq[proc ()] for i in 0..5: capture i: test.add( proc
() = echo i ) test[3]() `
Run
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:
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
> So, I'll ask now.
I think the primary reason is different API design.
26 matches
Mail list logo