Where to request code review?

2020-11-03 Thread Yardanico
Hello and welcome! I think that sharing your project here and asking for code review is a good idea :)

Where to request code review?

2020-11-03 Thread kamek
I've just started learning nim in my spare time and have just finished writing my first package. Because I'm learning in a bit of a bubble (I know no one personally that knows nim), I'm looking for feedback online. Where is the best place to ask for that feedback? Is it here? Or perhaps on the c

Passing iterators as arguments

2020-11-03 Thread slonik_az
@cblake: The [original implementation](https://forum.nim-lang.org/t/6649#41330) of `toItr` does not allow for multiple for-loop-variables. The code like `for x,y,z in toItr(points3D("ball")): ...` does not work. Below I reimplemented `toItr` macro to support multiple for-loop-variables:

Sending emails from Nim using SMTP

2020-11-03 Thread mrhdias
Sample app that shows how to send emails with attachments from a web form.

Some questions regarding gc-safety, httpclient and timezones

2020-11-03 Thread GULPF
> The first option looks exactly like what I need. However, do I need to > install some additional libraries to make it work? I am on Pop! OS which is a > derivative of Ubuntu and I have tzdata package installed (not sure if it's > needed at all). But when I use loadPosixTz"Asia/Yekaterinburg" w

How exactly do i start?

2020-11-03 Thread CHEEMS96
That's cool. I just now switched to spacemacs after getting frustrated with vim. I'll figure that out later. Emacs is much easier to use. I plan on understanding the nim syntax so that i can help with the bugs and stuff.

Nim control flow based type analysis

2020-11-03 Thread g5becks
Thanks a lot. Makes sense now.

Nim control flow based type analysis

2020-11-03 Thread Yardanico
You need to use `when` for compile-time conditions: type SomeType[T] = ref object proc echoTuple(tup: tuple) = echo tup proc echoString(str: string) = echo str proc example*[T](data: T): SomeType[T] = when data is string: echoS

Nim control flow based type analysis

2020-11-03 Thread disruptek
Use `when` versus `if`.

Nim control flow based type analysis

2020-11-03 Thread g5becks
I've been searching around for an answer to this and couldn't really find anything. In regards to generics, nim seems to work differntly than what I am used to. In langauges like Kotlin, Typescript, or even Dart - they use control flow based type analysis. So the code below will work just fine

How exactly do i start?

2020-11-03 Thread timothee
> Hi guys, I'm new here and I'd like to contribute to the nim project > how do > the rules work? What's the system of governance here? some issues have been tagged as a good fit for first time contributors: look at

How exactly do i start?

2020-11-03 Thread CHEEMS96
Hi guys, I'm new here and I'd like to contribute to the nim project. I'm just starting to use SpaceVim after deciding that i wasn't going to spend eternity trying to configure my neovim files to make it an IDE (I'm kinda new to vim anyway but I'm learning quickly). Since nim isn't as popular, I'

Passing iterators as arguments

2020-11-03 Thread Sixte
Your example works with copy and paste "out of nothing". I modified the `let par2` accordingly, following @solo989's proposal. I am baffled.

SIGSEGV on Android

2020-11-03 Thread PMunch
Sounds like you might be missing a call to `NimMain` which sets up the GC.

SIGSEGV on Android

2020-11-03 Thread vitaliy
Hi all! I am having a weird problem. Nim code is compiled to a static library and is used inside a React Native project as a native dependency. Some Nim functions defer to code written in Go (being thin wrappers), others provide native Nim implementations. iOS works allright. On Android there

SIGSEGV on Android

2020-11-03 Thread Yardanico
Can you try `--gc:orc`? I think it should fix the problem and it probably comes from the fact that you didn't call `setupForeignThreadGc` (but it's not needed with arc/orc).

Passing iterators as arguments

2020-11-03 Thread cblake
It sounds like his approach might be more general, but mine "just works with stock Nim going back 2 years". Anyway, I think that is a comparison better left to @Timothee. The old chestnut of tail recursive "spelling" of "iteration" obviously makes these things all closely related "up to" syntact

Passing iterators as arguments

2020-11-03 Thread slonik_az
> @cblake: You're welcome, but really do look into algorithm.nextPermutation. > It is probably >10x faster (although that may only translate to "n+1" with a > use that also grows combinatorially.) I chose permutation generator as a useful and short illustration of recursive iterators, nothing m

Virus scanner problems after installing Nim 1.4

2020-11-03 Thread enthus1ast
One way to see what triggers the alarm is the ol 'malware writers trick' to split the binary into small chunks, then let the antivirus scan. If one file is detected split this file again, let it scan again... until you found the content the antivirus thinks it sees a virus, the change this :).

Passing iterators as arguments

2020-11-03 Thread cblake
You're welcome, but really do look into `algorithm.nextPermutation`. It is probably >10x faster (although that may only translate to "n+1" with a use that also grows combinatorially.) Doesn't seem Timothee's pull request or RFC got as far as the symbol name bikeshedding processs. I should maybe

Passing iterators as arguments

2020-11-03 Thread slonik_az
@cblake: Fantastic! This is what I have been looking for. Works like a charm. And seems to be a simpler solution that of @timothee. BTW, any pros and cons of `toItr` vs `iterate` from ?

Handle missing library at runtime?

2020-11-03 Thread PMunch
Well it is certainly possible. But I can't think of an easier way of doing it than creating your own dynamic library which wraps the `db_mysql` part of your program and then conditionally load that in your main program by using the [`dynlib`](https://nim-lang.org/docs/dynlib.html) module.

Passing iterators as arguments

2020-11-03 Thread cblake
@slonik_az, Using only `toItr` from my aforementioned [very close](https://forum.nim-lang.org/t/6649#41330) and regular old "official" Nim 1.4 (earlier works with formerly experimental for loop macros activated), the translation is also almost line for line: proc lex_perm[T](x: se

Idiomatic function call coding style?

2020-11-03 Thread Araq
To turn loopy code into expressions we have the really sweet `sugar.collect`.

Sublime Text user experience

2020-11-03 Thread PMunch
There is a proposed extension to LSP to support semantic highlighting. Hopefully that will get officially included someday (the Vim LSP client already supports this, not sure about Sublime). If we implement that into NimLSP then we would have highlighting as well in the same plug-in.

Idiomatic function call coding style?

2020-11-03 Thread Araq
I like `str.len` much better and wouldn't use `foldl` at all. (I'm still not a fan of FP.)

Idiomatic function call coding style?

2020-11-03 Thread fxn
I hear you wrt foldl! My first implementation was a straightforward `for` loop that anyone understand just by looking at it, vs foldl makes me think for some reason. Finally looked up in the docs how to do it that way, but in normal circumstances I'd write the for loop.

Idiomatic function call coding style?

2020-11-03 Thread PMunch
This is very much a matter of preference. But there are some things that are more common than others. In generally I'd say if you extract a property of something, or if the procedure name sounds like a verb I'd use `.` so I can put the "subject" of the statement to the left. So for example I'd u

Idiomatic function call coding style?

2020-11-03 Thread lqdev
I think `str.len` is more common, but there isn't anything wrong with using `len(str)`. Use whichever one you prefer :)

Idiomatic function call coding style?

2020-11-03 Thread fxn
Ah! the "symmetry" in min(a, b) is a good point vs having a distinguished first argument.

Idiomatic function call coding style?

2020-11-03 Thread doofenstein
the way I usually go about this is: to use dot calls for cases when a function "belongs" to an object (like in the object oriented sense). to use normal calls for cases where all parameters are "equal" (e.g. min(a, b), distance(a, b), intersection(first, second)). Though yeah it all comes down

Idiomatic function call coding style?

2020-11-03 Thread fxn
Hi! I am learning Nim via exercism.io, and find myself doubting about the function call style. Take this exercise, for example: import math, sequtils # We are going to exploit that digits 0-9 are consecutive in ASCII. const ord0 = ord('0') func isArmstrongNumber

Running fzf from nim (again)

2020-11-03 Thread polm23
Thank you, I saw ff but to be honest I have difficulty following how it works with SELECT and I don't dev on Windows... The first thing I did that worked was write the output to a file. While that got the desired output, it wasn't exactly what I wanted. The proc that gives output to fzf takes a

Virus scanner problems after installing Nim 1.4

2020-11-03 Thread Clonk
> > I would prefer linux, but the laptop is so slow Have you tried using WSL on your Windows 10 laptop ? I've been using it almost exclusively for 2 years now on work issued Windows 10 laptop and it's quite good at giving you a Linux environment inside a Windows machine. * VSCode supports WSL