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
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.
Message Passing is not enough?
> 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 pl
Note that:
@[("Accepts".cstring, "application/json".cstring)]
Run
is the same as:
{"Accepts".cstring: "application/json".cstring}
Run
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
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, wh
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
holid
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 one
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)
@[("Accepts".cstring,"application/json".cstring)] was the correct incantation.
Thanks again for the help.
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 this
Thank you for this! I'll give it a shot.
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 large
I am not sure what the result of your test() should be and for what you will
use that result.
You can use type(x) to get the static base type of an object and name from
typetraits module to get the typename: Following code works, but I don't know
if it can help you:
type
A =
Term Rewriting Templates?.
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 defin
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 _langua
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"
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.
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.
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]
22 matches
Mail list logo