I don't think that bearing popularity in mind means disregarding all the other
things that Nim is already managing really well.
I don't like popularity, I like what it comes with popularity: more brains,
more libraries, better maintained packages, ... This thread could be titled:
"Nim's
Gracias @juancarlospaco. This is exactly what I was looking for.
@treeform, nice overview. Given Nim's potential, I am surprised about point 1.
I think/hope this is a matter of time.
I was wondering (just out of curiosity) about current Nim's popularity.
I know every metric is somehow biased, but I would like to get a feeling about
how is evolving. I was looking as well, for the biggest projects developped in
Nim (apart from Nim itself). I bet there is a way to get that
Hi deech.
I am posting here to avoid hijacking the [hackaton
thread](https://forum.nim-lang.org/t/6394).
I am not sure if I get it. If I understand this correctly, this provides is a
way to introspect headers by means of libclang. So this could be used to create
a nimterop like tool using
I am not a contributor so probably not entitled to give an opinion here. In any
case, I would suggest improving
[nimterop](https://github.com/nimterop/nimterop). Right now it works really
well when you try to wrap C libraries. But it could be even better, and it
still misses the capability to
The thing is that in example1 case there is an implicit conversion from Cat to
Animal, while in example2 that conversion has to be explicit.
I would expect the implicit conversion happening in both cases. Probably there
is a rationale for that no happening.
Ahhh. I though it would be something more complicated. It is just a matter of
adding objects into another object.
I understand the rationale of seq[Animal] being a different type than seq[Cat].
But I believe this is counter-intuitive when Cat it is actually an animal.
In fact, it looks strange to me the following behaviour:
type
Animal = ref object of RootObj
Cat = ref object of
With all this experiments with OOP, I have read in several places that Nim
encourage composition against inheritance. I have read
[this](https://medium.com/humans-create-software/composition-over-inheritance-cb6f88070205)
which is very clear, but I don't know how this translates well into Nim.
I am still struggling with the type system .
For instance:
type
A = ref object of RootObj
B = ref object of A
val:int
proc example*(x:seq[A]) =
for i in x:
echo repr i
var a:seq[A] = @[B(val:1), B(val:2)] #<--- This fails, but
My bad. It was an error somewhere else.
@mratsim, it looks we posted at the same time and I missed your answer. Much
better your second solution. Thanks.
Thank both. It is clear. In fact I just realised that the problem was cause by
something different (that I still don't understand), but probably it has
something to do with the stack and the heap.
I have something like the following:
let points = newPoint( @[ pt(0,0,0),
I have a function with the following signature:
proc newCurveLoop*( curves:seq[Curve]; tag:int = -1 ):Loop
Run
On the other hand I have:
Curve* = ref object of Tag
Line* = ref object of Curve
ini*, fin*:Point
Run
The type safety makes
Thanks Stefan. Understood.
I fixed it with:
proc pt*[N1,N2,N3:SomeNumber](x:N1, y:N2, z:N3):tuple[x,y,z:float] =
Run
Why the following code is failing?
proc pt*[N:SomeNumber](x, y, z:N):tuple[x,y,z:float] =
return (x: x.float, y: y.float, z: z.float)
let t1 = pt(0,0,0)
let t2 = pt(0.1, 0, 0)
let t3 = pt(0.1, 0.3, 0)
let t4 = pt(0, 0.3, 0) #<- Why is this
I think I just had to remove the ref in Tmp definition:
type
Coord = ref object of RootObj
x,y,z:float
Pt* = ref object of Coord
Tmp = ref object of RootObj
tag:int
point:Pt
let a = Pt(x:1.0, y:3.0,z:2.0)
let
I have not used OOP in Nim so far. I was playing with the following code:
type
Coord = ref object of RootObj
x,y,z:float
Pt* = ref object of Coord
Tmp = ref object of RootObj
tag:int
point:ref Pt
let a = Pt(x:1.0,
I have a sequence of distinct types (despite all of them are actually int). I
would like to "copy the types" into a new sequence. (Not looking for
workarounds, because the problem is a little bit more involved)
Something as the following:
type
A = distinct int
B =
I am trying to define the following callback from Nim:
static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
int i;
//-- Get the body's ID
dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2);
//-- If they are
Why other languages are not prettified?
I had that feeling too. Thanks Vindaar.
or theirs.
What I am doing is pretty simple:
1. I create a sequence of floats by calling
[linRange](https://github.com/mantielero/gr.nim/blob/master/examples/grm_plot.nim#L4)
2. The function linRange is pretty simple. It is defined
[here](https://github.com/mantielero/gr.nim/blob/master/src/gr/
Any experience/advise with this?
I was looking forward to create bindings with [Open
Cascade](https://www.opencascade.com/doc/occt-7.3.0/overview/html/index.html)
after the accumulated experience so far with a couple of projects. But I
realized that it is C++ and it is huge, so bad starting
I have just done the bare minimum to get it working. Hopefully it can be useful
for some of you.
Here you have some basic
[documentation]([https://mantielero.github.io/gr.nim/](https://mantielero.github.io/gr.nim/))
and the
[code]([https://github.com/mantielero/gr.nim)](https://github.com
I asked this question yesterday in [nimx
issues](https://github.com/yglukhov/nimx/issues/417). But I would like to do it
in other frameworks as well.
Basically I would like to do somehing like
[this](https://gr-framework.org/tutorials/gr3_wx.html).
@juancarlospaco, I was wondering if this
@Vindaar, I am working on doing some bindings to
[gr-framework]([https://gr-framework.org/)](https://gr-framework.org/\)). My
bindings are not mature, but I believe it could be a better option that using
Cairo.
I have created both animations, images, ... in both windows and pictures.
It could
Thanks guys.
Is there a function to know the number of items in a tuple?
on
[hs071_c.c](https://github.com/coin-or/Ipopt/blob/master/examples/hs071_c/hs071_c.c).
The second example uses a macro to perform a similar calculation
[ex02.nim](https://github.com/mantielero/ipopt.nim/blob/master/examples/ex02.nim)
which is a lot shorter and kinder to the eyes.
I hope it becomes
Thanks. That was what I was looking for.
For reference:
[https://github.com/nim-lang/Nim/issues/13973](https://github.com/nim-lang/Nim/issues/13973)
, because I am using something similar
[here](https://github.com/mantielero/ipopt.nim/blob/9967dc72130a45e8d6a675439f174cf24a01c941/src/ipopt.nim#L419)
and it is working. That is what is making me thing that this is an error a not
a bug.
I am having an issue with a macro that I am not managing to solve.
The code is messy, but I will try to make clear the issue.
I have the source code
[here](https://github.com/mantielero/ipopt.nim/tree/master/src). When I compile
this code, the last lines displayed (from expandMacro
This weekend playing with a macro I faced the following problem.
The following code [fails](https://play.nim-lang.org/#ix=2hQj):
import macros
proc hello() =
echo "hola"
macro function() =
let f = genSym(nskProc, ident="hello")
result = quote do:
I don't have much practise with macros and I normally end-up with big ones. How
can I split macros bearing in mind that I might need to reference identifiers
from one sub-macro into another submacro?
mymacro:
submacro1:
...
submacro2:
...
Thanks a Araq for trying.
I manage to find and solve the problem.
Regarding the cast, are you referring to
[these](https://github.com/mantielero/ipopt.nim/blob/master/src/ex01.nim#L238-L244).
I need to think about how to make it easier using the library.
I am getting the following error:
/home/jose/src/VapourSynth.nim/test/ex12.nim(24, 6) Error: type mismatch:
got
but expected one of:
proc append(vsmap: ptr VSMap; key: string; data: float)
first type mismatch at position: 3
required type for data: float
but
Just for the record, it was much more informative (at least for me) compiling
with:
$ nim c --profiler:on --stacktrace:on ex01
and then checking the error messages provided by valgrind:
$ valgrind ./ex01
://github.com/mantielero/ipopt.nim/tree/master/src). The ex01.nim
code compiles fine, but when I run it I get the failure:
**
This program contains Ipopt, a library for large-scale nonlinear
optimization
Well now I am amazed but on the other side of the pic.
I need to check if I have done something really wrong, but I have managed to
get: 6074fps using float32 (I was expecting 3000fps) and 10700fps using int32,
just by taking advance of multithreading.
I made it work like this:
import locks
type
FrameRequest {.bycopy.} = object
numFrames*: int # Total number of frames
nthreads*: int # Number of threads available
completedFrames*: int # Number of frames already processed
zed that, but I don't want to change
that (yet) until I get similar performance to the C++ version with similar
algorithm.
I tried to perform a filter with
[ArrayMancer](https://github.com/mantielero/VapourSynth.nim/blob/master/src/filters/Mancer.nim)
but I got worst.
My short term object
Disclaimer: I don't have much experience with multithreading (I played with it
long ago in python).
In a different [forum thread](https://forum.nim-lang.org/t/6169), we were
talking about the need of setupForeignThreadGc() on the top of a callback
called by C.
In the same context, I aiming to
**C++ stuff**
In order to test the C++ version:
1. The code can be downloaded from
[here](https://github.com/IFeelBloated/test_c_filters).
2. I compiled it like:
$ g++ -Wall -O3 -shared -fPIC -I. -o libfilter.so GaussBlur.cxx
3\. Create a VapourSynth python filter like
I was just looking into this at this very moment and I am not sure if I use it
well.
I was reading the [Thread
coordination](https://nim-lang.org/docs/backends.html#memory-management-thread-coordination)
section and this [forum entry](https://forum.nim-lang.org/t/3965#24714).
So I was
**Nim stuff**
I have updated the [repository](https://github.com/mantielero/VapourSynth.nim).
I have a local package.json with:
[
{
"name": "vapoursynth",
"url": "https://github.com/mantielero/VapourSynth.nim;,
You are probably right. For me is the first time doing this sort of stuff. But
the feeling that I have is that even small modifications in the algorithm
(avoiding conversions as much as possible, for example) has a significant
impact. I think that the reason is that I am interating on 100_000
This is part of a convolution filter. The result is in the same order of
magnitude (uint8):
let value:int32 = r0[col0].int32 + r0[col1].int32 * 2 + r0[col2].int32
+
r1[col0].int32 * 2 + r1[col1].int32 * 4 + r1[col2].int32
* 2 +
I have something like the following:
> let value:int32 = r0[col0].int32 + r0[col1].int32 * 2 + ...
where r0 has type ptr UncheckedArray[uint8].
How can I avoid adding .int32 each time I use one item from the unckeckedarray?
It has improved a bit. Regarding the Nim filter:
* 308fps by tuning seq[seq[int]], into array[9,int32]
* 442fps by changing the bound checks into min( max(val, 0), max_val)
Still slow but getting better.
import ../vapoursynth
import math
template clamp(val:int,
**Working with C filters**
When I work with C filters (like Convolution) I works fine with refc GC. In
that case, I don't know why I get 2640fps vs 3740fps on the python version.
They should be roughly the same. When I call a filter within an existing plugin
I just call one function:
At this stage I can only recommend NOT to use VapourSynth.nim. It is too slow
(not because of nim, but I cannot find out why).
Testing the convolution filter in Python:
import vapoursynth as vs
core = vs.get_core()
core.std.SetMaxCPU('none')
clip =
Let me try asking less general questions:
What is preferred, using UncheckedArray, using [these
templates](https://forum.nim-lang.org/t/1188#7366)? I guess all this is better
than performing a memcopy into a Nim structure.
Solved in Archlinux's R49-2. It was a packaging problem.
My filters are unsurprisingly slow (because of the "My" variable, of course).
Now I would like to learn how to avoid that. I have implemented a Gauss filter
just to compare it with a C++ version . The results are 80fps (for me) against
about 2400fps for a C++ wrapper and 11748fps for a pure C
Just for the record the C++ version is
[here](https://github.com/IFeelBloated/vsFilterScript/blob/master/GaussBlur.hxx#L23)
using templates.
And this is by using the [low level
API](https://github.com/IFeelBloated/test_c_filters/blob/master/GaussBlur.cxx#L26).
It doesn't gives me much information:
$ ./modifyframe
ViolaciĆ³n de segmento (`core' generado)
I have observed also that this happens when I call a macro, but not when I call
a vapoursynth plugin.
A different one. I get a Segfault:
That fails, but I have checked that the following works:
nim c -f --threads:on --gc:none modifyframe
Why do I need that now? Is this a change in Nim or in vapoursynth? I keep on
using v1.0.6 as far as I know.
Tonight I updated my archlinux installation. It updated vapoursynth from R48 to
R49.
If I compile and run a file I get the message:
$ ./modifyframe
/home/jose/src/VapourSynth.nim/src/libs/libvapoursynth.so: undefined
symbol: pthread_create
could not load:
What I have done is to go for a minimal execution trying to find problems.
Something strange that I have observed while doing so is that if I comment the
line:
echo &"Width: {width} bytesPerSample: {bytesPerSample} "
Run
I pass from 369 errors in 61 contexts to 0. Why
Thanks Stefan.
So:
nim c -r modifyframe
fails after 6 frames as explained before.
arc fails for me:
$ nim c --gc:arc modifyframe
Hint: used config file
'/home/jose/.choosenim/toolchains/nim-1.0.6/config/nim.cfg' [Conf]
command line(1, 2) Error: 'none',
I am facing some kind of issues that I am having difficulties to solve. I am
getting the following error during runtime:
Traceback (most recent call last)
/home/jose/src/VapourSynth.nim/src/filters/modifyframe.nim(9) modifyframe
I was wondering if it is possible to apply a small kernel to a bigger matrix. I
have implemented a small blur filter, and I would like to see how it feels to
do it with arraymancer.
Despite there is lot of work ahead I today I have achieved the two main
objectives I aimed with this project:
1. Being able to reuse VapourSynth plugins
2. Being able to create pure Nim filters in an easy way. And
[this](https://github.com/mantielero/VapourSynth.nim/blob
One remaning question is how can I see the result from a template execution. I
am not talking about invoking the template. For instance in the example above,
is there a way to see how:
tpl(myname):
echo "1"
echo "2"
Run
gets converted into:
I am trying to do something like the following:
template tpl(name:string, body:untyped):untyped =
proc `name Free`()=
body
tpl("myname"):
echo "1"
echo "2"
mynameFree()
Run
What am I missing to make it work?
Secondly,
Brilliant. Thanks a lot.
How can I create a new function with a template so that the created function
has its function name prefixed? Something like:
template mytempl(prefix) =
proc $prefix & World() = echo "hello world"
Run
So that:
mytempl(hello)
Run
creates a
I fixed this issue. Now we can create filters in pure Nim.
Right now, it is only a small improvement when compared with C because it only
avoids having the filter within a plugin.
Slowly getting there.
Thanks @Araq, that helped me fix the bug.
(Just for the record; I haven't checked if these are already known issues or if
they are actually issues or my misuse)
I am playing again with c2nim. I am not sure if this could be a problem:
typedef enum VSColorFamily {
cmGray = 100,
cmRGB= 200
}
This is the second time I face this error:
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
So I am pretty sure this is something that I systematically do wrong. This
happens when I wrap some libraries.
My question is what is the right strategy to debug this sort of
@mratsim, thanks a lot. Right now I am focusing on
[simple.nim](https://github.com/mantielero/VapourSynth.nim/blob/master/test/simple.nim).
Don't hesitate to participate in this
[issue](https://github.com/vapoursynth/vapoursynth/issues/534).
It looks like the address type wasn't right. The following works (where "tmp"
contains the pointer):
let address:ptr uint8 = cast[ptr uint8](tmp)
address[] = 10.uint8
Run
I'd like to change the content from an address. I though the following would
work.
let address =
address[] = 10
Run
How should I do it?
://github.com/mantielero/VapourSynth.nim/blob/master/test/function.nim),
but doesn't work (yes, I know there is plenty of rubbish in it). I think it
has to do with something related with memory managment or nil pointers of stuff
like that (I don't have the expertise).
I have reached a point where
I was missing the {.cdecl.} in the function declaration.
I am having a problem with a function call:
Error: type mismatch: got .}> but expected 'VSFilterGetFrame = proc (n: cint, activationReason:
cint, instanceData: ptr pointer, frameData: ptr pointer, frameCtx: ptr
VSFrameContext, core: ptr VSCore, vsapi: ptr VSAPI): ptr
[Added](https://github.com/mantielero/VapourSynth.nim/blob/master/src/plugins/motionmask.nim)
Let me know if it works (or not)
FFT3D should work (I haven't tried).
I think Masktools are not available as a plugin for VapourSynth. If I am wrong,
let me know and I will wrap it.
ost forgot, the link to the code:
[VapourSynth.nim](https://github.com/mantielero/VapourSynth.nim).
Lot of work ahead.
Thank you both. I got it working.
I am trying to read c-array into a sequence. If somebody could confirm if my
understanding is correct.
In one hand, I have in C world: an address, the array size and the type.
Something like: bufferptr, size and uint8 (it contains an image).
In order to load the buffer into the seq, is the
Thanks for that. I was looking about how that was called (enum offsets).
Nimterop has other issues (I should file it). For instance:
toast -pnrk VapourSynth.h
creates the following enums:
pfRGB24* = (cmRGB + 10).VSPresetFormat
pfRGB27* = 29.VSPresetFormat
pfRGB30* = 30.VSPresetFormat
pfRGB48* = 31.VSPresetFormat
@akavel no problem and I understand (I can imagine).
@shashlick thanks for that. Very useful.
I have left my spaguetty code [here](https://github.com/mantielero/h2nim.py) (I
called it **h2nim.py** ). It uses
[pyclibrary](https://pyclibrary.readthedocs.io/en/latest/) under the hood. It
is far
I will take a look to ggplotnim. Looks interesting.
I have played with both nimterop and c2nim before.
Thanks a lot.
Thanks for the clarification.
Or alternative, you can point me in the right direction if you actually know
what is the problem.
I read the documentation, despite neither
[here](https://github.com/nim-lang/c2nim) nor [here
When I try to use c2nim, it tends to fail while parsing stuff (vapoursynth and
gr). Por example, with
[gr.h](https://github.com/sciapp/gr/blob/master/lib/gr/gr.h):
$ c2nim --header gr.h
gr.h(27, 25) Error: token expected: ;
$ c2nim --dynlib /usr/gr/lib/libGR.so
By the way, I am just playing with [gr framework](https://gr-framework.org/).
#import gr_wrapper
const
libName = "/usr/gr/lib/libGR.so"
proc gr_initgr*(){.importc,dynlib: libName.}
proc gr_polyline*(a:cint, b:ptr cdouble, c:ptr cdouble)
Is it possible to avoid giving names to arguments in the functions?
I have the following in the C header:
DLLEXPORT void gr_polyline(int, double *, double *);
Run
and in order to make it work, I have to do:
proc gr_polyline*(a:cint, b:ptr cdouble, c:ptr
Solved with unsafeAddr(arr[0]) instead of unsafeAddr(arr)
I have wrapped a C function with the following signature:
type
VSAPI* {.bycopy.} = object
...
propSetIntArray*: proc(map:ptr VSMap, key:cstring, i:ptr int64,
size:cint):cint
...
Run
I want to make easier to deal with it with something like
Thanks for the clarifications. I'll try to improve it if I manage to get
everything working beforehand.
I see that this [nimeval - execute](https://forum.nim-lang.org/t/1319#8265)
could be useful for my problem. But it looks like it is no longer available.
What is the alternative?
I am trying to make something like the following:
macro gen_function(plugin:string, functionName:string) =
var source = fmt"""
proc {functionName}():ptr VSMap =
let plug = getPluginById("{plugin}")
let args = createMap()
return API.invoke(plug,
I am wrapping VapourSynth and I facing a problem that I don't how to best face
it.
I want to make available a number of functions that are available from plugins.
The plugins available are known at runtime. For example the following works:
macro gen_functions():typed =
var
1 - 100 of 132 matches
Mail list logo