Best showcase of tests in Nim standard library?

2021-01-21 Thread dogwater
I'm learning more about best practices around writing tests in Nim. I noticed some modules e.g. `thttpclient.nim` are relatively sparse and inconsistent in how the tests are written. Which stdlib module has the best set of tests for a newcomer to study?

Current state of list comprehison in Nim

2021-01-21 Thread dogwater
Did you see the section in the "Nim for Python Programmers" wiki here:

Current state of list comprehison in Nim

2021-01-21 Thread halloleo
I looked around the world wide wonder to find how to do _list comprehsion_ in Nim, but found rather conflicting info (links to the `sugar` module which were outdated, etc). I could not get a clear picture, sorry. Therefore my question: What's the current state of list comprehension in Nim?

Any new edition of the Nim in Action book in the making?

2021-01-21 Thread dogwater
I picked up Dom's book 2 weeks ago and helped me get up to speed on Nim quickly. Serves as a helpful reference where official documentation may be sparse, e.g. async/await, macros and templates. The contents are still very relevant imo.

Best practice for OOP-style of procedure calling

2021-01-21 Thread halloleo
Wow, didn't know about the `with` syntax. Looks strange, but I can see the vakue.

Best practice for OOP-style of procedure calling

2021-01-21 Thread moigagoo
It looks even cooler with `with`: with s: add "a" replace("a", "b") splitLines Run

Best practice for OOP-style of procedure calling

2021-01-21 Thread greenfork
OOP style also looks nicer when you have a set of functions for manipulating a specific type/object player.move(Left) player.accelerate(North) player.isHit(bullet) Run Same can be true for the whole strutils module :

Best practice for OOP-style of procedure calling

2021-01-21 Thread ElegantBeef
init("myOrg", "Linerino") createWindow("Linerino", 128, 128, 4, false) run(gameInit, gameUpdate, gameDraw) Run These functions from the Nico framework dont make much sense to call with member functions, since the function name does not sound like it'd be a member funct

Best practice for OOP-style of procedure calling

2021-01-21 Thread halloleo
Well, I'm totally with you. - I have a vague image what it means to use C-style " _where they make the most sense_ " and respectively for OOP-style calls. But is there any more specific way to say when which makes more sense?...

Any new edition of the Nim in Action book in the making?

2021-01-21 Thread ElegantBeef
There is [this](https://deepakg.github.io/nim/2019/09/28/nim-in-action-errata.html) which addresses the changes and [this aswel](https://github.com/dom96/nim-in-action-code). From what I hear it's a great book and is not really that outdated.

Any new edition of the Nim in Action book in the making?

2021-01-21 Thread halloleo
I'm interested in a printed resource about Nim, but hesitant to get _Nim in Action_ from 2017 - Nim has changed quiet a bit since I guess. Is there any new edition of _Nim in Action_ (or any other Nim book for that matter) in the making?

Best practice for OOP-style of procedure calling

2021-01-21 Thread ElegantBeef
It's up to your discretion but for many things it's nicer, for instance `a.isNil` vs. `isNil a`. I tend to use it where it makes more sense to read `a.b`, using the C-style calls where they make the most sense.

Best practice for OOP-style of procedure calling

2021-01-21 Thread halloleo
I think the very general approach Nim takes on OOP-style of procedure calling is pretty amazing. To make clear what I'm taking about: When i use the standard function `substr` I can either write substr("hallo",1,1) Run or "hallo".substr(1,1)

Print - a better echo. colors, pretty nesting, refs and cycles!

2021-01-21 Thread halloleo
This looks really great - just a shame it doesn't integrate with [debug](https://nim-lang.org/docs/logging.html#debug.t%2Cvarargs%5Bstring%2C%5D).

Is there a way to use question mark in my proc names?

2021-01-21 Thread ElegantBeef
> Not all functions could be prefixed with `is_`, let's say `a.match?(b)` or > `table.has?(key)` or `set.contains?(key)` Well if we're on a quest of readabillity, alias those procedures with the following a.doesMatch(b) a.matchesWith(b) a.has(key) # already gramatically co

Is there a way to use question mark in my proc names?

2021-01-21 Thread hugosenario
With template we can do this: import strutils template `?`(b: bool, c: untyped) = (if b: c) "nimble".contains("nim")? echo "nim inside" Run But if we could define a postfix operator `?`, it may work with `i

Regex and capture unicode text

2021-01-21 Thread stbalbach
That's great, thank you, did not know this. Now understand the issue and the possible solution.

Regex and capture unicode text

2021-01-21 Thread treeform
You might want to preform some sort of unicode normalization first, to map unicode "C" to ascii "C" etc... Maybe?

Regex and capture unicode text

2021-01-21 Thread treeform
Use unicode mode in the regex: re"(*UTF)..." Run See:

What are simple profilers to use with Nim?

2021-01-21 Thread treeform
I also use Intel VTune. It's not simple, kind of clunky, but I can't find a better tool for windows.

Nim proc pointers

2021-01-21 Thread Araq
You can also disambiguate overloaded procs via a type conversion: let a = addProc(add) Run

What are simple profilers to use with Nim?

2021-01-21 Thread juancarlospaco
If theres a problem with nimprof, then report the bug.

Nim proc pointers

2021-01-21 Thread minidude22
Wow that was indeed it. Thanks @xigoi!

Regex and capture unicode text

2021-01-21 Thread stbalbach
Working with various languages in Wikipedia and would like to capture text that is Unicode, for example: This works (plain ascii): import re let t = "{{Cite book|test=}}" echo $(findBounds(t, re("(*UTF8)[{]{2}Cite book[|][^}]+}}", {}) )) Run This does not work

What are simple profilers to use with Nim?

2021-01-21 Thread ynfle
Try this [https://github.com/disruptek/golden](https://forum.nim-lang.org/postActivity.xml#httpscolonslashslashgithubdotcomslashdisruptekslashgolden)

What are simple profilers to use with Nim?

2021-01-21 Thread disruptek
On Linux, use perf.

What are simple profilers to use with Nim?

2021-01-21 Thread enthus1ast
"Intel VTune" is not simple but very powerful.

Nim Community Survey 2020 Results

2021-01-21 Thread federico3
To put the numbers in perspective: 15% less responders, 5% less Nim users but the poll time was 40% shorter. The fraction of Nim users increased by 8% The average number of poll participants per day increased by 6%

Is there a way to use question mark in my proc names?

2021-01-21 Thread Stefan_Salewski
I don't miss the question mark from Ruby that much, but myseq.sort! vs. myseq.sort Run was not that bad. Well for sort we have sorted(), but that does not work always, so some proc names there is no ed form available.

Is there a way to use question mark in my proc names?

2021-01-21 Thread Hlaaftana
I'd say this is more of a problem with English rather than anything programming languages can really work with. Perl and Ruby prioritize the English language, so they have more freedom to account for the fact that "is xxx" by itself doesn't necessarily imply a question or predicate so "xxx?" is

Is there a way to use question mark in my proc names?

2021-01-21 Thread alexeypetrushin
Not all `bool` functions could be prefixed with `is_`, let's say `a.match?(b)` or `table.has?(key)`.

Is there a way to use question mark in my proc names?

2021-01-21 Thread wiltzutm
Indeed the question mark syntax is totally subjective matter. I prefer the question mark. Of course I understand that it isn't so subjective/superficial thing when you are the guy who has to implement it in the language, so if there's no point in it on your behalf then it is the end of discussio

What are simple profilers to use with Nim?

2021-01-21 Thread alexeypetrushin
Seems like `nimprof` is a bit outdated. What other **simple** profiler could be used with Nim? I'm looking for something simple, basically I need only 2 things: * Show top 10 stack-traces that consume most of the time. * Show top 10 most copied types of objects, so I may choose to replace `

Is there a way to use question mark in my proc names?

2021-01-21 Thread Araq
I don`t see the point, `full?` is not more readable than `isFull` for me. Nor is `if x.full?:` with the question mark before the colon all that "sexy".

Is there a way to use question mark in my proc names?

2021-01-21 Thread wiltzutm
Yes, I edited. I admit it was a bit uncalled for to code about human anatomy. ;)

Is there a way to use question mark in my proc names?

2021-01-21 Thread mratsim
The examples are very inappropriate, can you edit them?

Is there a way to use question mark in my proc names?

2021-01-21 Thread wiltzutm
Thank you for the quick reply. Actually I tried that backtick trick, but for some reason I trusted my IDE/linter whining about it and didn't properly compile it for testing. But it is good to know that it should and will work. As you said, it loses the whole point of using the question mark when

Is there a way to use question mark in my proc names?

2021-01-21 Thread alexeypetrushin
+1, really miss that feature (although I'm from Ruby, not Lisp). > ... Though you would have to use backticks each time you call a proc with > such name. That's not a good solution, nobody going to use that in practice.

Is there a way to use question mark in my proc names?

2021-01-21 Thread juancarlospaco

Is there a way to use question mark in my proc names?

2021-01-21 Thread haxscramper_
Sure, you can use to use any combinations of characters as proc name. For example: import std/strutils proc `youOk?`(message: string): bool = not ("penis" in message) echo `youOk?`("some message

Is there a way to use question mark in my proc names?

2021-01-21 Thread wiltzutm
Ok, I feel very inadequate for not finding definite answer for this, but is there any way I could use lisp like question mark proc names? eg. instead of proc isLarge(p: Penis): bool = return p.owner != "wiltzutm" Run I would like to use the typical lisp style:

libdill for large scale concurrency

2021-01-21 Thread mratsim
Weave is really tuned for compute-bound workload and not IO-bound workload because it optimizes for throughput (expediting all the work at once) instead of latency/fairness (make sure early tasks are executed earlier). A blog post waiting to be published on that (

Nim Community Survey 2020 Results

2021-01-21 Thread miran
> For 2019 we ran it for 50 days. This year it was 30 days. Also, one more reason for lower number this year can be seen if you compare the number of (non)users in each survey. In 2019 we have reached a wider (non-Nim) audience, probably thanks to HackerNews (you never know when and which post

libdill for large scale concurrency

2021-01-21 Thread Araq
> What do you guys think about this specifically, and in general about > integrating finished high quality focused libraries as part of the language > or its std lib? It doesn't run on Windows, and C code tends to produce things like