Re: How can I simulate "name[id]" behaviour?

2020-03-07 Thread mantielero
It works. Thanks a lot.

Re: Karax: Adding elements

2020-03-07 Thread herdingSheep
Thank you @jyapayne. It seems very simple now that I see code that works.

Re: Nested list comprehension

2020-03-07 Thread didlybom
It would be nice if when something is deprecated in the standard library there was a link to the associated discussion/decision summary (if any). I found the deprecated list comprehension type a while ago and was curious about why it was deprecated.

Re: How does one get a `var` from a `ref` object?

2020-03-07 Thread mratsim
In your case you probably want reference semantics all the way, unless you duplicate "Person" instances so type Person = ref object prefers: Person proc engage(p1, p2: Person) = p1.prefers = p2 p2.prefers = p1 Run

Re: How does one get a `var` from a `ref` object?

2020-03-07 Thread adnan
ok I simplified the code so I hope people understand my problem better. I don't quite think dereferencing will help in such a case?

Creating functions at runtime

2020-03-07 Thread mantielero
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 so

Re: Creating functions at runtime

2020-03-07 Thread Hlaaftana
I don't get exactly what you're trying to do except that you can use dynamic libraries to load plugins at runtime. Here is a related Nimble package: [https://github.com/genotrance/plugins](https://github.com/genotrance/plugins)

Re: Creating functions at runtime

2020-03-07 Thread mantielero
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, "{functionNa

Re: Creating functions at runtime

2020-03-07 Thread mantielero
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?

Like C extern pragma?

2020-03-07 Thread Lachu
I found information about extern pragma, but It don't describe what it does. I need C-like extern pragma or way to use only function prototype (and include file with these prototypes). That's because I have problem with circual import of modules. Nim compiler complain about missing function impl

Re: Creating functions at runtime

2020-03-07 Thread jyapayne
@mantielero Nim does not support creating functions at runtime. Generally, compiled languages such as Nim get around this by compiling a source file into a DLL and then loading that. It's unfortunately not as simple as you want it to be. The library @Hlaaftana linked to is being created by @sha

Re: Like C extern pragma?

2020-03-07 Thread Lachu
Ok. I found the problem. It was I use c2nim and it puts asterisk after procedure name. That was obvious. Procedure must been defined in the same file, because it was marked as to be exported. Because It was C header file (and after use of c2nim it was nim file contains only signature/prototypes/

Re: Another state of generating Android APK thread...

2020-03-07 Thread yglukhov
I'm not into writing tutorials right now, but I can answer any concrete questions. Jnim at this point allows "implementing" java classes in nim (still experimental feature though). So as long as you know how to write your app in java, it's just a matter of 1-to-1 porting. One important point to

How does one get a mutable iterator?

2020-03-07 Thread adnan
import options type T = ref object data: seq[Option[T]] proc p(t: var T) = for datum in t.data: datum = none(T) Run /usercode/in.nim(8, 5) Error: 'datum' cannot be assigned to| ---|---

Re: Creating functions at runtime

2020-03-07 Thread shashlick
I've created a plugin system that's ready for use. It was part of the feud text editor I was working on and was recently extracted into a standalone repo and package. It has diverged since extraction and feud is yet to be ported to use it but that will happen eventually. Appreciate all reviews

Re: How does one get a mutable iterator?

2020-03-07 Thread adnan
ok I worked around it like I would in C#... using indices.

Re: How does one get a mutable iterator?

2020-03-07 Thread lscrd
To make datum a variable you need to use mitems: import options type T = ref object data: seq[Option[T]] proc p(t: var T) = for datum in t.data.mitems: datum = none(T) Run

Re: Nim for Beginners Video Series

2020-03-07 Thread Kiloneie
#19 is live at: [https://youtu.be/uZ7jdkx4pKE](https://youtu.be/uZ7jdkx4pKE) Scopes and When Statements.

Re: Creating functions at runtime

2020-03-07 Thread mantielero
Thanks for the clarifications. I'll try to improve it if I manage to get everything working beforehand.

FFI: from seq[int] to C array

2020-03-07 Thread mantielero
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 the

Re: Nested list comprehension

2020-03-07 Thread dawkot
I generally only put brackets where neccessary. You can write this using devel version of nim (you can use choosenim) import tables, sugar, sets, sequtils proc cross(xs, ys: string): seq[string] = for x in xs: (for y in ys: result.add x & y) let rows =

Re: FFI: from seq[int] to C array

2020-03-07 Thread mantielero
Solved with unsafeAddr(arr[0]) instead of unsafeAddr(arr)

Code review request

2020-03-07 Thread adnan
I think stackoverflow is a better platform for asking such question but I'm only opening this thread to increase visibility. Here is the original: [https://stackoverflow.com/q/60582785/12029705](https://stackoverflow.com/q/60582785/12029705) The code is about stable matching.

Re: Performance test agains Python

2020-03-07 Thread cumulonimbus
You are also testing cache effect times at least as much as you are testing the code you are running; Either take minimum-of-5 sequential runs, or an average of 10 loops or so (or both); Not sure about Win10, but for sure Windows used to report times in multiples of ~16ms at least as late as Win

Re: Nim for Beginners Video Series

2020-03-07 Thread wintonmc
Your videos are very excellent, I hope to continue watching new content on your channel to continue learning since I am new

Re: Nim for Beginners Video Series

2020-03-07 Thread jiro4989
Your work is awesome!

Re: Another state of generating Android APK thread...

2020-03-07 Thread GordonBGood
@yglukhov: > I'm not into writing tutorials right now, but I can answer any concrete > questions. I can appreciate that not everyone is into writing tutorials; thus I am proposing that I will write the tutorial so that others can refer to it from their documentation, including yourself, but I

Re: Code review request

2020-03-07 Thread kungtotte_
I don't have a stackoverflow account so I'll have to answer here. What do you think the output of the following code should be? type Person = object id: int name: string proc newPerson(name: string): Person = var next_id = 1 result.id = nex

Re: Why does `setCommand` exist?

2020-03-07 Thread Hlaaftana
Are you sure it's not specific to nimble build?

mac nano editor syntax highlight

2020-03-07 Thread pielago
hello I am new to the language found out about it like 6 hour ago and i loved it. I looked at them tutorials from the website and I cant wait to start coding but, I am not sure if someone already asked this question(does anyone knows how to add syntax highlight in nim using terminal mac nano edi