Re: Question about type safety and OOP

2020-05-25 Thread adrianv
with the conversion of first element in the `seq` `B(val:1).A` you tell the compiler, that you create a `seq[A]`. For the remaining elements you don't need the conversion: var a:seq[A] = @[B(val:1).A, B(val:2)] Run and you can even omit the type declaration for `a`:

Re: Introducing --gc:arc

2020-04-29 Thread adrianv
I recently had a problem with `sink` parameter inference in exported procs. I haven't looked how it is now, but I think that exported procs should never have inferred `sink` parameters, because nim can't be sure in that case.

Re: Learning & Using Nim as a C# user + Fan logo Redesign

2020-01-26 Thread adrianv
hmm the logo somehow reminds of the Haxe logo

Re: What’s your favorite programming language and why?

2019-12-18 Thread adrianv
I like - in the order of appearance in my life: * pascal for showing me that Apple Basic was crap * forth for showing me how powerful it can be to do things in the reverse order * delphi for simplifying GUI development in 1995 * haxe for giving me the ability to program JavaScript or php

Re: binarySearch (from algorithm) not always working

2019-12-16 Thread adrianv
a binary search makes only sense on a sorted array.

Re: sequence of [string,Value] tables VS sequence of (string,value) sequences

2019-10-30 Thread adrianv
if a hash is useful depends on the problem. Hashes are good when you have a _big_ dictionary which does not change (much). If you have only some elements in the dictionary, then the costs for calculating the hash values might be higher than the costs for some compares. And don't forget the costs

Re: Nim for enterprise software development

2019-10-21 Thread adrianv
> Has anyone thought of using Nim with Lazarus LCL or Delphi's VCL? there are several problems here: * memory management * compatibility of standard types like string and dynamic array (=seq) * calling convention The first two are feasible with the new `destructors`. I am writing a libra

Re: 1.0.0 is here

2019-09-24 Thread adrianv
SUCCESS!

Re: rant about shr change

2019-06-02 Thread adrianv
now I am completely confused. When there is a `ashr` (which I have never noticed), why is there the need to change the behavior of `shr` for signed `int`? I can't see the point.

Re: rant about shr change

2019-06-01 Thread adrianv
I agree that `shr` on signed `int` is error prone, but that is how the things are now. To have a save transition I would suggest to have 2 operators `shr` and another one `ashr` or `sar` or whatever with signed shift behavior. We should then deprecate `shr` for signed `int` and in the future mak

rant about shr change

2019-05-30 Thread adrianv
I don't know if I am overreacting, but just realized that Run has changed its meaning from unsigned shit to sign preserving shift. IMHO this breaks a lot of code in a very dangerous way. A more thoughtful solution would have been to introduce a sign preserving operator

Re: closure_methods: OOP purely based on closures

2019-03-29 Thread adrianv
for property access you can use a distinct type and for assignment an operator like := type Obj = ref object fStep: int ObjStepProperty = distinct Obj template step(self: Obj): ObjStepProperty = self.ObjStepProperty proc `:=` (self: ObjStepProper

Re: Owned refs

2019-03-27 Thread adrianv
type specific allocators sound a bit weird for me, but since they are a debug only feature I am ok with it. The distinction between owned and not owned refs is a step forward and worth the work for the change I guess. Deterministic memory and resource management is the way to go. The destructors

Re: strutils find

2019-03-25 Thread adrianv
@dataman thanks that was a really helpful link. @araq I tested my simple hash algorithm against brute forth and BM with that smart tool. It always wins against brute forth. Against BM it wins always for pattern lengths under 16. Given that the BM has always an overhead for the first search I wo

strutils find

2019-03-21 Thread adrianv
playing around with text search (strutils.find) I realized, that the nim find implementation uses a Boyer-Moore algorithm. This is nice in many cases, but there are scenarios where a naive brute force search is faster (small search patterns and/or a simple one shot search like find("nim is a gre

Re: Should we get rid of style insensitivity?

2018-11-19 Thread adrianv
I am OK with the current state - I don't want a vote. If Andreas wants to change it I am OK with it too.

Re: How can I compile for DOS?

2018-11-16 Thread adrianv
But real DOS fun is compiling to 16bit and handling of XMS :) I don't know if Nim supports 16bit word sizes.

Re: Got "Warning: < is deprecated [Deprecated]"

2018-11-05 Thread adrianv
use `..<` without space between `..` and `<`

Re: koch boot fails reading basicopt.txt

2018-10-14 Thread adrianv
now I downgraded my gcc from 8.1 to 7.3 and it works.

Re: koch boot fails reading basicopt.txt

2018-10-14 Thread adrianv
strange it works when I boot with: koch boot -d:release --cc:vcc --cpu:i386 but with koch boot -d:release --cc:vcc --cpu:amd64 I get now another error: msgs.nim(85, 39) Error: ambiguous call; both tables.[](t: var Table[[].A, [].B], key: A)[declared in ..libpurecollectionstables.nim(187, 5)]

koch boot fails reading basicopt.txt

2018-10-14 Thread adrianv
Is it only me ? With actual nim from git, koch boot fails on third iteration with: cannot open file: ../doc/basicopt.txt but only on windows. With nim on linux it works. Any ideas ?

Re: the Fibonacci benchmark

2018-09-30 Thread adrianv
@cblake thanks for the explanation. I will check with the profiler. From what you said I tried this and get almost the same results - now for gcc and g++ and for clang a speed up of about 4x. proc fib(n: int): uint64 = if n > 1 and n != 30: return fib(n - 1) + fib(n - 2)

the Fibonacci benchmark

2018-09-29 Thread adrianv
Hi, on twitter I saw that Nim performed better on fibonacci benchmark than C and C++ ([https://github.com/drujensen/fib](https://github.com/drujensen/fib)) and wondered why. I did my own tests and these are quite interesting:Language| Time in s| compiled with ---|---|--- Nim| 0.456| nim cpp

creating code for C++ class

2018-09-24 Thread adrianv
Hi, I try to subclass a C++ class in nim and implement some features in nim. Here is what I do: {.emit:""" class Foo { public: int data; Foo() {} }; class Bar: public Foo { public: int d2; Bar() : Foo() {} ~Bar(); }

Re: How to get a list of all .nim files compiled for a project

2018-09-20 Thread adrianv
Sorry I was a bit quick with that question - it is not really necessary. I can live with just going over the source directories and add all .nim files to the project.

How to get a list of all .nim files compiled for a project

2018-09-20 Thread adrianv
Hi, I want to integrate nim in C++ Builder. Currently it already works quite nice and I can compile a hybrid project (nim, c++, delphi) from inside C++ Builder. But when I want to debug the the nim code (by using --lineDir:on and --debugInfo) it would be nice to have all the .nim files which ar

Re: Embedding ssl libraries ?

2018-09-05 Thread adrianv
for embedding ssl - have you tried mbedtls [https://tls.mbed.org/](https://tls.mbed.org/). Never used it, but maybe it is what you are looking for.

Re: Winim - Nim's Windows API and COM Library

2018-07-27 Thread adrianv
thank you for your effort

Re: Perfecting Nim

2018-04-24 Thread adrianv
from my point of view things that should go out: * `do` every time I read code which uses do I have to think hard what's going on. * `using` never used it and looks a bit strange to me * `method` is not really usable in it current shape. But we need some OOP. things that should stay or i

Re: cpp compilation into own namespace

2018-03-29 Thread adrianv
I did some deeper research. wrapping the nimbase.h would be wrong it is enough to wrap the TFrame stuff conditionally into a namespace Nim. In the generated code the wrapping should start after the #undef unix or before the first declaration until the end. Would you accept a pull request when I

Re: cpp compilation into own namespace

2018-03-29 Thread adrianv
I am trying to use Embarcadero C++ Builder with Nim. The problem is that by default C++ Builder pulls in all namespaces. So you have name clashes for example with TFrame or Exception. There is a way to avoid this by defining DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE which should prevents this. But

cpp compilation into own namespace

2018-03-27 Thread adrianv
Hi, what do you think about an optional parameter to compile nim code into its own namespace "Nim" (or configurable). When compiling nim code together with a big c++ library it is very likely to get name clashes with the existing code - for example names like TFrame or Exception are used very o

Re: Is there any way to create template with await?

2018-03-23 Thread adrianv
What does yield inside a template do ? The documentations says yield is only valid inside an iterator.

Re: How to turn thread spawn call into an async call

2018-03-19 Thread adrianv
nice

Re: How to turn thread spawn call into an async call

2018-03-17 Thread adrianv
I agree that would be fine. The two are very similar. To avoid the polling, threadpool should be able to transfer the result of its work to the async dispatch list of the calling thread when its done. expanding my example you could do: import os, asyncdispatch, threadpool

Re: How to turn thread spawn call into an async call

2018-03-15 Thread adrianv
you can also busy poll the result of the spawned proc in an async proc like that: import os, asyncdispatch, threadpool proc doWork(): bool = # staff use sql echo "starting..." sleep(5000) # complete the future var echo "... ok"

Re: Why is my destructor not called?

2018-01-06 Thread adrianv
why should it be called ? x is global and gets never out of scope.

Re: real inline for inline procs or converters

2017-10-24 Thread adrianv
not a real problem - but for JavaScript there is no inlining of procs. And for converters I would prefer to have the choice if they are inlined by nim or not, but the more I think about it, the benefit would be just cosmetic.

real inline for inline procs or converters

2017-10-24 Thread adrianv
Hi, just wanted to know if there is a reason (other than we more important things to do than that), why procs and converters are not inlined by nim when marked as such. I know you can always use a template - but not for converters (normally they are just a cast to make the typing the way you wa

Re: What's happening with destructors?

2017-10-21 Thread adrianv
@rayman22201 what I have seen is, that each proc that has a var of a type which is handled by a destructor needs a hidden try finally block (currently even if the var is not used). This can be a big overhead for small routines. The c target needs setjump/longjump which is a big overhead. The cpp

Re: Pascal type to nim

2017-10-10 Thread adrianv
object variants are not exactly the same, because you always need the extra tag - byte b here. In pascal you don't need a stored tag (like in the question). I guess the union should result in the same memory layout.

Re: Winim - Nim's Windows API and COM Library

2017-07-05 Thread adrianv
very nice library ! @Ward: How did you translate the interfaces ? manually, with c2nim or another tool. It would be nice to have a tool to import type libraries.

Re: Strange problem -- array is much slower than seq

2017-06-15 Thread adrianv
Its not about refuting your educated guess - because you know and we are only guessing. On the contrary its only for the understanding for the simpler minds like me With increasing the ref count for the strings in the array I partly disabled the GC for these strings but not for the other GCed d

Re: Strange problem -- array is much slower than seq

2017-06-15 Thread adrianv
I just made a small test and increased the ref count of each string in the array at the beginning and decreased it at the end. The result is, that the time of array variant decreased from 15sec to 2 sec on my PC. import random import hashes import times import math i

Re: Strange problem -- array is much slower than seq

2017-06-15 Thread adrianv
you are right, my conclusion was to simplistic. It doesn't matter if an array on the stack holds non ref data. > I do not understand currently why the seq is no problem for the GC I don't know either, but I guess its because the GC has to check all the roots on the stack. For the seq it has onl

Re: Strange problem -- array is much slower than seq

2017-06-15 Thread adrianv
Good to know. Than any consideration to have data allocated on the stack to avoid allocations, turns out as a performance killer as long as the GC plays its game in the background.

Re: Version 0.17.0 released!

2017-05-20 Thread adrianv
> Ahhh damn, I thought you'd go for the first option and add the feature soon me too - normally documentation takes longer than implementation...

Re: Version 0.17.0 released!

2017-05-18 Thread adrianv
congrats! How can I activate the VTable types described in the manual [https://nim-lang.org/docs/manual.html#generics-vtable-types](https://nim-lang.org/docs/manual.html#generics-vtable-types) ? I tried thy example from the manual but the compiler complains about undeclared identifier vtref.

Re: pas2nim improved

2017-03-28 Thread adrianv
should have done it a lot earlier

pas2nim improved

2017-03-28 Thread adrianv
For anybody who is interested in converting object pascal to nim, I have created a fork of pas2nim [https://github.com/AdrianV/pas2nim](https://github.com/AdrianV/pas2nim) which parses and converts a big amount of object pascal code: * class is converted to ref object * class, object and

Re: Are large projects slow to recompile?

2016-11-17 Thread adrianv
@Araq cool

Re: New blog posting

2016-10-04 Thread adrianv
nice post - now the perl guys can use nim too