Re: More convenient awk-style text processing with Nim

2020-06-12 Thread kaushalmodi
> includes a convenience iterator, rows,

Looking at your example code, I think that `rows` should be `cols`? Because in 
your example, `r[0]` points to the first field or column and `r[1]` points to 
the second?


Re: What is -> in Nim?

2020-05-29 Thread kaushalmodi
I have some notes on that "proc type" syntactic sugar `->` here: 
[https://scripter.co/notes/nim/#proc-type-sugar](https://scripter.co/notes/nim/#proc-type-sugar)


Re: Doc generation fails

2020-05-28 Thread kaushalmodi
This issue is now fixed on devel, but there's another regression with `nim doc` 
\+ `runnableExamples`: 
[https://github.com/nim-lang/Nim/issues/14485](https://github.com/nim-lang/Nim/issues/14485)
 .


Re: Is there a command line one-line to start an HTTP server using Nim?

2020-05-28 Thread kaushalmodi
After 
[https://github.com/enthus1ast/nimAsyncHttpTools/pull/2](https://github.com/enthus1ast/nimAsyncHttpTools/pull/2),
 `simplehttpserver` compiles and runs well on my machine (RHEL 6.8).


Re: Is there a command line one-line to start an HTTP server using Nim?

2020-05-28 Thread kaushalmodi
@bung You do not have an Issues section on your fork. I wanted to ask you if 
the dependency on libzip can be made optional? (See [my message 
above](https://forum.nim-lang.org/t/6386#39399) ). The original `nimhttpd` 
builds and runs fine on my machine (RHEL 6.8), but trying to run your fork 
fails as I don't have the needed `libzip`.


Re: Is there a command line one-line to start an HTTP server using Nim?

2020-05-28 Thread kaushalmodi
Awesome! That is the winner!

@Araq It would be now cool to bake that into nim :)


Re: Is there a command line one-line to start an HTTP server using Nim?

2020-05-28 Thread kaushalmodi
OK, it builds find after uninstalling `zip` and doing `nimble install 
zip@#head`.

So the correct fix is:

  1. Cut a new release of the `zip` nimble package
  2. Cut a new release of your `finder` package with updated zip version in its 
dependency
  3. Finally update your `static_server` package with updated finder version in 
its dependency




Re: Is there a command line one-line to start an HTTP server using Nim?

2020-05-28 Thread kaushalmodi
ok. .now it compiles, but doesn't run:

> could not load: libzip(|2).so(|.4|.2|.1|.0)

I'll have to figure this out later. I am using an admin managed OS, a very old 
OS: RHEL 6.8 (Linux).


Re: Is there a command line one-line to start an HTTP server using Nim?

2020-05-28 Thread kaushalmodi
I tried your repo as well. I cloned it and did `nimble build`, but it failed 
with this: [http://ix.io/2nAa/text](http://ix.io/2nAa/text)

It looks like the `psutil` dependency needs to be updated for a backward 
incompatible change that happened in nim 1.0.0. Now we have `isDigit` taking 
only `char` arg, not `string`.

I'll open a PR on `psutil` to fix this.


Re: Is there a command line one-line to start an HTTP server using Nim?

2020-05-28 Thread kaushalmodi
The aim of my post was if there's a way that Just Works for kicking off an 
adhoc server, like `python3 -m http.server` does, **and** then have that baked 
into nim as well.


Re: Is there a command line one-line to start an HTTP server using Nim?

2020-05-28 Thread kaushalmodi
Hello, I cloned your repo and did `nimble build`. It failed with this error: 
[http://ix.io/2nA6/text](http://ix.io/2nA6/text)

I am using the latest nim devel.


Is there a command line one-line to start an HTTP server using Nim?

2020-05-27 Thread kaushalmodi
Using python, one can trivially fire off an HTTP server to serve the files from 
the current directory using:


python3 -m http.server


Run

Is there an equivalent one-liner for Nim?


Re: Can I "prune" directories with walkDirRect?

2020-05-27 Thread kaushalmodi
Wow!.. why is it in **cligen** though? It looks like it can be a separate 
`find`-competition package :)


Re: Doc generation fails

2020-05-27 Thread kaushalmodi
I have reported this in issue 
[https://github.com/nim-lang/Nim/issues/14473](https://github.com/nim-lang/Nim/issues/14473)
 . Thanks for providing that minimal example.


Re: Doc generation fails

2020-05-27 Thread kaushalmodi
I have seen a similar issue on nim devel too. I am trying to create a 
reproducible example for that.

I also see runnableExamples trying to get executed from sequtils.. My Nim 
module does import sequtils, but there are no runnableExamples in it.

Also, I think this issue happens when I have \--path switches in my config.nims 
.. the nim doc doesn't seem to find modules that are specified via \--path or 
\--NimblePath. It only recognizes packages installed in the default ~/.nimble.


Re: Doc generation fails

2020-05-27 Thread kaushalmodi
This happens on nim devel (the version should be 1.3.5). I see that you are 
using nim stable 1.2.0.


Re: GitHub Actions: workflow to cross compile and release to GitHubRelease

2020-05-22 Thread kaushalmodi
It's on my list to learn GitHub Actions. I just had a comment about the 
NimScript task archive. You can put that into a global config.nims of yours 
which you pull in before building all of your projects.

I have started using [this minimal 
config.nims](https://github.com/kaushalmodi/version/blob/master/config.nims) in 
my new projects. The project's [.travis.yml then pulls 
in](https://github.com/kaushalmodi/version/blob/09100e7d619e8b681bb794d7b38d2b66e23a8af9/.travis.yml#L60)
 my [global 
config.nims](https://github.com/kaushalmodi/nim_config/blob/master/config.nims) 
which enables running my generic tasks using nim docs, nim musl .. and nim test.


Re: Checking the gcc/g++ versions used to compile nim program vs the dyn linked .so

2020-05-20 Thread kaushalmodi
Turns out that this issue was because of some mixup in the LD_LIBRARY_PATH. 
Once was was fixed, the nim program built with even g++ 9.1.0 links fine with 
the external_lib_64.so built with g++ 6.3.0.


Checking the gcc/g++ versions used to compile nim program vs the dyn linked .so

2020-05-20 Thread kaushalmodi
Hello,

Today I came across this run time error when running a nim compiled program 
that dynamically linked with an external c++ library .so (let's call it 
`external_lib_64.so`)


could not load: external_lib_64.so
compile with -d:nimDebugDlOpen for more information


Run

So I compiled and ran the nim program with `-d:nimDebugDlOpen` and still that 
did not give any useful information.

I knew that the `external_lib_64.so` was compiled using g++ 6.3.0. By a stroke 
of luck, it occurred to me that may be I should check the g++ version in my 
current environment where I was compiling the nim program .. and indeed it was 
different; it was g++ 8.4.0.

Once I switch to g++ 6.3.0, re-compiled the nim program and ran it, that "could 
not load: external_lib_64.so" error went away and things once again ran fine as 
before.

**Questions to the community:**

  * Should we need to match the g++ versions this way all the time? I thought 
that the compiled external_lib_64.so was "bulletproof" now that it was 
compiled. But apparently not?
  * @Araq Is it possible for the Nim compiler to detect this g++ version 
mismatch and throw a better error?



This was using the latest stable nim 1.2.0.


Re: Conflict of nfatype.Regex and nre.Regex

2020-05-15 Thread kaushalmodi
glob anyways imports the regex module ( 
[https://github.com/nitely/nim-regex](https://github.com/nitely/nim-regex) ). 
So you might as well just use that instead of importing nre.

nre will introduce a dependency on PCRE on your app, while the nim-regex module 
won't.


Re: Markdown test

2020-05-13 Thread kaushalmodi
Thanks, except for those bold/italics, other rendering (especially the Markdown 
link syntax) is nicely supported in the newer nimforum version: 
[https://forum.my-toolbox.xyz/t/6](https://forum.my-toolbox.xyz/t/6)


Markdown test

2020-05-13 Thread kaushalmodi
Testing quote block:

> some quote


echo "hello"


Run

_[Italics](https://forum.nim-lang.org/postActivity.xml#italics)

**Bold**

_ **Bold and italics** _

[Nim website]([https://nim-lang.org](https://nim-lang.org))

## heading level 2

## heading level 3


Re: runnableExamples Question

2020-05-11 Thread kaushalmodi
This is now fixed in nim devel. Now I auto-generate the docs for Std::Vector 
Nim wrapper ( 
[https://github.com/kaushalmodi/std_vector](https://github.com/kaushalmodi/std_vector)
 ) to 
[https://kaushalmodi.github.io/std_vector](https://kaushalmodi.github.io/std_vector)/
 .


Re: runnableExamples Question

2020-05-08 Thread kaushalmodi
@timotheecour has this feature addition in a pending PR in 
[https://github.com/nim-lang/Nim/pull/14278](https://github.com/nim-lang/Nim/pull/14278)
 . It should be merged soon it seems :)


Re: Nim's strutils.split() slower than Python's string split()?

2020-04-25 Thread kaushalmodi
@krtekz Awesome! Also make sure you share your optimized final code here for 
anyone who ends up on this thread in future :)


Re: What's the most favourable way to get documentation as an automated process?

2020-04-23 Thread kaushalmodi
@shashlick Did you have something in works that generated JSON Nim docs?


Re: How to write shell scripts in Nim

2020-04-05 Thread kaushalmodi
I have a bit involved NimScript: 
[https://github.com/kaushalmodi/nim_config/blob/master/config.nims](https://github.com/kaushalmodi/nim_config/blob/master/config.nims)

See if going through it and referring to docs helps you. 


Re: Nim 1.2 is here

2020-04-03 Thread kaushalmodi
> I think it's for reducing unneeded allocations? Is it correct?

That would be my guess. But I am not on expert on that. Hopefully someone else 
can give a thorough answer for that.

> dup stands for "duplicate"?

Yes.


Re: Nim 1.2 is here

2020-04-03 Thread kaushalmodi
I have taken the `dup` example from the 1.2 release notes and have refactored 
it a bit to help better explain this feature: 
[https://play.nim-lang.org/#ix=2gxD](https://play.nim-lang.org/#ix=2gxD)

Basically the `dup` macro helps **resuse** a proc that had (1) mutable arg and 
(2) no return type to be used as a proc with (1) immutable arg, and (2) return 
type same as the arg type.


Re: Announcement: The Nim compiler is rewritten in Python with some modules optimized in C

2020-04-01 Thread kaushalmodi
Read that post, peek at the calendar and have a laugh ;-)


Re: ggplotnim - pretty native plots for us

2020-03-22 Thread kaushalmodi
ggplotnim is an amazing library and @Vindaar's support has been excellent! I 
have been using it in a convoluted (pun intended) way -- using to plot FFT's of 
analysis done in MATLAB via its exported-to-C libs importc'd into Nim. 


Re: examples or documentation of Source Code filters

2020-03-21 Thread kaushalmodi
It can be used to generate any templated file you like. I have used it to 
generate SystemVerilog and HTML files.

What are you trying to achieve and where do you need help with the Source Code 
Filters? 


Re: FFI: how to avoid naming arguments in C functions

2020-03-08 Thread kaushalmodi
Also related to your C library wrapping project, have a look at 
[https://github.com/nimterop/nimterop](https://github.com/nimterop/nimterop).

Using that, I have successfully wrapped quite a few C libraries, and this is 
coming from someone who has never coded in C (of course, some learning curve is 
involved, but the community and the nimterop developer shashlick/genotrance was 
very helpful as I was learning to use nimterop). 


Re: FFI: how to avoid naming arguments in C functions

2020-03-08 Thread kaushalmodi
Related to your plotting application, also have a look at ggplotnim: 
[https://github.com/Vindaar/ggplotnim](https://github.com/Vindaar/ggplotnim) .

It helps me make things like:


Re: Nested list comprehension

2020-03-06 Thread kaushalmodi
> how about you first get familiar with the correct Nim syntax for them? link

Wait, you are linking against the deprecated lc syntax.

I believe the closest non-deprecated solution is 
[https://github.com/alehander92/comprehension](https://github.com/alehander92/comprehension)
 ?


Re: Nim's float issue?

2020-02-25 Thread kaushalmodi
Wow! I didn't know of [https://float.exposed/](https://float.exposed/). Cool 
website!


Re: Nim's float issue?

2020-02-25 Thread kaushalmodi
Your answer was nice but I think you it was equally helpful without:

> It's a bit hard to believe that this is a serious question because of..

and

> But maybe you missed that and have no CS experience.

I think most people would have stumbled across this in one programming language 
or another. 


Re: Generate XML file with xmltree [nesting format issue]

2020-02-24 Thread kaushalmodi
I have attempted to fix this issue in this PR: 
[https://github.com/nim-lang/Nim/pull/13482/files](https://github.com/nim-lang/Nim/pull/13482/files)

XML/xmltree experts: Please review that PR and help me make it better!


Re: Generate XML file with xmltree [nesting format issue]

2020-02-24 Thread kaushalmodi
It's probably because you are using `newXmlTree` for both **channel** and 
**rss** tags. May be you should use `newElement` for **channel** too?

_PS: I am just guessing; I haven 't used this library._


Re: Pipe operator in Nim

2020-02-16 Thread kaushalmodi
In case you weren't aware you can indent . chaining in Nim like this too if you 
like: [https://play.nim-lang.org/#ix=2bRv](https://play.nim-lang.org/#ix=2bRv)


Re: I made a simple tutorial on how to create a CLI with Nim

2020-02-08 Thread kaushalmodi
> slightly less flexibility Re help messages.

Now you're just being modest. `cligen` is awesome!! I can't think of starting a 
new CLI project without cligen now. What "slight less flexibility"? It has much 
more flexibility than I can think of (this is a compliment) :)


Re: Nim 1.0.6 is out!

2020-01-28 Thread kaushalmodi
Oops! In hurry, I pointed to a 1.0.6 nightly build.


Re: Nim 1.0.6 is out!

2020-01-28 Thread kaushalmodi
Windows builds are also done. Try this few days older nightly build which has 
windows too: 
[https://github.com/nim-lang/nightlies/releases/tag/2020-01-23-version-1-0-89b39ee](https://github.com/nim-lang/nightlies/releases/tag/2020-01-23-version-1-0-89b39ee)


Re: runnableExamples Question

2020-01-27 Thread kaushalmodi
Yeah that's a local hack (that works).. the back is in the associated closed PR.

The real fix is pending because I don't know yet how to add the `--backend` 
switch just to the `doc` subcommand. 


Re: runnableExamples Question

2020-01-27 Thread kaushalmodi
I needed this feature few weeks back and opened this issue: 
[https://github.com/nim-lang/Nim/issues/13129](https://github.com/nim-lang/Nim/issues/13129).

It's on my list to try to implement the suggested `-backend` switch for `nim 
doc` that uses the specified backend for compiling and running the 
runnableExamples and :test: code block examples. 


Re: How to find the path to nim lib from the command-line

2020-01-24 Thread kaushalmodi
Yes, that code relies on the directory containing the nim binary (usually bin/) 
and the Nim lib/ directory to have the same parent directory.

But the PR that timothee has submitted should resolve that issue. 


Re: How to find the path to nim lib from the command-line

2020-01-23 Thread kaushalmodi
I do it this way: 
[https://scripter.co/notes/nim/#nim-stdlib-path](https://scripter.co/notes/nim/#nim-stdlib-path)


Re: What is the keyword "end" reserved for?

2020-01-16 Thread kaushalmodi
**end** is used (and required for `if`) in the [Nim Source Code 
Filters](https://nim-lang.github.io/Nim/filters).


Re: Nim wrapper for C++ std::vector? [request]

2020-01-10 Thread kaushalmodi
I made some progress! @mratsim, the `[]` proc imports from your snippet proved 
very useful. I can finally loop through the `Vector` values.

The only puzzle is.. how do I use the `VectorIterator` imported from the vector 
lib?

My updated wrapper: 
[https://play.nim-lang.org/#ix=271H](https://play.nim-lang.org/#ix=271H)


Re: Nim wrapper for C++ std::vector? [request]

2020-01-10 Thread kaushalmodi
@deech

Thanks. That will serve as a useful reference. I looked through it, but it 
doesn't give an example on how to use the `vector::iterator` type.

Just by fluke, I replaced the `begin` and `end` proc types to be `ptr T` 
instead of the iterator, and it returns the begin and end pointers.. though I 
don't know yet how to use create an iterator in Nim for the `Vector`.

My attempt so far: 
[https://play.nim-lang.org/#ix=271v](https://play.nim-lang.org/#ix=271v)

@mratsim: Thank you for sharing the "roll your own"; seems like I started off 
the same path (see above link). I am though stuck at how to use the 
`VectorIterator`.

Thanks for all the help.


Re: Nim wrapper for C++ std::vector? [request]

2020-01-10 Thread kaushalmodi
Also, this construct:


type
  Vector* {.importcpp: "std::vector", header: "vector".} [T] = object


Run

gives this warning:

> Warning: pragma before generic parameter list is deprecated [Deprecated]

What is the right way to import that type so that I do not get that warning?


Re: Compilation error after upgrade to 1.0.2 from 0.19

2020-01-09 Thread kaushalmodi
This works on the latest Nim release (should work on 1.0.2 too): 
[https://play.nim-lang.org/#ix=26Zl](https://play.nim-lang.org/#ix=26Zl)


Nim wrapper for C++ std::vector? [request]

2020-01-09 Thread kaushalmodi
Hello,

Has anyone written a Nim wrapper for the C++ std::vector library (even 
incomplete)?

I started putting it together using bits and pieces I found from googling, but 
as I don't know C++, I reached a roadblock very soon when I tried to map the 
std::vector::iterator and associated procs like begin and end. 


Re: Advent of Nim 2019 megathread

2019-12-07 Thread kaushalmodi
My first time participating in Advent of Code! 
[https://github.com/kaushalmodi/aoc2019](https://github.com/kaushalmodi/aoc2019)
 :)


Re: Help with set

2019-12-05 Thread kaushalmodi
> there is not need in auto inferring, since type of x well-known before, and 
> it can not be changed implicitly by Nim rules.

It's the job of the compiler to ensure that the type of the value on right hand 
side matches with the type on left hand side.

I cannot rely on the user always doing the Right Thing. It's quite likely the 
error we see in your second example is a real error because the user put 
non-int16 values in the set by mistake :)


Re: Help with set

2019-12-05 Thread kaushalmodi
> why does it work with char?


Re: Help with set

2019-12-05 Thread kaushalmodi
Nim is a compiled language. So at the time of compilation, it checks if the 
value assigned to a variable fits the type of the variable in the declaration.

Nim auto-infers the type looking at the **right hand side** of an assignment.

So ..


type
  CharSet = set[int16]


Run

Nim: OK, you defined a type CharSet that's expected to be a set of only int16 
type elements


var
  x: CharSet


Run

Nim: OK, you **declared** an x variable of type CharSet


x = {1..9, 15, 45..78}


Run

Nim: _[sees](https://forum.nim-lang.org/postActivity.xml#sees) {1..9, 15, 
45..78}.. hmm the value is a set of ints (because the literal **1** (the first 
element) is of type int), but... the left hand side x expects a set of int16!! 
Abort .. abort ..

\---

Instead ..


x = {1.int16..9, 15, 45..78}


Run

Nim: _[sees](https://forum.nim-lang.org/postActivity.xml#sees) {1.int16..9, 15, 
45..78}.. hmm the value is a set of int16s (because the literal **1.int16** 
(the first element) is of type int16), and... the left hand side x also expects 
a set of int16! We are good :) 


Re: Help with set

2019-12-05 Thread kaushalmodi
Specifying the type only for the first literal also works.. 
[https://play.nim-lang.org/#ix=23CE](https://play.nim-lang.org/#ix=23CE).


Re: Get nimble file directory from within nimble file hook

2019-11-20 Thread kaushalmodi
Can you show with an example where the "original directory" is, where the 
.nimble is, and what path you are trying to get? 


Re: difference between ; and , as proc parameter separator

2019-11-17 Thread kaushalmodi
See the first 3 examples in 
[https://nim-lang.github.io/Nim/manual#procedures](https://nim-lang.github.io/Nim/manual#procedures).

`;` is used to explicitly break the type propagation. In most use cases though 
(when not using `using`), there's not much distinction between `;` and `,`.


Re: Array vs tuple for procs returning multiple values of same type

2019-11-16 Thread kaushalmodi
I'd just use a tuple or object for that. 


Re: Nimdoc: example of nimscript

2019-11-14 Thread kaushalmodi
I have few NimScript tasks which you can see in my repo's README: 
[https://github.com/kaushalmodi/nim_config/blob/master/README.org#list-available-tasks](https://github.com/kaushalmodi/nim_config/blob/master/README.org#list-available-tasks)

Those tasks are defined in the config.nims in that repo.

> Emacs editor was replaced with lem

That's sad. 


Re: ``Table.take`` should be ``Table.pop`` -- discuss

2019-11-13 Thread kaushalmodi
+1 for pop. 


Re: how return false or value?

2019-11-08 Thread kaushalmodi
Have a look at 
[https://nim-lang.github.io/Nim/options](https://nim-lang.github.io/Nim/options)
 .


Re: A super newbie git-related question

2019-11-08 Thread kaushalmodi
> git rebase is much better than git merge for branches because it keeps the 
> history clean.

Yes, please do not do merges if the commit history can be linear (using 
rebases, cherry picks, etc). 


Re: Using Shared Libraries written in Nim via FFI

2019-11-06 Thread kaushalmodi
I have ended up with the same set of questions today. Hopefully someone can 
answer. 


Re: Nim equivilent of Python's slicing with step list[start: end: step]

2019-11-03 Thread kaushalmodi
If you use countUp in the loop, it will optimize your code a bit as it accepts 
the step size. 


Re: Creating a type that is a non-contiguous subset of char?

2019-10-30 Thread kaushalmodi
May be something like this?

[https://play.nim-lang.org/#ix=20nQ](https://play.nim-lang.org/#ix=20nQ)


Re: Why aren't uin64 and usize ordinal types?

2019-10-01 Thread kaushalmodi
Nim internally has an int128 to fully handle uint64. Now to fully support 
uint128, it will need an internal int256! :P


Re: Lambdas?

2019-09-28 Thread kaushalmodi
Being a Lisp fan too (Nim fan of course), I have a section for ["Lambdas in 
Nim"](https://scripter.co/notes/nim/#lambda) in my Nim notes. 


Re: How do nim users who have some proficiency in Lisp compare the two?

2019-09-28 Thread kaushalmodi
> How do nim users who have some proficiency in Lisp compare the two?

As @Libman said, they are quite different. But you do see hints of Lisp in Nim 
here and there. Some examples: the way the AST parsing of Nim happens, and that 
it can be represented as a Lisp expression (See 
[lispRepr](https://nim-lang.github.io/Nim/macros#lispRepr%2CNimNode)), Nim 
templates can be redefined as you can do lisp expressions, you can easily 
introspect the types of variables and procs, as you can do in lisp. I even 
started this fun project [elnim](https://github.com/kaushalmodi/elnim).

> Are there any Lisp developers here who have used both in earnest?

I got exposed to lisp as I use Emacs and I loove hacking in Emacs-Lisp to make 
Emacs do whatever I want. And I have used Nim to replace bash and Python for 
me. More importantly, it has found a unique spot at my work where I use Nim as 
an interfacing language between C/C++ and SystemVerilog.

\---

Hey @rayman22201, thanks for the mention :) Yep, my website source is in Org 
mode. 


Re: Newbie experience with the documentation

2019-09-28 Thread kaushalmodi
You got the colon and parens in reverse order.

But I came to say here this. Once you know the consistent style of proc 
signatures, it's really easy to search for things.

The procs are defined as:


proc foo(arg1: Type1; ..): ReturnType =


Run

So to search for procs returning that ReturnType, you just search for `): 
ReturnType`.


Re: Nim source size

2019-09-27 Thread kaushalmodi
On Linux, I just run this for deploying Nim at work: 
[http://ix.io/1X9Y/bash](http://ix.io/1X9Y/bash)

It results in a meager 19MB install size.


Re: How to change C compiler globally on Linux?

2019-09-26 Thread kaushalmodi
> seems weird to me that they are closed even though it still doesn't work.

I think you should open new issues with recipes to reproduce the problem. 


Re: How to change C compiler globally on Linux?

2019-09-25 Thread kaushalmodi
I'm on RHEL 6.8. I put a `config.nims` in `$XDG_CONFIG_HOME/nim/` and that 
works fine.


Re: The Practical Dev section

2019-09-16 Thread kaushalmodi
This post is probably referring to 
[https://dev.to/t/nim](https://dev.to/t/nim). 


Re: Split on whitespace except for between quotes

2019-09-07 Thread kaushalmodi
Assuming that that input is from the command line, you can use the inbuilt 
commandLineParams() instead of manually parsing it (example in my notes: 
[https://scripter.co/notes/nim/#command-line-parameters)](https://scripter.co/notes/nim/#command-line-parameters\)).

Though, I use the **cligen** package from Nimble for my CLI parsing needs in 
general for much more CLI arg and switch parsing and auto doc support. 


Re: How does the pass statement differ from python?

2019-09-06 Thread kaushalmodi
> So I'm wondering why does the following code get compiled

Because it comes from jester: 
[https://github.com/dom96/jester/blob/dc74a797ebca15e4f1b46a7f2e1f4e733b1c5ee2/jester.nim#L588](https://github.com/dom96/jester/blob/dc74a797ebca15e4f1b46a7f2e1f4e733b1c5ee2/jester.nim#L588)


Re: Linters in Emacs

2019-08-29 Thread kaushalmodi
I haven't used flymake, and I have used flycheck only for shell scripts (it 
checks Bash scripts using shellcheck, and it's pretty awesome).


Re: Linters in Emacs

2019-08-29 Thread kaushalmodi
I believe it has to do with nimsuggest. I tried using flycheck about a year ago 
and nimsuggest froze more often than not.. so I ended up disabling nimsuggest, 
and thus flycheck for nim-mode.


Re: how to run single test among all tests?

2019-08-21 Thread kaushalmodi
> Can I turn off all the hints?

In your test directory, you can create a `config.nims` and put this in there 
for all the hints that you want to hide:


hint("Processing", false) # Do not print the "Hint: .. [Processing]" 
messages when compiling


Run


Re: Can the return value of a proc be a variable marked {.global.} ?

2019-08-20 Thread kaushalmodi
> I don't think it really argues/advises against @mratsim's warning/hint 
> solution.

Correct.

The hint is fine. I was just saying that setting the default to `-d:release` 
would just switch to the other problem bucket.


Re: Can the return value of a proc be a variable marked {.global.} ?

2019-08-20 Thread kaushalmodi
I have come across a scenario where the gcc -O2/-O3 "over-optiimized" the code 
and that resulted in a buggy behavior.

So I needed to put a note to **not** pass the `-d:release` switch for that 
project. The discussion was on Nim IRC few months ago. 


Re: Default implementation of generic proc

2019-08-08 Thread kaushalmodi
Dumb question.. wouldn't it then make sense to define your "default type proc"?


proc returnZero[T]() : T =
  return T(0)

proc returnZeroDefault() : float =
  return returnZero[float]()

echo returnZeroDefault()
echo returnZero[int]()


Run

[https://play.nim-lang.org/#ix=1R1B](https://play.nim-lang.org/#ix=1R1B)


Re: What text editor are you using for Nim?

2019-08-07 Thread kaushalmodi
> Nah, it's a pretty known fact.

This is a case that Spiderman's uncle talked about: "With great power comes 
great responsibility".

With the possibility to tweak Emacs anyhow one likes, that also increases the 
chances of one badly tweaking Emacs.

One should not blindly paste configs from other users; one should know exactly 
what their config is loading.

Most of those search results will talk about using `M-x profiler-start` which 
allows a user to understand what in their Emacs config is causing it to slow 
down (this exercise, which many people do not do, and just complain about it 
being slow).

If people find their Emacs slow, they should compare with how fast the `emacs 
-Q` (stock emacs with zero user config, but still fully functional) sessions 
are.

Emacs allows users to customize every aspect of their editor experience and 
that can be too easy to shoot in one's foot too.


Re: What text editor are you using for Nim?

2019-08-07 Thread kaushalmodi
> And Emacs itself tends to be somewhat unresponsive, as evidenced by the very 
> first posts in this thread.

That's a grossly incorrect generalization.

I agree that Emacs has a weak spot when handling long lines. I have been using 
Emacs for 14+ years, and I never came across that limitation, may be because I 
code in 2-window frames and thus limit line lengths to roughly 80 chars. 


Re: What text editor are you using for Nim?

2019-08-02 Thread kaushalmodi
Oops, I was playing with the longlines.nim and did not run nimpretty on that 
last modified version. But rest assured, that asdf was manually typed by me :D


Re: What text editor are you using for Nim?

2019-08-02 Thread kaushalmodi
You are right; may be nim-mode is exacerbating the slowness issue.

I haven't come across this issue as I limit the number of chars per line to 
around 80.

Try using `nimpretty` that ships with Nim.

With a `longlines.nim` ( [http://ix.io/1QnF](http://ix.io/1QnF) ), running 
`nimpretty longlines.nim` modifies the same file to this ( 
[http://ix.io/1QnG](http://ix.io/1QnG) ).


Re: What text editor are you using for Nim?

2019-08-02 Thread kaushalmodi
> Emacs slows down when you have long lines

I agree, but that would be a rare case where you have a single line 
unprettified JSON or something like that.

How long are your lines in Nim? I default to 80 chars per line. For Emacs, "too 
long" lines would be in the range of upper hundreds of chars per line.


Re: What text editor are you using for Nim?

2019-08-02 Thread kaushalmodi
Emacs here, using mostly the default key bindings.

About the slowness, you probably just need to disable the `nimsuggest-mode`. I 
haven't noticed any slowness when editing Nim code (or anything) in Emacs.


Re: Passing a type through a macro?

2019-07-23 Thread kaushalmodi
I don't have the full solution, but I believe a `static` type `typedesc` arg 
will get passed without conversion to NimNode? I think there's an example in 
tut3. 


Re: get a type via a string?

2019-07-20 Thread kaushalmodi
This is very related: 
[https://forum.nim-lang.org/t/5027#31537](https://forum.nim-lang.org/t/5027#31537).
 Does that help? 


Re: Get AST for type in macro

2019-07-18 Thread kaushalmodi
You are welcome! I am surprised I was able to answer a macro-related question 
:D (Well, my Nim macro knowledge is limited to just about that :P).


Re: Get AST for type in macro

2019-07-18 Thread kaushalmodi
@GULPF Do you mean something like this? 
[https://play.nim-lang.org/#ix=1MUr](https://play.nim-lang.org/#ix=1MUr) (click 
Run, and if the tab next to is says "Showing: output", click on that so that it 
switches to "Showing: debug").


Re: Get AST for type in macro

2019-07-18 Thread kaushalmodi
Using your example: 
[https://play.nim-lang.org/#ix=1OOM](https://play.nim-lang.org/#ix=1OOM)


Re: timezone in unit tests

2019-07-14 Thread kaushalmodi
I do this in one of my Emacs lisp projects, I set the `TZ` environment variable 
to `UTC` in my test config.

So when the tests run on Travis, it thinks that it lives in the UTC zone, and 
all time stamps are created accordingly.

That way, you don't need to hardcode the time zone in your Nim code, and all 
time manipulation code will default to the local time zone (set by TZ).. I 
believe.

I haven't tried this with Nim, so just try it out :)


Re: What prevents you from using Nim as your main programming language?

2019-06-27 Thread kaushalmodi
Also check out [nimterop](https://github.com/nimterop/nimterop).


Re: exporting API from submodules

2019-06-25 Thread kaushalmodi
`import testPackage/submodule1 export submodule1 import testPackage/submodule2 
export submodule2 import testPackage/submodule3 export submodule3 `

Run


Re: How to compile/view the docs on localhost?

2019-06-16 Thread kaushalmodi
I see that you intend to contribute to the Nim repo, so you would have already 
done the cloning step in step 1 in the instructions at 
[https://github.com/nim-lang/Nim#compiling](https://github.com/nim-lang/Nim#compiling).

For unix systems, step 2 is `sh build_all.sh`.

And then `koch docs` creates the whole Nim documentation website locally.


Re: Help getting this macro to work in a for loop

2019-06-15 Thread kaushalmodi
Thank you! That was a very good explanation; it now helps me understand why 
macros cannot work in for loops.


  1   2   >