Re: Nim nightly builds

2019-01-23 Thread kaushalmodi
@demotomohiro The Nim nightlies repo has been updated so that the releases are named with a new scheme: `--`. New releases with this new naming scheme will be out in about 1-2 hours. Then you can get the JSON data [https://api.github.com/repos/nim-lang/nightlies/releases](https://api.github.co

Re: Compiler - redefinition error message problem.

2019-01-23 Thread Araq
Don't `include` the same file twice, neither directly nor indirectly. Use `import` instead of `include`.

Compiler - redefinition error message problem.

2019-01-23 Thread bobg
I put together a Nim program that works and then I tore it apart to put pieces in separate files (to collect type, var, proc which concern separate parts of the program) - combining them all with 'include xx' in a main program, plus other additions. Thus I have a small main program and 3 more or

Re: Nim nightly builds

2019-01-23 Thread kaushalmodi
I think you would need to look at both 0th and 1st elements returned in the JSON at [https://api.github.com/repos/nim-lang/nightlies/releases](https://api.github.com/repos/nim-lang/nightlies/releases), and then get the element where the `name` field matches `"-bdevel-"`. _I just committed this

Re: Nim nightly builds

2019-01-23 Thread kaushalmodi
> Problem is this URL doesn't always return latest devel version That's correct. You will need to use the GitHub API and get the required release after parsing the JSON. Here's an example I found in wild: [https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c](https://gist.github.

Re: Nim nightly builds

2019-01-23 Thread demotomohiro
That PR has been merged and official nightly build is available on wandbox. But when I select a nim HEAD on wandbox, it uses nim-0.19.2 not 0.19.9. Problem is this URL doesn't always return latest devel version (currently, it is ver 0.19.9), but it could return a latest stable version (0.19.2)

Re: generic instantiation with object inheritance

2019-01-23 Thread Araq
Well inheritance works too, it's the `method` keyword which doesn't. Use case/if instead of method and you will be fine. :-)

Re: generic instantiation with object inheritance

2019-01-23 Thread e
@Araq, The advantage I am trying to achieve is to minimize memory utilization. If I use variants to represent my nodes, I get a union from the Nim code generator: struct tyObject_BBTreecolonObjectType__J7jcHxXTiq5WhuKk2uaAGQ { tyEnum_NodeKind_9bCibRYMAQfBZ6GB8aWzvUA kind;

Re: Deleting a certain value from a sequence

2019-01-23 Thread lotzz
I like @Araq s suggestion as well lol

Re: Deleting a certain value from a sequence

2019-01-23 Thread miran
> I have the feeling that finding find is hard for beginners, as it is hidden > in system. How can we improve that? I currently don't have the answer, but maybe @dom96's [proposal](https://github.com/nim-lang/Nim/issues/10385) would be the way to go?

Re: generic instantiation with object inheritance

2019-01-23 Thread Araq
It works just fine for me, [https://github.com/nim-lang/Nim/blob/devel/compiler/btrees.nim](https://github.com/nim-lang/Nim/blob/devel/compiler/btrees.nim) but indeed I don't use inheritance or methods for it, because even if they don't make Nim explode, they have no advantages.

Re: change string iteration start?

2019-01-23 Thread Araq
You can use this with (almost?) no overhead: iterator span(s: string; first: int, last: BackwardsIndex): char = for i in first..s.len - last.int: yield s[i] let s = ".something" for c in s.span(1, ^1): echo c Run

Re: Deleting a certain value from a sequence

2019-01-23 Thread Stefan_Salewski
miran, I have the feeling that finding find is hard for beginners, as it is hidden in system. How can we improve that? So that people looking for seq "class" see all related procs immediately. And we should have a proc findByValue().

Re: change string iteration start?

2019-01-23 Thread Stefan_Salewski
When performance is really critical you should test it yourself, otherwise all solutions are ok. Second and third example should be identical. The question is of both of them do copy the initial string s. I don't know, but a copy is fast. You may also consider using pairs iterator, which gives

Re: Module typeinfo, can't access field by name. Bug or not?

2019-01-23 Thread moigagoo
I ended up writing these templates to convert bracket notation to dot notation: import macros macro `[]`*(obj: object, fieldName: string): untyped = ## Access object field value by name: ``obj["field"]`` translates to ``obj.field``. runnableExamples:

Re: Deleting a certain value from a sequence

2019-01-23 Thread Stefan_Salewski
You would use system.find() to get the index and then del() or delete() to delete the entry. Of course find() is O(N) so it is not that fast for large seqs. [https://nim-lang.org/docs/system.html#find%2CT%2CS](https://nim-lang.org/docs/system.html#find%2CT%2CS) Maybe use another data structure

Re: Deleting a certain value from a sequence

2019-01-23 Thread miran
`import sequtils var a = @[1, 2, 3] a.delete(a.find(3)) ` Run

Re: How to check if all values in Table are empty?

2019-01-23 Thread Stefan_Salewski
Note, when your keys are integers you may consider using a seq or array for your objects, especially when keys are am continues range. That may be more efficient. What you now use is a hash table with keys as int and seq as values, but you seems not to delete the entries when done, but you repl

Deleting a certain value from a sequence

2019-01-23 Thread cag104
Example: a = @[1, 2, 3] Run I want to delete the value 3 from the sequence without using its index. Is there a way to specify a value to delete from a sequence? I know you can do: a.del(2) Run But this isn't what I want. Any ideas?

How to check if all values in Table are empty?

2019-01-23 Thread cag104
I am trying to figure out how to determine whether all values in a Table are empty. starting graph: {1: @[0], 2: @[1, 6], 3: @[2], 4: @[2], 5: @[4], 6: @[5, 8], 7: @[9], 8: @[7], 9: @[6], 0: @[3]} Run I delete a value after doing something for several iterations. I st