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.
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 =
> 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)
Nim uses odd minor version numbers to denote development releases and even
minor version numbers to denote stable releases. That is common practice, see
> 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
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
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
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.
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)
> 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
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.
> 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:
Is that related to
[https://forum.nim-lang.org/t/1703](https://forum.nim-lang.org/t/1703) ?
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)
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.
Only advantage is avoiding namespace collisions and the fact that the reader of
the source code can easily see the origin of the symbols.
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.
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
See also
[https://forum.nim-lang.org/t/4745](https://forum.nim-lang.org/t/4745)
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
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.
Also note that google will point you to
[https://gist.github.com/deefdragon1/2336e2404c468c3c59f1ef670745a920](https://gist.github.com/deefdragon1/2336e2404c468c3c59f1ef670745a920)
> 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
> 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
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
Same behaviour when compiled in debug mode, and with -d:release and -d:danger?
Can you try another GC, maybe boehm?
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
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
[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 =
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.
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
` nimble search audio `
Run
> 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
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.
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
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)
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)
> 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
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
> 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
You can explain someone who ask you about the current time how to built his own
atomic clock. But that is not always necessary.
> 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
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
See also
[https://forum.nim-lang.org/t/5192](https://forum.nim-lang.org/t/5192)
> 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
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
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
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.
> 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
> 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
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
> 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.
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)
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];
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
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
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.
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
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.
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
> ... 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
> 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
Your Java chess engine is using bitboards?
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
> There are no default values
But there are rumors that we may get them for Nim > 1.0
Funny, I did a chess game too some years ago.
[https://github.com/StefanSalewski/nim-chess4](https://github.com/StefanSalewski/nim-chess4)
> 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
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
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
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
>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
> 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
> 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
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,
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.
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
> 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.
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
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
> 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
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
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
Also see
[https://github.com/nim-lang/website/issues/162](https://github.com/nim-lang/website/issues/162)
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
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
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
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
> 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.
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
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
> 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
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)
> 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
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:
# 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:
One more short look...
tstack_p--;
Run
tstack_p -= 1
Run
You know that C pointer arithmetic is very different from plain integer
arithmetic?
> 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
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)
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
[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
201 - 300 of 880 matches
Mail list logo