Re: [Suggestion] A syntactic sugar for cast.

2018-08-03 Thread Stefan_Salewski
You may read again the manual section ncrosby cited, or read tutorial: [https://nim-lang.org/docs/tut2.html#object-oriented-programming-type-conversions](https://nim-lang.org/docs/tut2.html#object-oriented-programming-type-conversions) In Nim we generally avoid casts, but we may do type

Set of enums with holes

2018-07-30 Thread Stefan_Salewski
Recently someone complained about gintro not working well with latest Nim devel. Well not too surprising due to a few breaking changes. [https://github.com/StefanSalewski/gintro/issues/28](https://github.com/StefanSalewski/gintro/issues/28) I have just tried to try it with latest devel -- do

Re: Generating pascal interface

2018-08-01 Thread Stefan_Salewski
I think what you wants to do is plain text processing. For that you do not need Nim macros, you may use module strutils and related modules, maybe also pattern matching. Basically you parse the input nim file, and then write the pascal interface file with that data.

Re: Going to Haxe. Nim In Action book available.

2016-08-11 Thread Stefan_Salewski
> Got it. I will bookmark it in my mail folder, so i can send you the book > later. Why that effort? See google or Manning page: [https://account.manning.com/support](https://account.manning.com/support) Section shipping: I need to change my shipping address on a pending order. Please send a

Re: nim-ffmpeg wrapper: how to continue?

2017-11-02 Thread Stefan_Salewski
Yes, the reordering can be much manual work. For the gintro module, I do it automatically now, but it takes a few minutes to finish -- and it is based on gobject-introspection. The ugly way is to put all types into a single type section at the front of the module. Many modules from early days

Re: Differences: Object variant vs static conditional fields

2017-09-06 Thread Stefan_Salewski
You can store variables of type Node all in one single seq. For node2: I really think that there is no way to store variables of type Node2[nkInt] and Node2[nkFloat] in the same seq. So Node 1 is more dynamic. But I am not really sure, have never used object variants...

Re: completely new to programming

2017-11-13 Thread Stefan_Salewski
> I say this as someone who spent decades writing C code So you did exactly what I suggest Of course it is difficult to make suggestions to puwad as we don't know him. But starting with Nim TODAY for a real beginner is really hard. And Nim in Action is not a book teaching Nim for beginners.

Re: Partial casing is foo_bar

2016-07-19 Thread Stefan_Salewski
@cdunn2001 > partial-casing causes problems. Can you provide examples? For the gtk related libs, I had initially indeed problems two years ago when Nimrod was fully style insensitive. But now with partial casing there are no problems, types like Buffer start with capital letter, and procs or

Fun with deduplicate

2016-11-08 Thread Stefan_Salewski
I wonder if sequtils.deduplicate() should be renamed to deduplicated() as it returns a seq like sorted()? And maybe it should be noted that it is O(n^2), which is fine for small collections, but not so nice for large ones. And maybe we should add a O(n) deduplicate to stdlib -- sets modul is

Re: Nim in Action is now available!

2016-10-25 Thread Stefan_Salewski
I just got version 9 of the meap. I was curious about the actual improvement work of the manning people. My early expectation was that they would not do much, indeed I think they can not do much, just because they do not understand the matter. So only a few grammar fixes remain to them, and I

Re: Extending objects and initialization

2017-06-02 Thread Stefan_Salewski
That is very interesting, thanks. (As you know, I am using your module combinatorics.nim in [https://github.com/StefanSalewski/nim-gi2](https://github.com/StefanSalewski/nim-gi2). Would be nice if that module would be put into Nim's standard lib -- it works fine, but I have never tried to

Re: How to implement a dynamic array

2017-06-11 Thread Stefan_Salewski
> I got a Data Structures book Which book do you have? Do you like it? > I know how to do it with Java Can you show us your code? I would like to learn how to do it in Java. Basically, what you need to build something like Nim's seq is allocating chunks of memory from the OS. You may inspect

Re: Games made in Nim

2017-05-18 Thread Stefan_Salewski
[https://forum.nim-lang.org/t/2924#18358](https://forum.nim-lang.org/t/2924#18358) [https://github.com/StefanSalewski/nim-chess3](https://github.com/StefanSalewski/nim-chess3) [https://github.com/fragworks/frag](https://github.com/fragworks/frag) I think there are already more, some commercial

Re: Full nimble support for gintro package (high level GTK3 GUI) available

2018-03-04 Thread Stefan_Salewski
Should work for Windows 10 also now. As Araq recommended, I removed the single quotes in the wget and nimgrab command strings. You just have to ensure that all needed GTK3 libs are installed on your Windows box before gintro install. You may follow user zetashift's advise, but don't forget to

Re: Nim GC Performance

2016-12-02 Thread Stefan_Salewski
Thanks for the link, sounds interesting, will read soon... For your test code, I am not really sure what the purpose is. Nim's realtime GC is tunable, so you can get very short pause time with a tradeoff in throughput. See

Re: Compiler crashes while compiling module with

2018-02-25 Thread Stefan_Salewski
> I managed to reduce the crash to this Great. Maybe test if it only occurs for Natural or also for int, and create an issue for github issue tracker. Should be a task for Zachary.

Why is integer multiplication so slow here?

2018-04-23 Thread Stefan_Salewski
proc main = var s = 0 for i in 0 .. 10: if i * i == 49: #if i == 7: s += 1 echo s main() For this test, using "if i == 7" instead of "if i * i == 49" gives half runtime on my box. This is a bit surprising as multiply is

Re: question about templates / namespaces / modules

2017-11-12 Thread Stefan_Salewski
Have you tried something like when AVX2_Available(): Of course that can only work when your AVX2_Available() is known at compile time...

Re: Get base object from inherited object.

2017-09-01 Thread Stefan_Salewski
Calling getType() multiple times may give you the parents, I did that here: [https://github.com/StefanSalewski/gintro/blob/master/gintro/gimpl.nim#L12](https://github.com/StefanSalewski/gintro/blob/master/gintro/gimpl.nim#L12) I got it from a hint of Araq, I have no idea what really is

Re: Though about identifiers in text editors.

2018-04-04 Thread Stefan_Salewski
> Why not calling Nimsuggest on space hits and carriage returns only ? Yes this is one solution, but I was not really happy with it. In the general case one single keystroke can change highlight of the whole file. For example when we modify a var or type definition all occurrences of that var

Re: Question about arrangement of source files with modules

2017-03-22 Thread Stefan_Salewski
Yes, nimsuggest works really not bad now. For example I can investigate tables.nim fine, jumping to impl works also. One problem are still the generic procs, that symbols seems to be inactive, I guess there is already an hard issue in bug tracker. Now I consider supporting the outline and

Re: GTK 3.20 Nim wrapper

2016-12-24 Thread Stefan_Salewski
> I'm confused in all that pointer-reference-object_itself stuff I have already downloaded the source code of librsvg-2.40.16. Seems to be really a tiny lib, and the c headers contains not many strange macros, so building the wrapper should be easy. (There are bitfields used, but fortunately

Re: Basic pointer question

2018-02-22 Thread Stefan_Salewski
OK, I think I see your problem. In Nim an empty subscript [] notation can be used to derefer a reference or ptr. So if p is a pointer to string, in C++ you would write '*'p to dereference it, but in Nim you write p[]. And in Nim you can write p[n] to access the n'th character in that string. I

Why does this not compile, and how can I fix it?

2017-09-23 Thread Stefan_Salewski
import strutils type App = ref object of RootObj i: int proc isDigit(app: App) = discard macro xconnect(widget: RootRef; signal: string; p: typed; arg: typed; ignoreArg: bool): untyped = discard proc main = let app: App =

Re: Subtle memory management error found

2017-09-15 Thread Stefan_Salewski
> Can you show me how to do that? When you are using the Nim compiler from the command line, then in the current working directory a subdirectory with name nimcache is created. For example "nim c test.nim" creates "nimcache/test.c". You can inspect that intermediate C code. When you have clang

Re: compiler error in 0.18.0 ??

2018-03-06 Thread Stefan_Salewski
jzakiya, you may wonder why your program eats that much memory. I had just looked at you code, and tried this: #for byt in seg[0..Kn-1]: # count the twin primes in the segment # primecnt += uint(pbits[byt]) # count the '0' bit pairs as twin primes for jj

Re: Dynamic Object Type Fields

2016-07-29 Thread Stefan_Salewski
> So soemthing like Python's setattr() doesn't exist then? I think when you want support for dynamic runtime attributes, you have to prepare for it in a compiled language. For example you can add a field of type seq or table to your object and a proc for adding data to this field. Of course in

Re: Howto make arbitrary macro parameters persistant (non volatile)

2017-06-22 Thread Stefan_Salewski
Yes sure, Nim's strings are garbage collected, so GC_ref is available. But the user can pass really arbitrary data, maybe plain ints. Maybe I should just use "when compiles(GC_ref(data))". Maybe not the smartest solution, but should work. Then I only still have to learn how I copy data, I guess

Re: float64 hash

2017-04-29 Thread Stefan_Salewski
Hashing floats is not that trivial. A common problem are rounding errors. Do you want/need identical hash for i.e. (3.0 + 4.0) and (7.0)? If yes, then it may be necessary to mask the less significant bits before applying the hash function. So, before choosing a concrete optimal hash function,

Re: What do you think about Redox and Electron?

2017-01-08 Thread Stefan_Salewski
I heard about Rust OS some months ago (Is there one more than Redox). I think that is very interesting, indeed that would be my main motivation to learn Rust language deeply. But it is very hard for new operating systems to become popular. For Linux it was a bit different, because it was only

Re: Nim versus Julia benchmark comparison

2017-12-01 Thread Stefan_Salewski
And can you please try to avoid the ugly cast: #var u:array[4,int64] = cast[array[4,int64]]([60,1,342,0]) var u: array[4, int64] = [60.int64, 1, 342, 0] # should work -- if not tell Araq

Re: Generating a const by a proc -- unexpected result

2016-09-08 Thread Stefan_Salewski
Thanks. Should I add that example to Nim's github issue tracker?

Re: Fastest way to count number of lines

2017-10-20 Thread Stefan_Salewski
If speed is really important for you, you may consider SIMD instructions. D. Lemire gave an example for this in his nice blog: [https://lemire.me/blog/2017/02/14/how-fast-can-you-count-lines](https://lemire.me/blog/2017/02/14/how-fast-can-you-count-lines)/

Re: Windows nim binaries freeze

2016-06-26 Thread Stefan_Salewski
:

GetType() for object type macro parameter

2017-08-28 Thread Stefan_Salewski
import macros type S = string I = int O = object i: int P = ref O var i: I var s: S var p: P var o: O macro mconnect(arg: typed): typed = let at = getType(arg) echo $(at.toStrLit) if at.len > 1:

Re: Help with parallelizing a loop

2017-11-03 Thread Stefan_Salewski
Indeed Jack, I think sync() is nonsense when parallel statement is used.

Re: Nim in Action is now available!

2016-10-30 Thread Stefan_Salewski
> IMO your rewording of the explanation of forward declaration also leaves > something to be desired. Yes, it is difficult to explain, for me, in english. I just tried, as only complaining is sometime too easy. For the forward declaration, I think there is already a secret pragma to make it

Re: Shift operation for array elements

2016-09-24 Thread Stefan_Salewski
@OderWat Sorry, can not really understand... Somethink like memCopy or memMove? That was my first idea, but I was very unsure what would happen when array elements are not somethink like plain ints, but objects with refs. Would that confuse the GC? And of course one may ask if array shifting

Re: Strings and C.

2018-02-18 Thread Stefan_Salewski
It is generally a bad idea to send the whole seq to C function because there may reside additional data like seq length at start of memory chunk. Try to use address of first element of the sequence instead.

My first nimble package

2017-07-07 Thread Stefan_Salewski
stefan@nuc ~/gintro $ ls -lt total 40 drwxr-xr-x 1 stefan stefan 210 Jul 7 00:31 gintro -rw-r--r-- 1 stefan stefan 2288 Jul 7 00:30 gintro.nimble drwxr-xr-x 1 stefan stefan48 Jul 6 17:32 tests drwxr-xr-x 1 stefan stefan94 Jul 6 15:27 examples -rw-r--r--

Re: int literals and if statement

2017-07-07 Thread Stefan_Salewski
Kerp, you are working on the Vulkan bindings? Great! For C flags you should strongly consider using Nim's sets! I did that for the high level GTK bindings recently. Have code like type RegionFlag* {.size: sizeof(cint), pure.} = enum even = 1 odd = 2

Re: Tabulation symbols not allowed

2016-09-08 Thread Stefan_Salewski
> The big problem I've had with tabs was in team programming, But there is no problem, as long as tabs and spaces are not mixed for indentation purpose in a single file. And no one wants to allow mixing. There is one big advantage of tabs: Indent width can be freely configured, without the

Error: illegal capture 'a' -- I have no idea what that means

2016-12-07 Thread Stefan_Salewski
import random, algorithm # a < b ==> cmp(a, b) < 0 proc cmp(a, b: int): int = (a > b).int - (a < b).int proc quicksort(a: var openarray[int]; left, right: int; cp: proc (a, b: int): int) = proc qsort(left, right: int) = var l, r, p: int let

Seq with custom fields

2017-01-04 Thread Stefan_Salewski
I think I have still not really learned that. I think I may write something like type ExtSeq = object s: seq[int] timestamp: string var es: ExtSeq # init es.s.add(7) echo es.s[0] echo es.timestamp But I would

Re: cannot countProcessor in compile time

2018-05-21 Thread Stefan_Salewski
> If you really need to know the number of processors on a system, you could > always compile a sub-program during compile-time and invoke it. Indeed I assumed that. But I have no idea how to do it in detail in a user friendly way -- so that user can still do a plain "nimble install myTool".

Re: Is this a compiler bug?

2016-09-09 Thread Stefan_Salewski
I would have expected that the compiler sees that the proc parameter does not match and so ignores that proc and assumes that a type conversion is intended.

Re: GTK 3.20 Nim wrapper

2016-12-22 Thread Stefan_Salewski
> @Stefan_Salewski, seems that RsvgHandle has not svg data it's nil instead Of course making such a gtk related wrapper is not fully trivial. I think I once said that RSVG is not a very big library, so it should not be too much work to make the wrapper. Unfortunately I have never used R

Can var proc parameters be faster than function results?

2017-04-18 Thread Stefan_Salewski
Of course for plain compilers var parameters can be faster, because without smart optimizations result objects can be first allocated on the proc stack and then copied back to the caller variable. But I had the strong feeling that this optimization is generally done, so I never tried to

Re: Blog post about Nim performance tuning

2017-04-29 Thread Stefan_Salewski
Nice -- I already saw it some days ago. Will read it carefully soon...

Re: Why takes this code 22ns with cstring and 52ns with string?

2017-01-24 Thread Stefan_Salewski
Indeed -- putting all that test code in a proc make differences disappear! I am aware of performance problems of code outside of procs, but I really had not thought that that was the problem in this case. And I had not assumed that it makes 30 ns difference for a proc call. I think in future I

Re: My first nimble package

2017-07-07 Thread Stefan_Salewski
Well, this is the cleaned up version. We do check for dev packages on ubuntu, check if tmp dir already exists and delete tmp dir when done. Problem with mode = Whatif was that Whatif is a pure enum, issue is posted. The modules still import each other directly, without the gintro prefix. Seems

Re: Surprises with Generics

2017-11-12 Thread Stefan_Salewski
Reading this blog post [http://nibblestew.blogspot.de/2017/11/aiming-for-c-sorting-speed-with-plain-c.html](http://nibblestew.blogspot.de/2017/11/aiming-for-c-sorting-speed-with-plain-c.html) > I just remembered a discussion some time ago: S. Salewski wrote: > A consequence may be, that for

Re: Why is integer multiplication so slow here?

2018-04-23 Thread Stefan_Salewski
Hlaaftana, thanks for confirming. I was really tired yesterday and though I was doing something wrong. cdome, your message makes not too much sense for me currently. Indeed I tried using unlikely() for this test, which made no difference, as expected, as automatic branch prediction should work

Re: pixbuf_new_from_stock

2016-12-09 Thread Stefan_Salewski
What do you think where the problem is? Are you following a C example or the Krause book? As you know I am using only GTK3 -- but from my memory of examples and the Krause book I think that the second parameter of gtk_image_new_from_stock is generally a C enum of type GtkIconSize. So allowed

Re: register pragma

2017-01-20 Thread Stefan_Salewski
Have you tried something like var mycounter {.register.} = 0 You can check the C sources if it is applied, but as the manual says, in nearly all cases the (C) compiler knows better.

Re: Nim Chess 2 with transposition table support is available

2017-04-30 Thread Stefan_Salewski
Version 3 is now available! [https://github.com/StefanSalewski/nim-chess3](https://github.com/StefanSalewski/nim-chess3) Ram usage is reduced to about 340 MB, and I tried some other improvements. Not much tested yet. Nimble install is still not possible, but for Linux a copy and past of the

Re: TaintedString.parseInt problem

2016-08-07 Thread Stefan_Salewski
Why not use echo to see the content of the string you pass to parseInt? Note: for bash command expr / indicates integer division. For Nim / is floating point division, you may use div for integer division, or you may round the floating point result. So may guess is that you pass a floating

Re: GTK 3.20 Nim wrapper

2016-10-31 Thread Stefan_Salewski
No not as a library. But I have not investigated the remaining crashes. I worked on it two months ago for the last time and used the editor then while working on the chess game. For me some crashes are no problem, I saved every ten minutes. And I think there are no other users beside me. One

Re: Using cstringArray and allocCstringArray

2017-07-10 Thread Stefan_Salewski
> but allocCstringArray wants a openarray of string. So you should give it one. You should know how you can create an array or a seq of strings. When you know that 256 chars are desired for each string, then you fill the array with strings with at least this size. And finally you pass that

Fast branchless sign() function

2016-09-30 Thread Stefan_Salewski
[http://stackoverflow.com/questions/14579920/fast-sign-of-integer-in-c](http://forum.nim-lang.org///stackoverflow.com/questions/14579920/fast-sign-of-integer-in-c) I would like to have a sign function in std lib. I was really surprised that the brachless variant makes such a difference -- I had

Re: GTK 3.20 Nim wrapper

2016-08-06 Thread Stefan_Salewski
The plain Nim GTK3 editor is now available in version 0.2 [https://github.com/ngtk3/NEd](https://github.com/ngtk3/NEd) I have added multiview support, fixed the GTK related modules and added a short Asciidoc Readme. Not really tested yet. You should be able to compile it at least on 64 bit

Re: Howto make arbitrary macro parameters persistant (non volatile)

2017-06-22 Thread Stefan_Salewski
Araq, the deepCopy() part works fine with string and int parameters, but unfortunately not with objects. I got it working, when I substitute at by "ParObj" literal everywhere: (Of course that makes no sense for general use case) type ParObj = object x: float

Re: Big integer litterals

2018-03-06 Thread Stefan_Salewski
@lscrd Nim 0.18 is correct indeed -- see language manual: Pre-defined integer types These integer types are pre-defined: int the generic signed integer type; its size is platform dependent and has the same size as a pointer. This type should be used in

Re: Bug (?) with templates

2018-01-02 Thread Stefan_Salewski
template bar() = echo a template foo() {.dirty.} = let a = 5 bar() foo() echo a I would expect exactly that behaviour. As templates a hygienic by default, we need dirty pragma for foo() to make variable visible outside.

Re: Nim vs D

2017-07-06 Thread Stefan_Salewski
> Without main function: 5.004 s With main function: 3.126 s That is really some magic which we should investigate, document and remember.

Re: GTK 3.20 Nim wrapper

2016-09-10 Thread Stefan_Salewski
> Yes, a couple of fixes and it worked. If you want I'll write more detailed. Yes, would be fine. Araq just told me that he regards proc names like int32 invalid -- they shadow type conversions. So I have to filter all the GTK3 related modules for proc names which may conflict with type names.

Re: Will Nim in Action also be printed in colorful?

2016-07-22 Thread Stefan_Salewski
The paper version was announced as "printed in black & white". [https://manning.com/books/nim-in-action?a_aid=niminaction_bid=78a27e81](https://manning.com/books/nim-in-action?a_aid=niminaction_bid=78a27e81) But the ebub and PDF version has color and looks nice. There is no reason to buy paper

Creating a new seq is not that fast

2017-04-17 Thread Stefan_Salewski
Of course not, there is much allocation work involved. But about 500 ns (a few thousand CPU cycles) is indeed more as my expectations. I discovered that when tuning my chess engine -- using one more tiny seq noticeable reduced performance. Of course seq's are convenient, because of existing

Re: Total noob, statically allocated circular buffer on microcontroller question

2018-05-01 Thread Stefan_Salewski
> running Nim code on a medium size MSP430 32K Flash, 4K RAM. The > MSP430F5510-STK board from Olimex. Interesting. Can you access all the registers already? Do you use GC? Your project based on [https://github.com/lonetech/nim-msp430](https://github.com/lonetech/nim-msp430) ? Circular

Re: compile time code execution problem

2017-11-04 Thread Stefan_Salewski
> Coming from Ruby/Elixir, Maybe some C exercises would help Note that modpg.unit and rescnt.uint are not plain casts (reinterpretation of bit pattern) but type conversions. Type conversions may ensure that the values are not negative before conversion and raise exceptions otherwise. I don't

Re: Fun with rdtsc() microbenchmarks

2016-12-15 Thread Stefan_Salewski
Well, more meaningful and even more funny is this code with random numbers, where the compilers really can not remove the proc calls: import random proc rdtsc(): int64 = var hi, lo: uint32 asm """ rdtsc :"=a"(`lo`), "=d"(`hi`) """ result =

Re: Nim GC Performance

2016-12-06 Thread Stefan_Salewski
@Varriount Is your conclusion really fair? The Go benchmark seems to include no special tweaking. Araqs version switched of cycle detection. That may be fine for this small example. But when I have a real word complex program, can I be sure that I can switch of cycle detection? For all my

Re: Big integer litterals

2018-03-03 Thread Stefan_Salewski
That is an interesting topic. When you try var x: int = 10 * 1_000_000_000 it seems to compile fine on a 64 bit Linux box. So problem is the constant itself. But what I really ask myself: How does var x = 10 * 1_000_000_000 behave on 32 and 64 bit OS. Is x

Is for procs only one generic parameter allowed?

2017-12-01 Thread Stefan_Salewski
I tried to create a generic RTree. Beginning was easy, tests of union() and intersect() was working fine. But I did not got search() working -- it gets a rtree parameter and a box, which both are generic. I tried with proc p() which compiles when one of the parameters is used, but not when both

Re: To optimize operation of replacement of lines in the file

2016-07-14 Thread Stefan_Salewski
Do you want to search for regular expressions or for plain strings? Plain strings should be faster of course.

Re: Problem using

2017-10-20 Thread Stefan_Salewski
Now in your code there is no spawn at all! For parallel processing, you have to ensure that there are no conflicts when parallel tasks are accessing your data, otherwise the compiler may make copies of the data before, which may make it slow. And for parallel processing a good use of the CPU

Re: progress while binding libxl

2017-06-23 Thread Stefan_Salewski
> still be Greek for me. Well, the when statement is really easy to understand and well explained in the manual, so maybe you should read it again. It is good to understand it. What you may be looking for is a converter, see manual. A converter allows automatic conversion of proc parameter

Re: Howto make arbitrary macro parameters persistant (non volatile)

2017-06-23 Thread Stefan_Salewski
Well, I have a working solution. I can pass a string, an int, and object from the stack to the callback and it works. (Removing a button and reinserting does not work currently, but that is a different problem.) But I still wonder why I have to use the strange name(type(arg)) way to get the

Re: Partial casing is foo_bar

2016-07-20 Thread Stefan_Salewski
> would like to have a new "alias" functionality Was thinking about it a few times... For example, I have a longer proc with return type View. Can use predefined result variable in the proc, but then I have to remember that result is view. Or I use "var view: View ... return view". alias view

Re: Do we have a RTree or R*Tree for Nim?

2017-12-09 Thread Stefan_Salewski
Currently I favour to let the shape of the code as it is. One question arise: Would it make sense to rewrite code like this [https://github.com/StefanSalewski/RTree/blob/master/rtree.nim#L305](https://github.com/StefanSalewski/RTree/blob/master/rtree.nim#L305) for j in 1 ..<

Re: Allocation on heap somehow unstable - Why does this crash?

2017-07-18 Thread Stefan_Salewski
We had a very similar thread recently: [https://forum.nim-lang.org/t/3054](https://forum.nim-lang.org/t/3054)

Re: How do you install the gtk 3 development libraries and toolchain on Windows 64bit?

2016-09-24 Thread Stefan_Salewski
> Which directory are your GNOME development libraries themselves installed, I am not using Windows. For gentoo linux, command is just "emerge -av gnome". I can search for directory paths, but I guess that will not really help you for Windows. Personally I would be very interested how well

Re: NEd GTK3 editor is available in v 0.3 now -- with full nimsuggest support

2016-12-01 Thread Stefan_Salewski
> I tested it, but I did not have any syntax highlighting. I assume on Linux. Do you have syntax highlighting at all, for example in gedit? Do you have syntax highlighting for other files, maybe xml? You may try with another file extension, like ./ned nimdark1.xml but I just

Re: Nim versus Julia benchmark comparison

2017-12-02 Thread Stefan_Salewski
One more explanation for a factor of 3 - 4 in performance can be of course SIMD instructions. Maybe latest Julia is very good in using SIMD? Maybe you can try clang instead of gcc to see if clang can better apply SIMD and related parallel instructions to your code. (Or Julia may pre-compute

Re: GTK 3.20 Nim wrapper

2016-10-30 Thread Stefan_Salewski
You may try first [https://github.com/ngtk3/nim-chess2](https://github.com/ngtk3/nim-chess2) The readme contains the instructions, which I tested recently with Nim v 0.15.2 on Linux. For Linux you can copy the commands to a file and run the script, bash script.sh. I know that it does not

Re: GUI programming

2016-12-10 Thread Stefan_Salewski
And of course nimx and QML. And note that latest GTK 3.20 wrapper is at [https://github.com/ngtk3](https://github.com/ngtk3), I will delete the old 3.15 wrapper in the next days...

Re: Nim Dynamic Libraries: exporting functions that return pointer-based types

2017-07-10 Thread Stefan_Salewski
> I'm trying to create a Ruby extension in Nim, Interesting, maybe you can collect your insights in a blog or forum post. I have used Ruby too in the past, and I wrote some C extensions for using CGAL and Boost library. While I was told that extending Ruby with C was easier than extending

Re: How to debug a compile error in a template?

2017-12-05 Thread Stefan_Salewski
nim check mycode.nim But it is true, if errors are in code with generics, templates or macros it can occur that there is absolutely no useful hint to the real error location. For example as error position code in system.nim is showed. And some hours ago I had a case with generics

Re: Proc call is blocking call of finalizer

2017-06-09 Thread Stefan_Salewski
OK, that is what I guessed more or less... I think I will try to put all the relevant code into another proc and then call GC_fullCollect() when that proc is finished, then all stack of that proc should be released and finalizer should be called for that objects. Will continue testing GTK3 GC

Re: GUI programming

2016-12-10 Thread Stefan_Salewski
> Do i have to learn a new GUI language for that programming ? When you have experience in GTK3 programming in C already, you can just start with GTK3 and Nim, it is very similar. You can even convert C GTK3 code to Nim with the tool c2nim, do some modifications, and are done. But to be

Re: Is it possible to avoid default array initialization?

2018-02-06 Thread Stefan_Salewski
>From the manual: [https://nim-lang.org/docs/manual.html](https://nim-lang.org/docs/manual.html) The implicit initialization can be avoided for optimization reasons with the noinit pragma: var a {.noInit.}: array [0..1023, char]

Re: Nim in Action is now available!

2016-10-30 Thread Stefan_Salewski
Well, writing books in a foreign language is not easy... You may have noted that this remark from chapter 2 is still not very nice Order of procedures It is important to note that the order of procedures and procedure calls matters. When calling a procedure, it must be

Re: Best 2D game engine for nim?

2016-07-31 Thread Stefan_Salewski
There is a fine tutorial by Dennis: [https://hookrace.net/blog/writing-a-2d-platform-game-in-nim-with-sdl2](https://hookrace.net/blog/writing-a-2d-platform-game-in-nim-with-sdl2)/

Re: Best way to convert sequence of bytes to uint32

2016-11-18 Thread Stefan_Salewski
var i: uint32 s: seq[byte] p: int s = newSeq[byte]() s.add(0) s.add(1) s.add(0) s.add(0) i = (cast[ptr uint32](addr s[p]))[] echo i output is 256, maybe not that wrong. But I am still confused, maybe Dom can add a few more pages

Re: Macro, same parameter in typed and untyped version, and other problems

2017-09-20 Thread Stefan_Salewski
Yes, I have seen that in the Nim manual. Unfortunately such a concept construction is a bit difficult because all the code is automatically generated by use of gobject-introspection. Maybe I will make one manual test case to see if it would work. For now I have broken down the procs into

Any ideas for the "Port already in Use" nimsuggest socket error?

2016-11-11 Thread Stefan_Salewski
In the last days I was going to spent some time debugging the random NEd Nim editor crashes. Unfortunately, while I got some crashes some weeks ago when working on the chess game, I was not able to generate crashes when testing. So I think I have to wait until a real crash occurs again, and

Re: Is nimsuggest expected to work with latest devel?

2016-08-08 Thread Stefan_Salewski
Sorry Araq, IRC just banned my IP again, so I can not answer there... No, I don't used -d:release explicitely. But nimble install should have done that I guess? Will try now with -d:release without nimble.

Re: Execution speed Nim vs. Python

2016-08-10 Thread Stefan_Salewski
> that it is really the const seq which is causing most of the slowdown That is very interesting! I strongly assume that const seg is identical to const array? Have you tested? So this may indicate that we should avoid const arrays when speed is important.

Set of enums -- some caution is needed

2017-09-13 Thread Stefan_Salewski
type E = enum a = 0 b = 1 c = 2 d = 8 EventFlag* {.size: sizeof(cint), pure.} = enum exposure = 1 pointerMotion = 2 pointerMotionHint = 3 buttonMotion = 4 button1Motion = 5 button2Motion = 6

Re: which part of std. lib can work without GC?

2018-05-08 Thread Stefan_Salewski
r3, regarding microcontrollers without operating system you may follow this thread carefully: [https://forum.nim-lang.org/t/3803](https://forum.nim-lang.org/t/3803) As you may know, when we program tiny controllers like 8 bit AVR in C or C++ we generally avoid library stuff like printf,

  1   2   3   4   5   6   7   8   9   >