Mac GUI

2021-08-08 Thread AIR
Thanks @georgelemon. All, I have switched the repository over to [GitHub](https://github.com/Airr/nim-cocoa.git), and have updated the original post. Of note: The `dev` branch is configured so that a static library is used in place of the discreet modules, which leads to faster compilation. A

Does parameter type matter for GC_unref()?

2021-08-08 Thread planetis
It appears it matters: (since destroy will call the destructor for Surface[] object.

Does parameter type matter for GC_unref()?

2021-08-08 Thread Stefan_Salewski
And this is the diff when I cast to Surface instead of RootRef: @nuc /tmp/salewski/.cache/nim $ diff drawingarea_d/ crash/ diff drawingarea_d/drawingarea.json crash/drawingarea.json 4,9c4 < "compile": [ < [ < "/tmp/salewski/.cache/nim/drawingarea_d/@m.

Does parameter type matter for GC_unref()?

2021-08-08 Thread Stefan_Salewski
For reference, this is the crash I get with latest Nim compiler with wrong cast: $ nim c --gc:arc drawingarea.nim Hint: used config file '/home/salewski/Nim/config/nim.cfg' [Conf] Hint: used config file '/home/salewski/Nim/config/config.nims' [Conf] ..

Using /usr/bin/time -v ./myprog is a bad idea for looking for memory leaks.

2021-08-08 Thread planetis
That used to be valid reason in in kde 4x series. Nowadays everything is split up in frameworks/applications and the dependencies are probably minimal/absolutely required.

2d canvas library

2021-08-08 Thread treeform
You can easily use pixie with glfw or SDL2 that can open windows and get keyboard and mouse inputs, see here for examples: * *

Using /usr/bin/time -v ./myprog is a bad idea for looking for memory leaks.

2021-08-08 Thread Stefan_Salewski
Yes I forgot, of course I compiled always with nim c --gc:arc -d:useMalloc myproc.nim Run I guess I can not use as I have not installed Qt and KDE, and I do not really intend too. Gnome is ugly still, but I don't think that KDE is re

Using /usr/bin/time -v ./myprog is a bad idea for looking for memory leaks.

2021-08-08 Thread planetis
May I suggest on linux?

constructor which will be called immediately after var call.

2021-08-08 Thread haxscramper
Nim does not support default initialization, everything is just set to zero-filled memory. If you want to default-init something then manually write `default (T)` on call. So it would be `var a = default(int)`. Seq is set to empty because nim sequences and strings have value semantics (they can

constructor which will be called immediately after var call.

2021-08-08 Thread chaemon
How about this example? type S = object a:int proc default(t:typedesc[S]):S = S(a:42) var s:S echo s # (a: 0) not (a: 42) Run

Generic way to set discriminant value that works on both C and VM backends

2021-08-08 Thread haxscramper
I even started writing and RFC for this as well (which is probably more generic than `reset()`). Didn't finish it and didn't publish, but here is a start (it talks about serialization because that was my main example at the time): * * * This artificial limitation, paired with compile-time check

Generic way to set discriminant value that works on both C and VM backends

2021-08-08 Thread haxscramper
Yes, I also discussed this with clyybber a while ago - (that's when `offsetof` hack was suggested), but I ended up writing macro that generates this initialization abomination (with explicit assigns) to please the prover. Now it got into i

invalid type: 'seq[int] or iterator (): int{.closure.}' in this context

2021-08-08 Thread Hlaaftana
`seq[int] or iterator: int` is a typeclass, not a concrete type. Concrete sum types in Nim can be achieved with [object variants](https://nim-lang.org/docs/manual.html#types-object-variants) . type Curve*[T] = object case isIter: bool of true: cpIter:

Unsafe data conversion in the VM

2021-08-08 Thread haxscramper
Is there any way to do unsafe conversion of one ref object type to another in VM? I can't do `cast[B](a)` in a macros (not for arbitrary types `'cast' from tyRef to tyRef`). I tried doing it in several steps, like `a -> int -> b`, but this does not work either, (`'cast' from tyInt to tyRef`). A

Generic way to set discriminant value that works on both C and VM backends

2021-08-08 Thread Hlaaftana
Unfortunately I don't think there's a good way yet. There is [this proposal](https://github.com/nim-lang/RFCs/issues/56) in the meantime.

Generic way to set discriminant value that works on both C and VM backends

2021-08-08 Thread haxscramper
Is there a generic way to hack discriminant assignment in a way that works for both VM and C backend (and Js backend as well if possible). I've come up with a solution that works for a C backend, but it fails in a VM. type Obj = object notKind: bool case kind:

constructor which will be called immediately after var call.

2021-08-08 Thread chaemon
If we call "var a:int", a is set to be 0. Then, are there any way to set to be call some proc like "default" immediately after "var" call? It seems that there is default proc for type int, string, float but these proc is not called after var call. I know that we can make another macro "var2" to

constructor which will be called immediately after var call.

2021-08-08 Thread juancarlospaco
It does uses default proc I think.

2d canvas library

2021-08-08 Thread Stefan_Salewski
I think both Raylib and SDL2 are not bad, and Nim bindings are available. But Pixie should be the most fun, when you do not need highest performance and can accept that it is still in an early development stage. For highest performance we may consider blend2d, but that one has no real docs yet

2d canvas library

2021-08-08 Thread asrp
> Most 2d graphic libs do not support that. Cairo does not, cairo on linux uses > gtkdrawingarea for that. Ah, I'm on Linux and that might be why I was able to get input. I just had a look and I'm using the Python C FFI for both XCB and Cairo, calling `connection = xcffib.connect()` and then `c

2d canvas library

2021-08-08 Thread asrp
Thanks! That looks promising.

Using /usr/bin/time -v ./myprog is a bad idea for looking for memory leaks.

2021-08-08 Thread Stefan_Salewski
Often use of /usr/bin/time -v is recommended for checking for the maximum memory consumption of a program. That information is given in Maximum resident set size (kbytes): 64392 Run Yesterday I spent a few hours wondering why it was showing leaks fine for C test progr

invalid type: 'seq[int] or iterator (): int{.closure.}' in this context

2021-08-08 Thread tsojtsoj
This gives a bit more helpful error message: type Curve*[T] = object cp: seq[T] or iterator: T proc linear*[T](cp: seq[T] or iterator: T): auto = result = Curve[T](cp: cp) let vf = @[0,1,2,3,4,5,6,7,8,9] var tlin = linear(vf) Run `/use

Does parameter type matter for GC_unref()?

2021-08-08 Thread Stefan_Salewski
And has that changed recently? I spend the whole weekend with Indeed I found a bug due to a tiny typo, but the cairo apps continue to crash with ARC. Before it was not crashing, maybe it leaked memory before. I have still no idea if Nim, Ca

2d canvas library

2021-08-08 Thread Stefan_Salewski
> get keyboard and mouse input Most 2d graphic libs do not support that. Cairo does not, cairo on linux uses gtkdrawingarea for that. Maybe you want SDL2, I think it supports input. Or maybe Raylib? Note, when people say canvas, some have graphic object handling in mind. But Cairo just draws

2d canvas library

2021-08-08 Thread ingo
might come closest to your whislist

2d canvas library

2021-08-08 Thread asrp
I'm looking for recommendation for a Nim 2d graphics library that also handles input * render text at fixed (x, y) location * an easy way to get bounding boxes for text * draw lines * draw filled and empty polygons * draw filled and empty circles * get keyboard and mouse input * (op

invalid type: 'seq[int] or iterator (): int{.closure.}' in this context

2021-08-08 Thread ingo
type Curve*[T] = object cp: seq[T] or iterator: T proc linear*[T](cp: seq[T] or iterator: T): auto = var curve = Curve[T]() curve.cp = cp curve let vf = @[0,1,2,3,4,5,6,7,8,9] var tlin = linear(vf) Run results in: