Re: Best way to store/search/etc and an int-int data structure

2019-12-02 Thread Stefan_Salewski
For a small number of values linear search may be OK; when values do not change much, you may sort them and do a binary search. Or use a hash table, or maybe a tree structure.

Re: Strange Crash

2019-11-28 Thread Stefan_Salewski
Solution seems to be easy: In [https://github.com/StefanSalewski/gintro/blob/master/gintro/cairoimpl.nim#L242](https://github.com/StefanSalewski/gintro/blob/master/gintro/cairoimpl.nim#L242) proc popGroup*(cr: Context): Pattern = new(result, patternDestroy) result.impl =

Re: Fastest way to check for int32 overflows

2019-11-28 Thread Stefan_Salewski
> I want to predict when the result I think predict is only possible in rare cases. Why not use saturated arithmetic to detect overflow after it has occurred? [https://en.wikipedia.org/wiki/Saturation_arithmetic](https://en.wikipedia.org/wiki/Saturation_arithmetic)

Re: Nim 1.0.4 is out!

2019-11-28 Thread Stefan_Salewski
Nim uses odd minor version numbers to denote development releases and even minor version numbers to denote stable releases. That is common practice, see

Re: setupForeignThreadGc() equivalent for Boehm GC?

2019-11-26 Thread Stefan_Salewski
> So... any idea? Your posts are a bit hard to understand, at least for me, and I have no idea on what project you are working and what you intend. What is > when trying the command with --gc:boehm it complains You can compile your program with something like nim c --gc:boehm myprog.nim to

Re: The authors of the Nimacros project stopped working on that book

2019-11-26 Thread Stefan_Salewski
What I was wondering about from the beginning: How many real Nim experts are in your group, and which advanced Nim projects have your group created already? I don't think that only Araq or Mratsim will be able to write a real Nim textbook, but I think that there are only a few candidates who

Re: GC and fixed memory addresses

2019-11-26 Thread Stefan_Salewski
Do we have a moving GC for Nim at all? D does not have one, see [https://dlang.org/spec/garbage.html#obj_pinning_and_gc](https://dlang.org/spec/garbage.html#obj_pinning_and_gc) I assume with a moving GC there could be a problem when we have a Nim ref object, cast its address to ptr, pass it to

Re: Problem with .exportc-marked variable containing proc reference

2019-11-26 Thread Stefan_Salewski
I think, when you are using generics inside an object, than the object may need generics as well, so maybe try something like Statement[SystemFunction,ExpressionList,Value] = ref object ? Just a guess.

Strange Crash

2019-11-25 Thread Stefan_Salewski
Traceback (most recent call last) /home/stefan/pet2/pet.nim(717) pet /home/stefan/pet2/pet.nim(714) test /home/stefan/pet2/pet.nim(683) newDisplay /home/stefan/.nimble/pkgs/gintro-#head/gintro/gio.nim(24220) run /home/stefan/Nim/lib/core/macros.nim(570)

Re: How to parallelize a for-loop

2019-11-25 Thread Stefan_Salewski
> love to know how to harness the multicore capability inside a for loop in Nim. Have you already played with [https://nim-lang.org/docs/manual_experimental.html#parallel-amp-spawn](https://nim-lang.org/docs/manual_experimental.html#parallel-amp-spawn) But I think there may coming other ways

Re: Which is the fastest way to use a timer

2019-11-25 Thread Stefan_Salewski
The fact that the time of times module is not monotonic is a bit surprising for me -- well maybe when the user sets the wall time of his box? The fact should be noted in times module. But for all benchmarks done with times.getTime() I have never seen a negative delta yet.

Re: Which is the fastest way to use a timer

2019-11-25 Thread Stefan_Salewski
> I cant find any timers on nim manual. But i found times module. Why would you expect timers in the Nim manual? Nim is not a kind of virtual basic which may integrate all the user stuff into the language. And when you have already times module, you may inspect its functions:

Re: Problem with forward declarations and pragmas

2019-11-22 Thread Stefan_Salewski
Is that related to [https://forum.nim-lang.org/t/1703](https://forum.nim-lang.org/t/1703) ?

Re: How to print a float's binary digits?

2019-11-21 Thread Stefan_Salewski
Cast your float to int64 and use [https://nim-lang.org/docs/strutils.html#toBin%2CBiggestInt%2CPositive](https://nim-lang.org/docs/strutils.html#toBin%2CBiggestInt%2CPositive)

Re: Performance: 2 indirections or 1?

2019-11-21 Thread Stefan_Salewski
I think it is exactly the same. Objects are pure by default, as long as no inheritance is involved, so there is no hidden object header in this case.

Re: Advantages of "from... X... import Y" over "import Y"?

2019-11-21 Thread Stefan_Salewski
Only advantage is avoiding namespace collisions and the fact that the reader of the source code can easily see the origin of the symbols.

Re: Silly mistake in for loop but can't figure it out

2019-11-19 Thread Stefan_Salewski
Really funny :-) I guess you know that we generally write "when is mainModule:" With while it makes no sense, but the compiler can not catch all nonsense.

Re: Reversing string Hash value

2019-11-19 Thread Stefan_Salewski
Note that hash() function is not a one to one operation, but generally many objects have the same hash value. In a HashTable the hash values is generally used to guess a set of candidates, and the candidates are then compared each to the key to see if there is a real match. hash() is generally

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)

Array vs tuple for procs returning multiple values of same type

2019-11-16 Thread Stefan_Salewski
When I started with Nim years ago I used arrays, as tuples are only necessary when not all types are identical, and as we can iterate at runtime over array, which may be rarely needed for a proc result. Then I saw examples using tuples, and I think that time automatic tuple unpacking was

Re: Differences between simple assignment, shallowCopy and deepCopy

2019-11-16 Thread Stefan_Salewski
I think for most of us it works exactly as we suppose. Some years ago there was no exact documentation available, so indeed you request writing documentation. But I think explaining this is not that easy, as it should be understandable to newcomers, but at the same time not boring for experts.

Re: Cross compiling for Linux

2019-11-15 Thread Stefan_Salewski
Also note that google will point you to [https://gist.github.com/deefdragon1/2336e2404c468c3c59f1ef670745a920](https://gist.github.com/deefdragon1/2336e2404c468c3c59f1ef670745a920)

Re: Cross compiling for Linux

2019-11-15 Thread Stefan_Salewski
> syntax error near unexpected token newline I do know really nothing, but from that message my guess would be that the server tries to execute your uploaded file as a shell script. But I guess it should be executed as a binary. May it be necessary to mark it as executable, maybe setting an

Re: Need advice regarding using templates

2019-11-15 Thread Stefan_Salewski
> for perfomance reasons That sounds a bit strange for me. Have you tested proc with inline pragma already? And note when you compile with -flto you have generally full inlining for free. I think templates may have benefit for tiny procs, when there is only one plain statement maybe. And

Splat operator

2019-11-14 Thread Stefan_Salewski
Is the solution of Mr Felsing still the best and only solution? [https://stackoverflow.com/questions/48418386/tuple-to-function-arguments-in-nim](https://stackoverflow.com/questions/48418386/tuple-to-function-arguments-in-nim) Is so, maybe we can tune it and add it to Nim std lib? Splat is

Re: Memory leak

2019-11-14 Thread Stefan_Salewski
Same behaviour when compiled in debug mode, and with -d:release and -d:danger? Can you try another GC, maybe boehm?

Re: Nimrad: Nim and Rapid Application Development

2019-11-13 Thread Stefan_Salewski
Are you thinking about something like [https://glade.gnome.org](https://glade.gnome.org)/ Well of course you can use that with gintro, I gave a small example. You may also investigate [https://github.com/ba0f3/uibuilder.nim](https://github.com/ba0f3/uibuilder.nim), but I don't know what it

Re: Marshal and friends

2019-11-13 Thread Stefan_Salewski
After a closer look at JSON and YAML it seems that the user interface for storing and loading objects is similar, so I can start with one and maybe later exchange it with the other :-) YAML is really large, a small test program generates a 200k executable in release mode. For module marshal

Marshal and friends

2019-11-12 Thread Stefan_Salewski
[https://nim-lang.org/docs/marshal.html](https://nim-lang.org/docs/marshal.html) I just started playing with marshal module. Seems to be the easiest way to store objects in an human readable form to disk. My test is import marshal, streams var s =

Re: A couple of questions

2019-11-12 Thread Stefan_Salewski
I think that "perfectly valid topic" is a copy -- I stumbled about the strange phrase "have 1.3M bytes of text" I think I have seen it somewhere else. Was just about asking miram to remove the spam links.

Re: A taxonomy of Nim packages

2019-11-11 Thread Stefan_Salewski
Thats works! I have moved RTree from Graphics algorithms to Data structures . I do not fully understand the sorting in each category, seems to be mostly alphabetical, but not strict, and what is about lower case and upper case? You wrote about prefering pure packages. Note that wNim and gintro

Re: Play audio in Nim ?

2019-11-10 Thread Stefan_Salewski
` nimble search audio ` Run

Re: A taxonomy of Nim packages

2019-11-09 Thread Stefan_Salewski
> i dont get the point of these categorized lists. I think such a list is not that bad for newcomers to get an overview what is available. But no nimble packages should be left out -- if you do not like gtk you can not simple ignore all gtk related GUIs, and if you hate RTrees, or do not know

Re: Retrieving field names of an enumeration or other types?

2019-11-08 Thread Stefan_Salewski
There is [https://nim-lang.org/docs/iterators.html#fieldPairs.i%2CS%2CT](https://nim-lang.org/docs/iterators.html#fieldPairs.i%2CS%2CT) but I have never used it, and it seems to be not intended for enums.

Re: A taxonomy of Nim packages

2019-11-07 Thread Stefan_Salewski
There was another similar attempt recently, see [https://forum.nim-lang.org/t/5190#32541](https://forum.nim-lang.org/t/5190#32541) Thank you for your effort, but I can not imagine that such an incomplete list can be very helpful. For example Araq listed the GUI packages recently, I think that

Re: Can themutually recursive types be written separately?

2019-11-06 Thread Stefan_Salewski
I guess not much has changed in the last six months: [https://forum.nim-lang.org/t/4745#29616](https://forum.nim-lang.org/t/4745#29616)

Re: Why is Seq.reverse() not part of the standard lib?

2019-11-06 Thread Stefan_Salewski
I just remembered that we had a similar discussion some months ago: [https://forum.nim-lang.org/t/5068#31836](https://forum.nim-lang.org/t/5068#31836)

Re: Why is Seq.reverse() not part of the standard lib?

2019-11-05 Thread Stefan_Salewski
> possibly reversing seq's is not implemented in any of the current standard > libraries because it is so easy to do writing it yourself. I don't think that this is a good reason. Some months ago I even voted for having even() and odd() in the standard lib, maybe as isOdd() and isEven(). I

May this macro work good enough?

2019-11-04 Thread Stefan_Salewski
In the last days I created the requested macro for [https://forum.nim-lang.org/t/5418](https://forum.nim-lang.org/t/5418) [https://github.com/StefanSalewski/gintro/blob/master/gintro/gimpl.nim#L308](https://github.com/StefanSalewski/gintro/blob/master/gintro/gimpl.nim#L308) which printed out

Re: read number from ascii (text) file: scanf-like functionality?

2019-11-04 Thread Stefan_Salewski
> The system module has readLine but not readWord There are dozen of ways to do it and dozen of examples -- some are optimized for performance, some more for easy usage. For example for lines of text, there is split iterator which can split the line into words. Miram already recommends

Re: read number from ascii (text) file: scanf-like functionality?

2019-11-02 Thread Stefan_Salewski
You can explain someone who ask you about the current time how to built his own atomic clock. But that is not always necessary.

Re: help setCellDataFunc gtk3

2019-10-31 Thread Stefan_Salewski
> it will be necessary to wait until April 2020 (migration of the stable) to > explore 0.6 Sorry for that, but from [http://ftp.gnome.org/pub/gnome/sources/gtk+/3.24](http://ftp.gnome.org/pub/gnome/sources/gtk+/3.24)/ my impression is that GTK 3.24 is available for more than one year now. So

Re: help setCellDataFunc gtk3

2019-10-30 Thread Stefan_Salewski
OK, I found a CellDataFunc example code from A. Krause. I will add that needed macro to the package eventually. But as I have just shipped v0.6.0 I hesitate to ship a new version just for this macro -- CellDataFunc is not used often, and maybe you can not use it at all as you have still old gtk

Re: let & const on C backend

2019-10-30 Thread Stefan_Salewski
See also [https://forum.nim-lang.org/t/5192](https://forum.nim-lang.org/t/5192)

Re: cairoimpl.nim error

2019-10-29 Thread Stefan_Salewski
> version lib gtk 03.22.30 Thanks for confirming. That version is really old -- I am using 3.24 for very long time now, currently 3.24.10. Indeed basic gobject-introspection was added to cairo upstream some months after I started with the gobject-introspection bindings about 3 years ago. See

Re: cairoimpl.nim error

2019-10-28 Thread Stefan_Salewski
It should be not related to GTK4, I have tested with only GTK3. For all your problems: Of course you can ask in this forum or where ever you want, but it should be understandable for others at least, and maybe should concern others too. For your cell data function issue, well I can understand

Re: cairoimpl.nim error

2019-10-28 Thread Stefan_Salewski
Thank you for your error report. But you should really not pollute this forum with such stupid messages! Nim packages are generally hosted at github, and there are issue trackers. For gintro it is

Re: help setCellDataFunc gtk3

2019-10-28 Thread Stefan_Salewski
Have just send out v0.6 with the requested gstreamer support, so I need a break of a few days at least. Unfortunately I do know not much about all the treeview stuff, and treeview is the most difficult in GTK. I read about it ten years ago in the book of A.Krause, but can not remember details.

Re: Make Nim easier for the developer

2019-10-28 Thread Stefan_Salewski
> wrapper free interop Can that really work? Do zig, jai, vlang and all the other new candidates have high level gtk support at least, or C++ support for Qt, CGAL, BOOST? I don't think so. For zig it may work for C, as zig does manually memory management, and as zig is basically a C better

Re: How to write a shared(static in c++) proc in a type ?

2019-10-27 Thread Stefan_Salewski
> Cat().purr() Cat() does allocate an anonymous object for each call -- at least it did in the past. You may also consider type or typedesc as first parameter, see as an example [https://forum.nim-lang.org/t/5331](https://forum.nim-lang.org/t/5331) So we can call a proc on a type like

Re: Requesting examples of macros in Nim

2019-10-22 Thread Stefan_Salewski
Araq, tut3 is really much too short and restricted -- I can not remember well, but many open questions. I never asked, because I know Arne D. had to do much work currently. Generally I liked the flenniken tutorial better for beginners, because it is easy to understood. But I don't know if it

Re: Requesting examples of macros in Nim

2019-10-22 Thread Stefan_Salewski
> As soon as the book on Nim macros is ready, A Nim macro book would be really great. I read [https://nim-lang.org/docs/tut3.html](https://nim-lang.org/docs/tut3.html) and [https://flenniken.net/blog/nim-macros](https://flenniken.net/blog/nim-macros)/ but have still a lot problems with macros.

Re: What are you building now?

2019-10-17 Thread Stefan_Salewski
Can you tell us what the procvar pragma does and why it is necessary in your code? [https://github.com/thebigbaron/rainbow/blob/master/src/rainbow.nim#L22](https://github.com/thebigbaron/rainbow/blob/master/src/rainbow.nim#L22)

Re: R-Tree module -- what can we improve?

2019-10-16 Thread Stefan_Salewski
OK, maybe lets start with the proc vs iterator issue: We have [https://github.com/StefanSalewski/RTree/blob/master/src/rtree.nim#L894](https://github.com/StefanSalewski/RTree/blob/master/src/rtree.nim#L894) proc findNearestBox*[M, D: Dim; RT, LT](t: RTree[M, D, RT, LT];

Re: images: simple way to read/write and manipulate images in nim?

2019-10-16 Thread Stefan_Salewski
Yes, that looks good, but when I visited that page yesterday I was not sure if it is a pure Nim solution or it depends on C libs. I found that flippy depends on some other libs, but than again I was not sure if that where native Nim libs or C wrappers. C wrappers is not too bad when done well

May we need one more assert(), like debugAssert()?

2019-10-16 Thread Stefan_Salewski
In the past we had doAssert() for checks always enabled, and assert() which was disabled in release built. But with Nim 1.0 we generally avoid -d:danger, so assert() is generally enabled. For example in

Re: images: simple way to read/write and manipulate images in nim?

2019-10-16 Thread Stefan_Salewski
Thanks for example. I have never found time to learn about gtk-pixbuf myself. Of course gintro can work on Windows as well, some Nim users have managed to install it. But of course most Windows users just don't want to use GTK.

R-Tree module -- what can we improve?

2019-10-15 Thread Stefan_Salewski
I have just shipped version 0.2 of Nim R-Tree module rtree.nim to github. Integration in nimble data base should occur soon. [https://github.com/StefanSalewski/RTree](https://github.com/StefanSalewski/RTree) This is a fully generic module with insert(), delete(), search(), bulk-load() and

Re: Manu v1.1 - Matrix Numeric package released!

2019-10-13 Thread Stefan_Salewski
Testing performance would still make sense. I strongly assume that original Java authors used double[][] because it is not too slow in Java. Would be fine to know that your Nim code is not slower.

Re: Manu v1.1 - Matrix Numeric package released!

2019-10-13 Thread Stefan_Salewski
Nice work. It must have been much work to manually convert the Java code to Nim. For C or C++ code conversion based on c2nim should be much easier. I hope you can do some performance tests also. I don't expect a performance gain for Nim, as long as you have keep the original Java data

Re: Multi-threading and data sharing

2019-10-13 Thread Stefan_Salewski
> ... it seams that the reasonable action would be to switch back from nim to > c++ I think in your initial post you where talking about Java? Currently multi-threading and parallel processing may be not optimal for Nim, but I think it will improve soon, maybe with newruntime or new GC with

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

Re: bitops iterator

2019-10-11 Thread Stefan_Salewski
Your Java chess engine is using bitboards?

Re: c-like read\write data structure in Nim?

2019-10-10 Thread Stefan_Salewski
For binary data using streams similar like [https://stackoverflow.com/questions/33107332/writing-reading-binary-file-in-nim](https://stackoverflow.com/questions/33107332/writing-reading-binary-file-in-nim) But there is also json and

Re: default values for objects

2019-10-09 Thread Stefan_Salewski
> There are no default values But there are rumors that we may get them for Nim > 1.0

Re: Nim Coding Examples and Exercises for beginners?

2019-10-08 Thread Stefan_Salewski
Funny, I did a chess game too some years ago. [https://github.com/StefanSalewski/nim-chess4](https://github.com/StefanSalewski/nim-chess4)

Re: ui TABLE error

2019-10-07 Thread Stefan_Salewski
> for gintro you answered well I have no problem it was another message So I misunderstood you because you asked about gintro some hours before. For libui I can not help you. It seems that libui is hosted under nim-lang at github, so maybe open an github issue there. Or just wait, maybe someone

Re: ui TABLE error

2019-10-07 Thread Stefan_Salewski
OK, but I have never seen that code before. It seems to belong to libui, a different Nim GUI lib. Mr Rouge, please try to provide a C example to show what you really desire. Or an example in a different programming language. Currently I can not guess what you intent, and I would hope that we

Re: ui TABLE error

2019-10-07 Thread Stefan_Salewski
You are referring to [https://github.com/nim-lang/ui/blob/master/examples/table.nim](https://github.com/nim-lang/ui/blob/master/examples/table.nim) That is the only one google gave me, but it is in no way related to gintro/gtk3

Re: ui TABLE error

2019-10-07 Thread Stefan_Salewski
Do you really assume someone can guess the reason for the error from that snippet? GValue is one of the more difficult part of GTK, luckily we don't need it often. We have some examples for using of GValue for gintro already. When you use it wrong you get messages like above. Please try harder

Re: Gintro gtk_builder_new_from_string

2019-10-07 Thread Stefan_Salewski
>From my understanding you want to distribute your application without an >associated xml file containing the GUI definition? For gtk builder we have at least 3 choices: Load the content from external xml text file, load it from string contained in the program code, and load from resource. I

Re: wNim - Nim's Windows GUI Framework

2019-10-05 Thread Stefan_Salewski
> I am starting to write some beginner tutorial for wNim It is great that there is some progress with your Windows GUI. How do you manage memory resources? I have seen no manual free() in your example code, so I assume that you have implemented finalizers like I did for GTK, using GC_ref() and

Re: Parameter location doesn't match proc api parameter location

2019-10-04 Thread Stefan_Salewski
> server gets passed to the first argument in the background? We really should not name it this way, it is no magic. It was called UFCS in D-Lang and is called "Method Call Syntax" in Nim. f(x) can be written as x.f

Re: Nim in Action Help thread

2019-10-03 Thread Stefan_Salewski
OK: $ nim -v Nim Compiler Version 1.0.99 [Linux: amd64] Compiled at 2019-10-03 Copyright (c) 2006-2019 by Andreas Rumpf git hash: c51857f4348823f647110e8a1ede07d76d93b7da active boot switches: -d:release The chess game compiles and runs fine for me still. But I can test only on 64 bit linux,

Re: Nim in Action Help thread

2019-10-03 Thread Stefan_Salewski
No, no reason -- but my last update was only two weeks ago. Will update now, but will not test all my packages again. Have first to finish tgs bulk loading for my RTree, and maybe then make a nimble package out of it. So testing other packages have to wait, maybe next year.

Re: NIM in action offline resources

2019-10-03 Thread Stefan_Salewski
Dom's book was available in ebub format from the beginning, I read the early drafts in epub. Note hat the book is not needed to learn Nim, there are many great resources for beginners now: [https://nim-lang.org/learn.html](https://nim-lang.org/learn.html) The book is a nice to have, for some

Re: Nim in Action Help thread

2019-10-02 Thread Stefan_Salewski
> Please let us know if you upload the chess game :D . How many lines of code > did it take if I may ask? The chess game is available since a few years of course, it was one of my early tests for Nim and GTK.

Re: Nim in Action Help thread

2019-10-02 Thread Stefan_Salewski
I got last info from [https://forum.nim-lang.org/t/5124#32234](https://forum.nim-lang.org/t/5124#32234) > You need to compile with both -d:release (removes stacktraces and uses -O3) > and -d:danger. And indeed, just tested again: $ nim c -d:danger board.nim -rwxr-xr-x 1 stefan stefan 200728

Re: Nim in Action Help thread

2019-10-02 Thread Stefan_Salewski
mratsim -- I don't get it. You told us recently that -d:danger is not enough for optimal performance, so use additional -d:release. And I think I tested that indeed. But from

Re: Nim in Action Help thread

2019-10-02 Thread Stefan_Salewski
> With 0.20, plain asserts are kept Oh -- I thought bound checks are kept with -d:release, but not asserts. I hope the differences of -d:danger and -d:release are explained at a prominent place now -- some people like me have trouble to remember. Some think still that -d:danger does include

Re: Nim in Action Help thread

2019-10-02 Thread Stefan_Salewski
There is nothing special with assert(). See [https://nim-lang.org/docs/lib.html](https://nim-lang.org/docs/lib.html) [https://nim-lang.org/docs/assertions.html#doAssert.t%2Cuntyped%2Cstring](https://nim-lang.org/docs/assertions.html#doAssert.t%2Cuntyped%2Cstring) Assert just ensures that a

Re: Getting a strange error with file streams

2019-10-01 Thread Stefan_Salewski
Compiler message is very clear. There is only proc setPosition(s: Stream; pos: int) which takes an non optional int as second parameter. So call file.setPosition() is invalid. I have no idea what you wants to do exactly, maybe you assume that there is a default parameter to setPosition()? There

Re: Front page example

2019-10-01 Thread Stefan_Salewski
Also see [https://github.com/nim-lang/website/issues/162](https://github.com/nim-lang/website/issues/162)

Re: Proposal to start a Nim-Scientific Community

2019-09-29 Thread Stefan_Salewski
Why not just start on Nim forum and Nim IRC and switch to separate area when number of participants becomes too large, like maybe a few dozen? I really wonder why some people like to separate so much? We all know that Nim community is still small, and there is no evidence that many people are

Re: Newbie experience with the documentation

2019-09-28 Thread Stefan_Salewski
While reading your post for the first time I got the impression that you were looking for data type "Natural" \-- I searches for Natural in docs and found it fast. But now I have the impression that you are looking for keyword "type"? Keyword type is mentioned in tutorial 1, maybe not early

Re: Nim beginners tutorial

2019-09-27 Thread Stefan_Salewski
Great work miran! Your Asciidoctor css layout looks nice. I was never fully satisfied with the default Asciidoctor style, and also liked the Asciidoctor Stylesheet Factory themes not really. So I tried tuning them a bit, but was not too successful. It seems you tuned CSS for html, pdf and even

Re: Unexpected error using parseInt

2019-09-27 Thread Stefan_Salewski
Yes, that may be a bit confusing, there are two parseInt() procs in stdlib. You may go to [https://nim-lang.github.io/Nim/lib.html](https://nim-lang.github.io/Nim/lib.html) and type parseInt into the "search" field. Then you get parseutils: parseInt(s: string; number: var int; start = 0): int

Re: [RFC] Why use Nim?

2019-09-24 Thread Stefan_Salewski
> Very few other languages support direct C++ interop. I think we should not advertize C++ interop. too loud. C++ with its classes and template is really hard. Can Nim use C++ libs like Boost, CGAL, Qt out of the box? I dont think so, and I think onl C++ itself can use these libs unrestricted.

Re: ambiguous identifier in macro

2019-09-17 Thread Stefan_Salewski
Ah yes, macros.owner() seems to be what I need. Have just added line echo widget.getTypeInst.owner.strVal Run to mconnect() macro and output is gtk, exactly the module name what I need. It was not really obvious for me that term owner is related to module identifier

ambiguous identifier in macro

2019-09-16 Thread Stefan_Salewski
Seems to be the same problem again. Compiling [https://github.com/StefanSalewski/gintro/blob/master/examples/gtk3/css_colored_listview.nim](https://github.com/StefanSalewski/gintro/blob/master/examples/gtk3/css_colored_listview.nim) does only work with import gintro/gdk except

Re: Call to all nimble package authors

2019-09-13 Thread Stefan_Salewski
> doc_quality, project_quality, categories That is an interesting effort, but you may admit that above categories can be very arbitrary. And unfortunately it can discourage people when they get not maximum point count. At leasts I would become really angry if I get not nearly maximum point

Re: How can I write `($typeof(x[])).split(":")[0]` better?

2019-09-04 Thread Stefan_Salewski
Yes, I was wondering also about this "ObjectType" in [https://github.com/StefanSalewski/gintro/blob/master/gintro/gimpl.nim#L33](https://github.com/StefanSalewski/gintro/blob/master/gintro/gimpl.nim#L33)

Re: Came across a video talking about NIM

2019-08-31 Thread Stefan_Salewski
> Nim basics tutorial doesn't expect you to have some prior knowledge Yes, I have to admit that the situation for beginners has improved in the last years, so for smart people starting with Nim as their first computer language is an option. Note that we recently got one more core components

Who owns the widget in this example?

2019-08-29 Thread Stefan_Salewski
This compiles and runs fine with --newruntime: # nim c --newruntime -r t.nim import OS type Widget = ref object i: int a: array[1024, int] var g1: seq[Widget] proc newWidget(): owned Widget = new result proc addWidget(w:

Why does this compile and work with --newRuntime

2019-08-29 Thread Stefan_Salewski
# nim c --newruntime -r t.nim import OS type O = object i: int a: array[1024, int] R = ref O proc t = var r: R = R(i: 2) # var r = R(i: 2) # OK # var r: owned R = R(i: 2) # OK var x: R for i in 0 .. 1e7.int:

Re: Help me optimize this small Nim port to the speed of the original C version

2019-08-26 Thread Stefan_Salewski
One more short look... tstack_p--; Run tstack_p -= 1 Run You know that C pointer arithmetic is very different from plain integer arithmetic?

Re: Help me optimize this small Nim port to the speed of the original C version

2019-08-26 Thread Stefan_Salewski
> Nim uses half of the memory That is strange. You do both of your tests with 32 bit OS, or both with 64 bit OS? One more remark: You used int32 and float32 data types in your Nim version -- that seems to answer my initial question, you have not used c2nim for code transfer. I think there is

Re: Need debugging help

2019-08-26 Thread Stefan_Salewski
May this help: [https://github.com/nim-lang/Nim/wiki/Hunting-crashes:-The-ultimate-guide](https://github.com/nim-lang/Nim/wiki/Hunting-crashes:-The-ultimate-guide)

Re: Help me optimize this small Nim port to the speed of the original C version

2019-08-26 Thread Stefan_Salewski
One more idea: What is the option for gcc? Nim passes -O3 to gcc by default, while C programs most of the times use only -O2. -O3 can significantly grow the executable size -- generally O3 should be not slower than O2, but for rare cases it may be slower. And you may try option -flto for link

What EXCACTLY is pure pragma in object declaration?

2019-08-25 Thread Stefan_Salewski
[https://nim-lang.github.io/Nim/manual.html#pragmas-pure-pragma](https://nim-lang.github.io/Nim/manual.html#pragmas-pure-pragma) type O {.pure.} = object i: int var o: O echo sizeof(o) Run Output is 8 with and without pure pragma for 64 bit

<    1   2   3   4   5   6   7   8   9   >