It works. Thanks a lot.
Thank you @jyapayne. It seems very simple now that I see code that works.
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.
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
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?
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
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)
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
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 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
@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
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/
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
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|
---|---
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
ok I worked around it like I would in C#... using indices.
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
#19 is live at: [https://youtu.be/uZ7jdkx4pKE](https://youtu.be/uZ7jdkx4pKE)
Scopes and When Statements.
Thanks for the clarifications. I'll try to improve it if I manage to get
everything working beforehand.
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
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 =
Solved with unsafeAddr(arr[0]) instead of unsafeAddr(arr)
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.
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
Your videos are very excellent, I hope to continue watching new content on your
channel to continue learning since I am new
Your work is awesome!
@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
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
Are you sure it's not specific to nimble build?
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
30 matches
Mail list logo