Permission Error when trying to compile a Nim program

2018-02-18 Thread SolarLune
Hey, there. I'm getting a permission error when I go to compile a program built in Nim. I can compile fine if I use sudo nim, but that makes me enter the password each time into Visual Studio Code, so I'd rather not have to do that. Any advice? Here's the error in full:

Re: color text output in nimble

2018-02-18 Thread sflennik
Thanks. My problem was using the wrong escape code. Here are some examples of showing [Suite] in bold blue. Python: python -c "print '033[1;34m[Suite]033[0m'" Nim: echo "e[1;34m[Suite]e[00mn" Bash: printf "e[1;34m[Suite]e[00mn"

Re: Sorting

2018-02-18 Thread twetzel59
Ok.

Re: Module logging: how to create the right Logger(s) in a library?

2018-02-18 Thread cumulonimbus
Araq, you are doubtlessly correct in that the right way to do it is a hook that receives structured data. Perhaps there is something worth putting in the standard library even in this case (e.g., an easy, consistent way to timestamp and mark severity - even if only as a concept). Nevertheless,

Re: Strings and C.

2018-02-18 Thread DTxplorer
That makes sense.

Re: How do you get an "IpAddress" from a hostname?

2018-02-18 Thread monster
In case anyone cares, this how I eventually did it: let first = hostent.addrList[0] let a = uint8(first[0]) let b = uint8(first[1]) let c = uint8(first[2]) let d = uint8(first[3]) let ipstr = $a & "." & $b & "." & $c & "." & $d try: ip =

Re: Getting a NimSym from an nkIdent?

2018-02-18 Thread StasB
That works. Thank you! I think I'm starting to get the picture of how it works. Speaking of the VM, is there an approved way to instantiate and use it at runtime, or does it involve mucking about with the compiler source code?

Re: Sorting

2018-02-18 Thread Araq
Yeah we probably need to offer a sort that inlines the comparator. That said, I have seen the C compilers remove indirect calls if they can prove the jump destination (and for `sort` that is actually rather easy to determine).

Re: Optimizing file I/O

2018-02-18 Thread Araq
Your Python program runs once over the input, your Nim program twice. If I read it correctly.

Re: Getting a NimSym from an nkIdent?

2018-02-18 Thread Araq
The VM is not allowed to perform symbol lookups. If you pass `someProc` to a `typed` macro parameter you should be able to inspect the symbol(s) though.

Re: Nim Dogfooding

2018-02-18 Thread Araq
Email notification used to work but got broken when we moved to HTTPS iirc. Not sure what it takes to fix it. > But, well, does anyone maintain the repo? Issues and PRs opened in 2015 are > still there :/ I am afraid to just do the job which will never be merged. Yes, we do maintain it. The

Re: color text output in nimble

2018-02-18 Thread Araq
On Unix you can write escape sequences, it doesn't need NimScript support. On Windows escape sequences can be enabled for a terminal too, but it's not the default and the API call to enable it is not avaiable for Nimscript either.

Re: Optimizing file I/O

2018-02-18 Thread Stefan_Salewski
As you may have found out yourself already, when I was talking about replace() proc I had in mind this type of replace: var s = "This is a test" s[5 .. 6] = "was" echo s For finding the start and end position you may use find proc searching for ',' or whatever is

Re: Strings and C.

2018-02-18 Thread Stefan_Salewski
It is generally a bad idea to send the whole seq to C function because there may reside additional data like seq length at start of memory chunk. Try to use address of first element of the sequence instead.

Re: Strings and C.

2018-02-18 Thread DTxplorer
Thanks again cdome. I have another question with C but I want to avoid polluting the homepage with noobish topics. And strings are kind of sequence isn't it ? I want to pass a sequence to a C function but the result is unexpected. Two files for minimal example. proc

Re: Optimizing file I/O

2018-02-18 Thread Lando
The [blog entry about profiling etc.](https://nim-lang.org/blog/2017/10/02/documenting-profiling-and-debugging-nim-code.html#profiling-with-valgrind) might help. Here's the short version: If your'e on Windows: can't help you. Maybe try Linux Subsystem for Windows 10. If your'e on MacOs or

Re: Fatal compilation error on Windows

2018-02-18 Thread amalek
Yeah, I suspected as much. In fact, I was compiling the project from the command line with the nim executable. I'll have to see if compiling from an IDE actually changes things.

Re: Optimizing file I/O

2018-02-18 Thread Stefan_Salewski
It should be clear that your code is not IO bound. You are using split(), which creates a seq of substrings for each call. Of course such operation is expensive, as for each call a new seq is allocated, and for each entry in the seq a string is allocated. If performance is really a concern,

Optimizing file I/O

2018-02-18 Thread aedt
As a new user, I'd love to know about I/O optimization techniques for Nim. Hence, I have this simple function for [https://www.fluentcpp.com/2017/09/25/expressive-cpp17-coding-challenge/](https://www.fluentcpp.com/2017/09/25/expressive-cpp17-coding-challenge/). import os, strutils