Experimenting with an SQLite-based portable graph DB engine

2021-01-12 Thread ElAfalw
Wow! Very interesting project. I'll definitely have a look. Well done!!

Sublime Text user experience

2020-10-30 Thread ElAfalw
Interesting topic. I am using Sublime myself. What are you guys using?

Handle missing library at runtime?

2020-10-30 Thread ElAfalw
Currently, I'm making use of `db_mysql`, which means that there must already be a `MySQL` driver installed. If MySQL is there, the program compiles fine and runs fine. If MySQL is not installed, the program still compiles fine but throws an error (that's on Mac): could not load:

Get all procs in given module

2020-10-30 Thread ElAfalw
Ok, so I've been trying to get _all_ procs defined in a given module. Let's say in `myModule.nim` we have `proc proc1` and `proc proc2`. How can I do something like this (at compile-time): const myProcs = getProcsIn("myModule") Run and `myProcs` containing `[proc1, pr

Passing X to a sink parameter introduces an implicit copy

2020-10-19 Thread ElAfalw
Nice explanation. Thanks! I'll give it a try to see the results...

Passing X to a sink parameter introduces an implicit copy

2020-10-19 Thread ElAfalw
`...; if possible, rearrange your program's control flow to prevent it.` This is a common hint message I've been getting. Are there any guidelines as to how to deal with that? (I know about `move`, but I'm not really sure what it implies...)

Tuple unpacking and '_' - not being discarded?

2020-10-19 Thread ElAfalw
Good to know. Thanks!

Tuple unpacking and '_' - not being discarded?

2020-10-19 Thread ElAfalw
As per the documentation, I'm trying to "unpack" a tuple like this: let (a, _) = getSomeTupleValue() Run So, in that sense, I imagine I'm just assigning `a` to the first element of the tuple, and discard the second. However, this is what I'm getting when compiling:

Tuple unpacking and '_' - not being discarded?

2020-10-19 Thread ElAfalw
I was using 1.5.1 devel and thought I tried 1.4.0 to see if that was the case. However, in 1.4.0, I keep getting the exact same message. I still cannot figure out why I get the Hint and you don't. The only difference I guess would be that I'm using it in a template?

push/pop hints on/off not working?

2020-10-18 Thread ElAfalw
I've been trying to silence one million different hints coming from system (std) libraries, but I still cannot manage to see how... Here's an example of what I mean (the list is practically endless, this is just a sample - and the problem is that amidst all these, I cannot spot the warnings and

Localized sorting library?

2020-10-16 Thread ElAfalw
So, I'm wondering if there is any localization-friendly sorting library in Nim? In Ruby, I've been using twitter_cldr and lots of different ones, which seem to be working great. Basically, let's put it like that: * You define the language * And sort the strings accordingly. E.g. if the s

Non-blocking async HTTP server

2020-10-14 Thread ElAfalw
This is my code (but it obviously blocks everything). var server = newAsyncHttpServer() proc handler(req: Request) {.async,gcsafe.} = #...do some stuff await req.respond(status.HttpCode, body, headers) try: echo ":: Starting server on port " &

Emdedding text in binary - post-compilation

2020-10-13 Thread ElAfalw
I have a rather weird question but I don't really know how to put it or where to start looking from. My question is _not_ about "embedding" a text file (we already have at compile time) - that is too obvious. My question is if (and how) I could let's say "package" an existing (Nim created) bin

Differentiate between system and user modules

2020-10-08 Thread ElAfalw
Let's say that I'm desperate to have a user module called `strutils` for example. Am I allowed to do that? And if so, how do I differentiate between the two modules when importing them for example?

Looking for collaborators!

2020-10-06 Thread ElAfalw
Well, count me in! I guess there are many people far more knowledgeable than me in this field, but given that I've been playing with interpreters/compilers/grammars/etc for the past 15 years, I hope there is something that I can contribute. :) And, yes, in that aspect, Nim seems like a perfect

Defects vs Exceptions

2020-10-05 Thread ElAfalw
I've been getting various similar warnings, like: Warning: See corresponding Defect; DivByZeroError is deprecated [Deprecated] Run The same happens with OverflowError which I'm trying to catch in some cases, like: try: ... something except Ov

Defects vs Exceptions

2020-10-05 Thread ElAfalw
oh... and I kept looking and looking for the solution and it was apparently in front of me. haha Thanks a lot! :)

Assignment in if condition

2020-09-30 Thread ElAfalw
Thanks a lot! Yep, that did the trick!

Assignment in if condition

2020-09-30 Thread ElAfalw
Well, basically what I'm trying to do is something like that: if (let a = getSth()) != 0: echo a Run Is that possible? How?

Disable Warning or Hints from system libraries only?

2020-09-18 Thread ElAfalw
I'm running nim devel. I know how to disable one specific Hint or Warning. The problem is I'm getting many-many warnings and hints, all coming from the Nim libraries (that is: NOT from my code). Is there any way I can disable only these warnings? (So, that I can spot if there is something that

Impact of "UnusedImport"s

2020-09-18 Thread ElAfalw
When building my code, perhaps the most common "hint" is that of UnusedImport. I understand the point. But, is there really any impact on the resulting binary, or could I safely ignore it?

Electron-like app with Nim

2020-09-18 Thread ElAfalw
Basically, this question is more like food for thought. I've been thinking of create a webview-based app (in order to be portable, one code base and all that) but do it in nim. Of course, I know about Electron but it seems to me to bloated (plus, why add Node.js when I don't need it). I've als

how to package C-only project on macOS?

2020-09-10 Thread ElAfalw
Thanks for the suggestion> Regarding shipping binaries, that's exactly what I thought. But look at this one:

how to package C-only project on macOS?

2020-09-10 Thread ElAfalw
Basically, instead of sending out my Nim (and force everyone to install the compiler), I was thinking of just sending out the C code. How to obtain a fully compilable (with everything included) C-version of my project?

Compilation for different macOS version

2020-09-10 Thread ElAfalw
I'm running macOS 10.15. I compiled my binary fine here and sent it to sb else with an older macOS version. He keeps getting the following error: dyld: lazy symbol binding failed: Symbol not found: chkstk_darwin Referenced from: /Users/nkszf/Documents/./testapp (which was

Calling templates with untyped params

2020-09-10 Thread ElAfalw
I have a template like: template doSomething(code: untyped) = ... the template ... Run which I can call like: doSomething: ... my code ... Run What if I want to add an optional param to this template? Like: te

Regex replace with callback?

2020-09-02 Thread ElAfalw
In Ruby there is a way to replace occurences of a given regular expression with the value returned by a callback. For example: s.gsub(/^\d+(\w+)\d+/) { |m| m.upcase } Run which basically takes every "word", surrounded by digits, passes it to the callbac

How to achieve better performance with arc GC?

2020-09-01 Thread ElAfalw
I've been experimenting a bit with the different GC's offered by Nim. >From what I've seen so far, "arc" works _far_ better for me, compared to the >other ones. The question is: what should I focus on in case I want even better performance? Is there any way I can intervene in how it handles the

Trouble using parallel

2020-08-31 Thread ElAfalw
So, any idea?

nimDecRefIsLast and EXC_BAD_ACCESS:

2020-08-29 Thread ElAfalw
I'll give it a try in a minute and I'll let you know!

nimDecRefIsLast and EXC_BAD_ACCESS:

2020-08-29 Thread ElAfalw
I'm getting an EXC_BAD_ACCESS error, related to nimDecRefIsLast: 136 proc nimDecRefIsLast(p: pointer): bool {.compilerRtl, inl.} = 137if p != nil: 138 var cell = head(p) -> 139 if (cell.rc and not rcMask) == 0: 140

Trouble using parallel

2020-08-29 Thread ElAfalw
I'm experimenting a bit with `parallel` (my main goal is to implement a simple parallel loop - that's all). I've imported `threadpool` with `--threads:on` and `{.experimental: "parallel".}`. Here's the code in question: parallel: for item in collection:

Observing value changes

2020-08-29 Thread ElAfalw
Let's say I have a `Table[string,int]` with different values. Is there any way I can "observe" changes to a particular key? I mean, when some key's value is changed to have a specific function executed.

Recognizing non-ASCII characters in lexbase-based lexer

2020-08-27 Thread ElAfalw
So, I've been experimenting a bit with a handwritten lexer, using lexbase - in order to convert an existing project of mine which uses Flex/Bison. For example, when we encounter a character that is in `PermittedIdentifiers_Start`, the appropriate code is executed: template parseIde

Handling in-place functions efficiently

2020-08-27 Thread ElAfalw
Let's say I have a string and want to make it uppercase. I would do: str = str.toUpperAscii() Run Is there any _in-place_ way to do the same? (like Ruby's `str.upcase!`) I'm not particularly interested in the uppercase function. I'm looking for some more... universal

Empty c-style array

2020-08-21 Thread ElAfalw
OK, let's say I have a array-type variable. Is it possible to set it to... nothing? I mean let's say a function takes an array parameter, with some (or no) values. I could obviously declare it as a seq, but then we would deal with memory allocation. I can also declare it as an openArray, and th

Table with different types of values?

2020-08-21 Thread ElAfalw
OK, this is not so important, but I still thing I'm missing something. I want to create a **const** table (meaning: only for compile-time, in order to have things better organised). It's like that: const TABLE = { "key1" : { "param1": "a string

inline vs template vs simple proc

2020-08-19 Thread ElAfalw
What is the real difference in terms of performance and drawbacks? For example, if I have a (relative small, 10-15line) proc, that gets call thousands of times (from 1-2 different locations). Would it be preferable to simply declare it as a template? In which case would you favor what?

observable stores to 'x'

2020-08-18 Thread ElAfalw
I have set up a very simple command line argument parser (with the help of **parseopt** ). However, I keep getting a warning at this line: var x = initOptParser(commandLineParams()) Run Here is the warning: Warning: observable stores to 'x' [Observa

General recommendation for optimum performance?

2020-08-18 Thread ElAfalw
Thanks a lot! Also, @araq, I'll try with the devel branch to see if I notice any difference. Any other suggestions? (I mean unrelated to compiler options)

General recommendation for optimum performance?

2020-08-18 Thread ElAfalw
I'm experimenting a bit with Nim and wondering if there are some general guidelines for speed. For example, I compile with c -d:release -d:danger --gc:arc --opt:speed --checks:off --passC:"-O3 -flto -m64" --passL:"-flto" -o:example example.nim Run Does this look good? An

programmatically create variable in context, using template

2020-08-18 Thread ElAfalw
Stefan, thanks! Great solution.

programmatically create variable in context, using template

2020-08-17 Thread ElAfalw
I don't know if a template is the right way to do it, but this is what I'm trying to do: template doSth(i: int): untyped = if i>=1: let x = "X" if i>=2: let y = "Y" . proc someOtherProc() = doSth(1)

passing 'p.cmds[p.idx]' to a sink parameter introduces an implicit copy

2020-08-14 Thread ElAfalw
Getting the above message when simply using parseopt. Anything I can do about it?

Passing string to C code with --gc:arc

2020-08-13 Thread ElAfalw
I tried calling GC_ref on a cstring, but it doesn't allow me to...

Passing string to C code with --gc:arc

2020-08-13 Thread ElAfalw
I'm trying to pass a Nim string (auto-converted to cstring, I guess) to a C function. The whole thing does work but not consistently (at times, it crashes with " malloc: Incorrect checksum for freed object : probably modified after being freed.") and I imagine it has something to do with th

Object destroyed after editing enum property?

2020-08-13 Thread ElAfalw
I have an object defined like this: Obj = ref object case kind: ObjKind: of typeA, typeB:contents: seq[Obj] else: discard Run Then I create an object like that: example = Obj(kind: typeA, contents: @[some contents])