Re: Saying hi

2018-12-29 Thread rect0x51
So... is this accurate? **Today:** Each thread has its own memory heap and GC. This eliminates pauses and race conditions but impairs efficiency because the communication between threads is less nimble (can only exchange messages but no other data). **Tomorrow:** ARC will allow a shared-memory

Re: Saying hi

2018-12-29 Thread Araq
Destructors are required for sane atomic reference counting, in order to close "queues" at scope exit reliably, for unique pointers. All the nice building blocks for "concurrency" work better with them.

Re: Saying hi

2018-12-29 Thread rect0x51
Message Passing is not enough?

Re: Saying hi

2018-12-29 Thread Stefan_Salewski
> I have no idea about what the connection between destructors and concurrency > is, Currently passing data between threads is restricted (Channels, unsafe pointers ...), as we have a thread local Garbage-Collector. I think when Destructors fully work, they can replace GC ref objects in many

Re: openArray[(cstring,cstring)] parameter

2018-12-29 Thread dom96
Note that: @[("Accepts".cstring, "application/json".cstring)] Run is the same as: {"Accepts".cstring: "application/json".cstring} Run

Re: Saying hi

2018-12-29 Thread moigagoo
Hi! Please don't be afraid to ask "stupid" questions! It's totally ok. Luckily, the Nim community is not a bunch of programming snobs who will roll there eyes when asked questions. Also, I have no idea about what the connection between destructors and concurrency is, so I'm eager to learn that

Re: Getting the original type of an 'upcasted' object

2018-12-29 Thread zevv
Thanks for pointing me to that thread, that explains some of the details I did not yet grasp. For now I'm good with a bit of redesign: I store a ref to object with some proc pointers for that specific type in each node. If this is solvable with a macro I can save a pointer per object though,

Re: Getting the original type of an 'upcasted' object

2018-12-29 Thread Stefan_Salewski
That is indeed too difficult for me to answer. Mr Felsing once suggested to use a proc in combination with methods to solve a similar issue, see [https://forum.nim-lang.org/t/3128](https://forum.nim-lang.org/t/3128) I hope some of the smart devs can answer your question -- maybe after the

Need guidelines for contributing bugfixes

2018-12-29 Thread rect0x51
Hi, I want to eventually start fixing bugs and I worry about misusing git (it's probably just my lack of experience). The [relevant article](https://nim-lang.github.io/Nim/contributing.html) doesn't go into details about branching. I considered a couple of strategies and I am not sure which

Re: Saying hi

2018-12-29 Thread rect0x51
I barely dare to ask because it might be self-explanatory... but if you can put it briefly: how will destructors aid concurrency? (I've seen the relevant articles and videos on destructors but still can't make the connection)

Re: openArray[(cstring,cstring)] parameter

2018-12-29 Thread bketelsen
@[("Accepts".cstring,"application/json".cstring)] was the correct incantation. Thanks again for the help.

Re: Getting the original type of an 'upcasted' object

2018-12-29 Thread zevv
Here's an extract of my code. My issue is with the `proc `$`(s: SNodeAny): string =` function. Basically, it is just a long list of `if` statements (could be a `case` as well, doesn't matter) to check if the object is of some type, and then apply the `$` operator on the casted type. I feel

Re: openArray[(cstring,cstring)] parameter

2018-12-29 Thread bketelsen
Thank you for this! I'll give it a shot.

Re: Getting the original type of an 'upcasted' object

2018-12-29 Thread zevv
Sorry Stefan, my original question was indeed lacking background info of what I am actually trying to achieve. I'm trying to port a data model which was originally implemented in Lua to Nim. This consists of a tree of nodes, of which the leaves are heterogenous containers for a relatively

Re: How to achieve "mechanical substitution" like C macro

2018-12-29 Thread juancarlospaco
Term Rewriting Templates?.

Re: How to achieve "mechanical substitution" like C macro

2018-12-29 Thread moerm
You are welcome. Plus another side note: Nim templates _are_ (what C calls) macros albeit pimped up and cleaner. One important point to remember is that templates (unlike Nim macros) are basically but smart text substitution. This also means that any variables one refers to must either be

Re: Saying hi

2018-12-29 Thread Araq
1. Yes, pretty much. 2. Nim's target audience is the enlightened/misguided programmer who doesn't understand why there should be more than one programming language. 3. 1. Tough question. Ultimately the exising PL/OS split is an unfortunate legacy and concurrency belongs into the

Getting the original type of an 'upcasted' object

2018-12-29 Thread zevv
Hi, How can I find out the original type of an object that has been promoted/demoted/casted (what is the right term here?) to a parent type without testing for each individual type with the of operator? import macros macro test(a: typed): untyped = # how to get "T2"

Re: How to achieve "mechanical substitution" like C macro

2018-12-29 Thread liwt31
Exactly what I wanted. I've tried this before: template POP: int = result = stack[p] dec p Run and realized it won't work, then I went in the wrong direction (to put it in one line)... That solves my probem, many thanks to you all.

Re: How to achieve "mechanical substitution" like C macro

2018-12-29 Thread mashingan
Did you mean "textual substitution" instead? Also, reading manual about [template](https://nim-lang.org/docs/manual.html#templates) should provide you ideas on how you can do with it.

Re: How to achieve "mechanical substitution" like C macro

2018-12-29 Thread miran
If your `stack` and `p` are defined globally and at the beginning (before `PUSH` and `POP` procs), you can do as simple as: var stack: array[10, int] p = -1 proc PUSH(v: int) = inc p stack[p] = v proc POP: int = result = stack[p]