Binding a closure to a std::function to call it from C++... safe to do ?

2022-04-18 Thread krakengore
> I don't really know what std::function is It's a polymorphic function wrapper that is able to store function pointers, pointer to member function, capturing lambdas, bind result and so on. See for more info.

Binding a closure to a std::function to call it from C++... safe to do ?

2022-04-18 Thread krakengore
What is the lifetime of the closure scope that rawEnv points to? Can a closure have parameters? How do i specify them when i decompose the closure into his rawProc and rawEnv counterparts?

metatag - an audio metadata library

2022-04-18 Thread exelotl
This seems really useful! If you're looking to reduce the number of shared lib dependencies, I can recommend [zippy](https://github.com/guzba/zippy) as a pure-nim replacement for zlib :)

Optimize parsing large file line-by-line

2022-04-18 Thread LLN13
Ah, yeah. I thought about preallocating but unfortunately it would be difficult to estimate the line length. Thanks for the code! I'm new to the language and this is useful.

Binding a closure to a std::function to call it from C++... safe to do ?

2022-04-18 Thread Yardanico
I don't really know what `std::function` is, but one thing I can help with - Nim closures are stored internally as a object with two fields: pointer to the procedure itself, and pointer to the environment.

Optimize parsing large file line-by-line

2022-04-18 Thread LLN13
I'll try using a tuple. I only used a Table because the Python solution I have uses a dictionary and I wanted to compare the speeds. Thanks!

Optimize parsing large file line-by-line

2022-04-18 Thread doofenstein
oh stringifying chrom and checking for that, that's clever!

Binding a closure to a std::function to call it from C++... safe to do ?

2022-04-18 Thread krakengore
Do you think this could be a viable approach for passing a closure to a C++ member that could be called by C++ ? As my knowledge is still limited, i'm not sure this is safe to do or i could lead into shooting myself in the foot. Any advice would be great ! {.experimental: "callOper

Optimize parsing large file line-by-line

2022-04-18 Thread cblake
@Stefan_Salewski \- could be..This topic arises constantly. I was figuring "chrom" was short for "chromosome" and LLN13's context was bioinformatics. @LLN13, FWIW this is a concrete realization of my interpretation of Stefan's abstract ideas that may help you. I find it clearer (subjective-ish)

Optimize parsing large file line-by-line

2022-04-18 Thread Stefan_Salewski
Thanks for the link. I think actually I was remembering this one, it is not from Mr. Felsing, which I initially supposed. But I ca

Optimize parsing large file line-by-line

2022-04-18 Thread cblake
You may mean this thread:

Optimize parsing large file line-by-line

2022-04-18 Thread doofenstein
import parseutils, tables proc parse_bim(bim: string, chrom: int): Table[string, seq[string]] = var snp: seq[string] = @[] a1: seq[string] = @[] a2: seq[string] = @[] i = 0 while i < bim.len:

Optimize parsing large file line-by-line

2022-04-18 Thread Stefan_Salewski
My feeling is that you are using a few operations, which are all not very fast. split() allocates a few strings, which takes some time, and add() for sequences takes also some time. Maybe your parseInt() is not really necessary, may a plain string compare work? Note that parsing files was discu

Seeking advices for a C programming book

2022-04-18 Thread reversem3
its a rabbit hole when you dig into it that's for sure. Really interesting though and it helps to learn more about nim types. Someone needs to write a book how all of these languages get put together and at the same time compiler everything down into C.

Optimize parsing large file line-by-line

2022-04-18 Thread LLN13
Hi everyone, I am trying to pass a file (`file.bim`)with 21,283,105 lines line-by-line, apply a filter, and then save the results to a Table and would like to know if my following solution can be optimized further: import std/tables import std/strutils proc parse_bim(b

Possible workarounds for subclassing a c++ class and overriding a virtual method

2022-04-18 Thread krakengore
Isn't including actually creating another copy of the emitted code ?

Possible workarounds for subclassing a c++ class and overriding a virtual method

2022-04-18 Thread krakengore
After some tinkering i was able to bootstrap the C++ framework and get a window up: This is defining a macro that will emit both c++ and nim and the same time, using cdecl function pointers that will call into nim from c++.

Installing choosenim (on Windows) on a custom folder does not seem to work

2022-04-18 Thread didlybom
Hi, I'm trying to install choosenim on a custom folder in order to avoid my (corporate) antivirus from deleting some of its executables. I have been reporting the false positives to our antivirus vendor, but while it seems to help a bit, whenever I update choosenim again the problems seem to co

async stdin/stdout errors (compiling nimlsp on Windows)

2022-04-18 Thread veksha
Hello, All. I found a problem while compiling `nimlsp` project. this lines don't compile for me. (I'm on Windows 11 x64.) import asyncfile, asyncdispatch var ins = newAsyncFile(stdin.getOsFileHandle().AsyncFD) Run D:\Programm\Nim\nim-inject\test.nim(8

Seeking advices for a C programming book

2022-04-18 Thread Sixte
> Nim has not much "context" with C, whatever that means, it's Modula 3 with > Python's syntax and Lisp's macro system. But where is Modula-3's _opaque_ type then? It seems that a "tiny" abstraction layer is missing in Nim. If this is intentional or accidential, I don't know. Anyhow, it has som

metatag - an audio metadata library

2022-04-18 Thread sauerbread
Hello everyone, lately I've been tinkering around with audio files / playback and notice the lack of support of metadata handling in Nim (except a c wrapper for taglib). So I'm pleased to announce [metatag](https://github.com/sauerbread/metatag) a metadata reading & writing library written from