Re: Throw-away variables?

2019-10-12 Thread miran
Related: if you want to unpack other datatype, there is `unpack` package: [https://github.com/technicallyagd/unpack](https://github.com/technicallyagd/unpack)

Nim for enterprise software development

2019-10-12 Thread dponyatov
What do you think about using Nim in place of Java, C#, and legacy Delphi for enterprise software development? It looks for me as a technology very interesting for the small business market, where there are no resources to rent or invest in hardware and expensive software for huge processing wi

Re: nimble task arguments

2019-10-12 Thread aredirect
yes [https://github.com/nim-lang/nimble/issues/633](https://github.com/nim-lang/nimble/issues/633)

nimble task arguments

2019-10-12 Thread sflennik
Is it possible to pass arguments to nimble tasks? I want to pass the filename to run one test like this: nimble test filename Run

Re: Newbie question: let f = 0.0; why type(f) is float64 instead of float?

2019-10-12 Thread juancarlospaco
`doAssert f is float` is the way to assert the type.

Re: Throw-away variables?

2019-10-12 Thread htorun
I think this is what you are looking for: [https://nim-lang.org/docs/manual.html#statements-and-expressions-tuple-unpacking](https://nim-lang.org/docs/manual.html#statements-and-expressions-tuple-unpacking) proc returnsTuple(): (int, int, int) = (4, 2, 3) let (x, _, z) = ret

Newbie question: let f = 0.0; why type(f) is float64 instead of float?

2019-10-12 Thread htorun
This may not be a critical issue but I am trying to understand the basics well to be able to build on them. This is what I think I know: When we declare a variable, we declare it with a type: var i: int = 0 i3: int8 = 1 f: float = 0.0 f32: float32 = 3.14

Re: Warning: imported and not used

2019-10-12 Thread sflennik
thank you, that did the trick

Re: Warning: imported and not used

2019-10-12 Thread jlp765
the `-f` command line parameter of Nim will force a rebuilding of ALL modules

Warning: imported and not used

2019-10-12 Thread sflennik
I'm getting warnings about modules imported but not used and I want to fix my code. The second time I compile the warnings to do show up. How do I get the warnings to appear again? The second compile is much faster, so I'm thinking I might have to delete the cache. Is this correct? Where is it?

Re: Problem with macro and identation ...

2019-10-12 Thread Lachu
I think about using inheritance to achieve this. Nim, as pascal, delivers many method to use countable types, like splices, etc. I will write type, which contains seq of strings and I will implement method to get string from this sequence by index. Other method will get index of string. One que

Attaching finalizers to ref types (is there a better way?)

2019-10-12 Thread gyohng
Hello, I was looking into creating genuine ref types with finalisers. Is there a way to attach a finalizer to a type without using new(...) ? It seems that Nim is attaching a finaliser statically, but only does that if new() is mentioned somewhere in the program. This is what I found to be work

Re: Problem with macro and identation ...

2019-10-12 Thread Lachu
Thanks a lot. I was trying to write macro that generates: enum type and procedure to map value of this enum to related string. I decided to port game based on Freeciv. I'm only developer of this game and introducing a new features takes too long. Freeciv (and my game) is write in C and uses x-i

Re: Nim Days: Day 17 Building Sonic Client in Nim

2019-10-12 Thread aredirect
I appreciate your words. Hopefully, I can get more chapters coming. btw, I love dom's work! it's well written and has lots of clear explanations and I think both books can complement each other

Re: How to turn thread spawn call into an async call [redux; Nim 1.0.0]

2019-10-12 Thread dom96
Not yet AFAIK. We're still waiting on @rayman22201's patches to be finalised.

Re: Nim Coding Examples and Exercises for beginners?

2019-10-12 Thread siloamx
Can you provide any example how to use a modern database (Sqlite3/Mysql/Postgres) with Nim on Windows? I've tried to use Postgres, but libpg was not detected properly.

How to turn thread spawn call into an async call [redux; Nim 1.0.0]

2019-10-12 Thread boia01
Hi, I've been using a macro to turn thread spawn into an async call that had been [shared previously](https://forum.nim-lang.org/t/3648#22852) on this forum. With Nim 1.0.0 and improvements to asyncdispatch, I'm wondering if this capability made its way into the standard library yet? Sorry if

Re: FOSDEM Call for Participation

2019-10-12 Thread dom96
This description still seems rather "Minimalistic languages" focused. What is the official title of this devroom? Why do we need to focus on minimalistic languages where our devroom was aimed at _emerging languages_?

Re: Problem with macro and identation ...

2019-10-12 Thread jyapayne
Hmm, looks like you have quite a bit to understand. Your macro line is also indented too much, it should be on the same indentation level as the type declaration. This line: echo """{name} = enum\n " Run needs to be this: echo "{name} = enum\n "

Re: Problem with macro and identation ...

2019-10-12 Thread jyapayne
Your first file has an extra space on each echo line after the for loop. Remove that and your program will compile. However, that is not how you write a macro. You need to generate NimNodes instead of just printing to the screen. I can give an example when I get to my computer.

Re: question sur les struct or tuple

2019-10-12 Thread JPLRouge
ok je vais aller regarder ok i'll go watch thank you

Re: Terseness and productivity in Nim vs other languages

2019-10-12 Thread kidandcat
I work mainly with JS and Go, and I can tell you I love Nim because I can copy the same program from Go to Nim and it will have like 10 times less code

Error in proc with var and ptr parameters

2019-10-12 Thread Citrusn
type VALUE = object d: uint32 #proc init(v: var VALUE) = # working code # v.d = 3 proc init(v: var VALUE | ptr VALUE) = when v is ptr VALUE: v[].d = 1 else: v.d = 2 # compile error var v: VALUE v.init() echo repr v

Re: Problem with macro and identation ...

2019-10-12 Thread juancarlospaco
`echo` just prints to terminal, like `print` on Python, `puts` on Ruby, `echo` on Bash, etc.

Re: Terseness and productivity in Nim vs other languages

2019-10-12 Thread torarinvik
I find that it is more readable when you declare what data type it is. You don't have to comment as much, so it is more orderly IMHO. I think Python have the extreme edge on most language with all these libraries. It seem neural networks and AI in general is leaning towards python, and AI is the

Re: question sur les struct or tuple

2019-10-12 Thread boia01
Have you looked at [Tables](https://nim-lang.org/docs/tables.html) ? They are like hash maps.

Problem with macro and identation ...

2019-10-12 Thread Lachu
Sorry for that (probably) simple question, but I have indentation problems (compiler complains about it): First file: type progress_specenum_el = object name: cstring value: string macro generate_specenum(name: string; elements: openarray[progress_specenum_el]): untyped = ech

code to unpack (msgpack) and "cast" object to

2019-10-12 Thread enthus1ast
I receive different types of object from network, packed as msgpack. Now i need a construct that creates objects of the given type, to work with them further. I'm struggeling to create a proc/template that does this in one call. My goal is to get something like this: var msgObj = u

question sur les struct or tuple

2019-10-12 Thread JPLRouge
Bonjour, voilà j’arrive du c/c++ j’utilise les struct j’ai fait une correspondance avec (tuple objet) par contre j’aurai aimé me servir de map tel que le c++ me le propose le but : avoir une petite banque de données interne au programme pour faire soit des simulations ou des outils internes.

Re: Terseness and productivity in Nim vs other languages

2019-10-12 Thread torarinvik
This makes perfect sense, now I have more arguments when recommending Nim to advanced programmers. Thank you for your answers. I am planning to make a tiny toy language(I have a lot of reading and practise to do). Is nimly the way to go? Are there any manuals available? Thank you for all answers

Re: Terseness and productivity in Nim vs other languages

2019-10-12 Thread federico3
A lot of people find Nim's expressiveness comparable to Python. I find static types in Nim increase productivity even over Python although the ecosystem and tooling are not that rich.

Re: Terseness and productivity in Nim vs other languages

2019-10-12 Thread Araq
IME Nim code is almost always shorter and it's easy to see why: It doesn't have lines full of `} } }`. ;-) That's hardly an objective bonus to "productivity" because syntax is simply not that important. > How compact are Nim applications? It depends on the coding style. > Can one write a Nim e

Re: bitops iterator

2019-10-12 Thread Stefan_Salewski
> I would say 20% That is surprising for me. I would have assumed that Java is not a good choice for a chess engine using (rotated) bitboard representation. As Java uses most of the time reference semantic with indirection, not value semantic. And as Java was not really designed initially for l

Re: bitops iterator

2019-10-12 Thread pge
Interesting ! I will measure and compare speeds of both...

Re: bitops iterator

2019-10-12 Thread pge
Well, regarding java... efficiency is lower than C or Nim... I would say 20% for CPU intensive apps, not more. The memory consumption is also excessive in Java. But conceptualization is convenient. Here is an example of java bit iteration (cryptic but working): protected static fi

Terseness and productivity in Nim vs other languages

2019-10-12 Thread torarinvik
I have a question that I have been thinking about since I discovered Nim. How does Nim compare to other languages like C/C++, python,Java as far as productivity and terseness? How compact are Nim applications? Can one write a Nim equivalent to a C++ program in dramatically fewer lines of code? A