NaN tagging in Nim?

2019-11-17 Thread drkameleon
Are there any existing implementation of NaN tagging in Nim? (I'm about to do it myself - or at least experiment with to see if there are any performance benefits - but having sth for reference wouldn't be bad at all :))

Binary resulting much larger with --opt:size?

2019-11-17 Thread drkameleon
I've just noticed sth very weird. I have 2 different tasks in my _nimble_ file. One builds the project with \--opt:size and one with \--opt:speed. The thing is the resulting binary with the first option is over 900KB, while with \--opt:speed it get down to 600-sth(!). How is that possible?

Re: Differences between simple assignment, shallowCopy and deepCopy

2019-11-17 Thread drkameleon
Thanks a lot. Very thorough explanation!

Re: Web applications and pattern match

2019-11-17 Thread Vindaar
Good to hear! I couldn't find the source for the new version of the live demo though. In the markdown document it's still the old code as far as I can tell. Yes, please just ask!

A simple web page with utf-8 html form

2019-11-17 Thread edu500ac
I wrote a very simple web application just to learn how to do the job. Basically, the web page present a few lines of the Iliad, and has a visitor book. In the previous version, the visitor book worked with ASCII characters only. However, I noticed that many people wanted to test the page with

Re: Web applications and pattern match

2019-11-17 Thread edu500ac
Hi, Vindaar. I will use the solution you pointed out in the tutorial. By the way, if you visit the demo page, you will see that I already replaced the inicial version of the program with another one, which is based on the scanf. I also used the decode.Url procedure in order to test the utf-8

Re: How to avoid recursive module dependency ?

2019-11-17 Thread kcvinu
@Stefan_Salewski, Thanks. @juancarlospaco Let me try.

Re: How to avoid recursive module dependency ?

2019-11-17 Thread kcvinu
Thanks for the reply

Re: Jester memory usage keep rising using sqlite

2019-11-17 Thread me7
Thank you for your answer. I think that's because Nim does not free memory to OS. It's still ok for me that it's not memory leak

Inject into closures

2019-11-17 Thread foldl
Hi all, I have submitted issue [#12625](https://github.com/nim-lang/Nim/issues/12625) on GitHub on generating func-s (closures) with mapIt, where the code crashes nimvm or behaviors wrongly in runtime. Further checking indicates that the root cause is that, {.inject.} variables (it in this

Re: Is this a compiler bug or I took mistake?

2019-11-17 Thread georgbekesy
Oh I see. Thank you.

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

2019-11-17 Thread FernandoTorres
Not sure if this helps, but here an example: The Complex type (at the Standard Math/complex pure library) used to be a tuple, and was upgraded to a generic object. There are two possible representations of a complex number: rectangular and polar. The library and most functions are based on the

Re: Compilation error after upgrade to 1.0.2 from 0.19

2019-11-17 Thread demotomohiro
According to your error message, it seems tokens[ITEM_NAME] is Option[system.string] type and you are trying to add it to seq[string] type result variable. You might need to read this document and learn how to get a value from an Option type.

Compilation error after upgrade to 1.0.2 from 0.19

2019-11-17 Thread axben
The following code used to compile in nim 0.19: result = newSeq[string]() ... var tokens = li.match(re"\s*(\S+)\s*(?:>\s*(\S.*\S))?\s*").get.captures.toSeq() # Add to the list of list values result.add(tokens[ITEM_NAME])

Re: Can I "prune" directories with walkDirRect?

2019-11-17 Thread sschwarzer
I guess the link to the Python 2 version of the library was only by accident. If some new functionality in Nim should be modeled after Python, refer to the documentation for Python 3. For most older libraries, there shouldn't be a big difference, but for newer libraries there may be, and even

Re: How to avoid recursive module dependency ?

2019-11-17 Thread juancarlospaco
Put types on a dedicated file, `include` it.

euwren – a high-level wrapper for the Wren scripting language with a user-friendly DSL

2019-11-17 Thread lqdev
Recently, I have been working on euwren, a high level wrapper for [Wren](http://wren.io/). The idea behind euwren is to be _the king of Wren wrappers_ , one that uses a user-friendly DSL and that makes wrapping Nim procs a piece of cake. All you have to do is list the things you need in the

How to avoid recursive module dependency ?

2019-11-17 Thread kcvinu
Hi all, I have a recursive module dependency. How to solve this ? Say, i have two modules like this. #module_A.nim type a_Type* = ref object aVar* : b_Type Run And in another file, #module_B.nim type b_Type* = ref

Re: How to avoid recursive module dependency ?

2019-11-17 Thread lqdev
When you have types that depend on each other, you must place them under one `type` section—there's no way of avoiding that.

Re: How to avoid recursive module dependency ?

2019-11-17 Thread Stefan_Salewski
See also [https://forum.nim-lang.org/t/4745](https://forum.nim-lang.org/t/4745)

Re: Complex vs Rational implementations in the Standard Library

2019-11-17 Thread FernandoTorres
Congrats for 1.0 milestone. I'm glad to see that the Complex type is not a tuple any longer but an object and allows generics like the Rational type. That makes more sense now. Great job.

Re: Nim based Github Actions

2019-11-17 Thread jiro4989
I created GitHub Actions too. And I published it. [https://github.com/jiro4989/setup-nim-action](https://github.com/jiro4989/setup-nim-action) [https://github.com/marketplace/actions/setup-nim-environment](https://github.com/marketplace/actions/setup-nim-environment) But my actions is very

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: Problems with Emacs mode for Nim

2019-11-17 Thread Vindaar
Be that as it may, the fact remains that nim-mode is written in elisp. ;) I don't even think these changes are hard at all, but I don't know my way around how to find the code responsible for those indentations without studying all of nim-mode first.

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

2019-11-17 Thread cblake
Ok. Just to close the loop on this thread I believe this accommodates all expressed views: [https://github.com/nim-lang/Nim/pull/12678](https://github.com/nim-lang/Nim/pull/12678) (except maybe one week pre-release implies backward compatibility forever view or the if one-table has a proc, all

Re: difference between ; and , as proc parameter separator

2019-11-17 Thread SolitudeSF
when you're listing multiple parameters under one type like this proc test(a, b: int) Run if you're gonna use semicolon, the a parameter wont be an int. in current nim thats just useful when you're using the using statement

Re: Problems with Emacs mode for Nim

2019-11-17 Thread edu500ac
As far as I know, Vindaar, it is possible to program Emacs in any language through the Emacs Dynamic Mode. I believe that even in Nim. It is also possible to write extensions in neovim for any language, although the feature works better in the case of dynamic languages, such as Common Lisp,

Re: the "type" of the curly-bracket structure

2019-11-17 Thread cblake
What Nim calls the Table Constructor as dom96 has correctly pointed out, the lisp world has long called "association lists", often abbreviated "alist". Since it is a macro you are writing, you could check that the kind of the NimNode is `nnkTableConstr` and if not emit a useful compile-time

Re: Cross Platform Python Package

2019-11-17 Thread mratsim
They have a wheel per platform and pip/conda select the correct one on install.

Re: Can I "prune" directories with walkDirRect?

2019-11-17 Thread cumulonimbus
The python os.walk is exceptionally convenient and supports such a use case - the iterator returns 3 components: "path", "dirs" and "files"; the user has to enumerate "files" (or dirs) themselves, and join themm to the "path" for the list of files, but can also ignore dirs or modify it - the

Re: Accessing the terminating null byte in a string

2019-11-17 Thread mratsim
It's only there for no-copy interop with C libraries. If you want to access it you need to cast with `cast[ptr UncheckedArray[char]](s[0].unsafeAddr)`

Re: difference between ; and , as proc parameter separator

2019-11-17 Thread mratsim
None.

difference between ; and , as proc parameter separator

2019-11-17 Thread adnan
> What's the underlying difference between this signature: proc max(a: int; b: > int): int = and this proc max(a: int, b: int): int =?

Accessing the terminating null byte in a string

2019-11-17 Thread adnan
As per "Nim in Action", strings are lists of char`s terminated by `'0' (page 29). In the code below, how can I access that null byte? let s = "Abcd" echo s[s.len()] == '\0' # Error: unhandled exception: index 4 not in 0 .. 3 [IndexError] Run

Re: Web applications and pattern match

2019-11-17 Thread Vindaar
So originally I wanted to write a up a nice example to do the replacements via the scanf macro: [https://nim-lang.github.io/Nim/strscans.html](https://nim-lang.github.io/Nim/strscans.html) by defining tuples of strings to match against and their replacements, but I hit a dead end, because an