Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread SolitudeSF
there is no split iterator that returns two values at a time. you're confusing it with sequence and implicit pairs. you have to keep track of the indexes on your own here.

Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread freeflow
On further reading it seems there is a split proc and a split iterator. The former returns a sequence of substrings. The code I have seems to be using the iterator version. How would I indicate to nim to use the proc rather than the iterator version of split?

Re: Compilation failure 1.0.4 on Pi3

2020-01-13 Thread blippy
I'm using Raspbian on a Pi3 (and Pi2). The version of nim in the repo is fairly old. I'm now just going with the simplest solution: using the nightly build that I indicated above. It works, so I'm happy. I'm using GCC v 8.3.0 on the Pi 2 and 3. I do most of my work on an x84_64.

GitHub Actions to lint Nim code

2020-01-13 Thread jiro4989
I wrote a GitHub Actions to lint Nim code. nimlint-action is inspired by [reviewdog/action-eslint](https://github.com/reviewdog/action-eslint). [https://github.com/jiro4989/nimlint-action](https://github.com/jiro4989/nimlint-action) This action notices compile message to Pull Request. Exam

Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread SolitudeSF
invoke items/pairs iterator explicitly

Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread sky_khan
Sorry for being lazy earlier and for my poor English. What I meant was this: import strutils var file = """ Hello,World Key,Value """ for line in file.split("\n"): # iterator returns string var data = line.split(",") # proc returns s

Re: Setup Nim with Vim/NeoVim

2020-01-13 Thread leorize
As a shameless plug, but I made one of the most featureful Nim plugin for neovim :) Check it out at [https://github.com/alaviss/nim.nvim](https://github.com/alaviss/nim.nvim)

Re: new experimental nim plugin for neovim

2020-01-13 Thread mikebelanger
Still using this plugin lots - and works great! One thing I'm wondering about is opening and closing sections. It's nice to have top-level things collapsed when a file is first opened, and I can just open the section I'm interested in. Only thing is, I'm not sure how to close a section after it

Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread freeflow
I'll have to wait until my knowledge of nim improves before I can that. In the meantime I'm using let mySeq:seq[string]=readFile(day02PathAndName).split(',') for myKey, myValue in mySeq: result[myKey.int64]=myValue.parseint.int64 Run

Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread Araq
Seems to be a use-case for Nim's csv parser, [https://nim-lang.org/docs/parsecsv.html](https://nim-lang.org/docs/parsecsv.html)

Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread freeflow
It might be more productive if I advise you that I spent several days perusing the nim documentation before I admitted defeat and asked a question here. @Solitude's comments highlighted something that is not adequately referenced when you read the for loop section of the manual.

Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread freeflow
Aha: success for myKey, myValue in readFile(day02PathAndName).split(',').pairs(): result[myKey.int64]=myValue.parseInt Run

Re: missing rules in grammars.txt

2020-01-13 Thread Araq
Sorry, I made it a showstopper bug, will be fixed anytime soon now.

Re: new experimental nim plugin for neovim

2020-01-13 Thread leorize
`zf` is for creating fold :) To close one you use `zc`. See `:h fold-commands` for further folding magic.

Re: Introducing --gc:arc

2020-01-13 Thread leorize
> At present I can get cligen things (like that example bench above) to compile > and run ok, but with gc:arc invoking with --help raises a HelpOnly exception > that then dumps core. Current runtime seems to think the exception is > unhandled. (Haven't looked into it further.) [https://github.c

Re: Setup Nim with Vim/NeoVim

2020-01-13 Thread blippy
One thing I really hate about Nim is its use of whitespace, particularly in regards for disallowing tabs. I've been going pluginless for a couple of years now, and want to keep it that. I like to be able to get my installations from 0 to working in as little time as possible. For some reason, I

Re: Setup Nim with Vim/NeoVim

2020-01-13 Thread leorize
Nowadays, with vim 8 & neovim's `packages` feature (see `:h packages`) it has never been easier to maintain a full setup that you can just clone from your git and got everything working right after :) > For some reason, I couldn't get vim embedded instructions to do the tabs > properly. I don't

Re: new experimental nim plugin for neovim

2020-01-13 Thread mikebelanger
Ah ok, thanks :)]

Re: stdlib pegs: Accessing optional subexpressions

2020-01-13 Thread sschwarzer
Thanks! I had heard of `npegs`, but so far chose `pegs` because it's in the standard library and understands standard PEG syntax. That said, `npeg`'s features are very impressive. :-) > Afaik, stdlib peg is designed for nim compiler itself and somewhat limited. So I guess there's not much moti

Re: new experimental nim plugin for neovim

2020-01-13 Thread leorize
A [demo](https://asciinema.org/a/276278) on debugging in neovim: \-- I made this a long time ago, but forgot to share it on the forums.

How do I initialize a set of range?

2020-01-13 Thread tobia
This code: let somePrimes: set[1..10] = {2, 3, 5, 7} Run gives: Error: type mismatch: got but expected 'set[range 1..10(int)]' Run How do I initialize a set of range?

Re: How do I initialize a set of range?

2020-01-13 Thread Araq
Like so: type OneTo10 = range[1..10] let somePrimes = {2.OneTo10, 3, 5, 7} Run

Re: Introducing --gc:arc

2020-01-13 Thread Araq
> fully document this change. I'm waiting for a bug report because I bet it is a bug and not the deliberate choice to map IndexError et al to quit. Consider that code that catches these errors already was broken with `-d:danger` too and for years `-d:release` was what is now `-d:danger`.

exportc pragma and ref object

2020-01-13 Thread jdn
When I compile the following code: import strutils type Token {.exportc.} = object typ: cint val: cstring proc exportc(a: Token) {.exportc.} = let msg = "Token (type, value): ($1, $2)" % [$a.typ, $a.val] echo msg Run

Re: Introducing --gc:arc

2020-01-13 Thread cblake
Well, changing to inherit from `CatchableError` did not alone fix things (though that is clearly a thing I should have done long ago, and I think separating bugs from unusual control flow is a Good Thing). I did catch these when compiled with `-d:danger/-d:release` for the past 2.5 years, though

Is this expected behaviour?

2020-01-13 Thread dawkot
var x {.compileTime.} = false static: x = true echo x Run > false