Re: Where do I learn how to program Nim without a GC?

2016-08-25 Thread Araq
Compile with `--gc:stack`


var rx: Region

withRegion rx:
  ... json code here ...


You're right though that it needs documentation. I don't even know if it's in 
0.14.


Re: Send data structures between threads?

2016-08-25 Thread Araq
> How do I avoid accidentally trashing the refcounts?

protect and dispose only give you a `pointer` that you can cast to `ptr 
JsonObj` and so RCs are not affected.

> But as you mentioned before, I can force it with a cast. Is that part of the 
> solution you're suggesting?

Well yes. But you really need to be careful and even then it doesn't support 
multiple threads creating data and adding it to an existing datastructure 
wihout copies, so Boehm may indeed be what you want.


GD Designs Rochdale Reviews (16)

2016-08-25 Thread azmirbogovic
GD Designs Rochdale Reviews (16) . Looks fab and was half price of other 
companies. Barry Fairhurst


Re: asynchttpserver and big request body

2016-08-25 Thread _tulayang
@vega

I think it is different between io of httpserver and stand stream. readChar 
readData ... are not useful. I think we need apis like recvOnClientError 
recvOnAChunk recvOn100Continue recvOnTimeout etc.


Re: Send data structures between threads?

2016-08-25 Thread jyelon
Say, I never did get an answer to either of the questions above. I'm still 
curious:

1\. If the json is stored in a thread-local heap, then I let other threads 
reference the json, those other threads are going to tend to touch the 
refcounts. But the refcounts, presumably, aren't atomic ints. How do I avoid 
accidentally trashing the refcounts?

2\. The compiler is trying very hard to prevent me from passing a ref to the 
json from the thread that created it to any other thread. (That's what gc-safe 
is all about). But as you mentioned before, I can force it with a cast. Is that 
part of the solution you're suggesting?


Re: Where do I learn how to program Nim without a GC?

2016-08-25 Thread jyelon
Yeah, but he needs information on how to cause an normally garbage-collected 
library (for example, the JSON library) to allocate out of a memory region, 
without changing the code for the library. I think the real answer is: I don't 
think memory regions are implemented yet, I don't think anyone's really ironed 
out the details.


Re: Where do I learn how to program Nim without a GC?

2016-08-25 Thread flyx
> I mean somehow I have to tell Nim when to free memory right?

Yeah sure, you just use these: 
[alloc](http://forum.nim-lang.org///nim-lang.org/docs/system.html#alloc,Natural),
 
[dealloc](http://forum.nim-lang.org///nim-lang.org/docs/system.html#dealloc,pointer),
 
[allocShared](http://forum.nim-lang.org///nim-lang.org/docs/system.html#allocShared,Natural),
 
[deallocShared](http://forum.nim-lang.org///nim-lang.org/docs/system.html#deallocShared,pointer).
 You can cast the `pointer` from and to 
[ptr](http://forum.nim-lang.org///nim-lang.org/docs/system.html#ptr) types and 
then you have your manually managed heap memory.

(This is a general answer to how to use non-GC'd memory and has nothing to do 
with memory regions)


Re: Where do I learn how to program Nim without a GC?

2016-08-25 Thread Maxxi
Araq, I dont understand. I'm just now looking into Nimlang. How would I have to 
change the programming style to program with memory regions in Nim? It can't 
just be a flag to the compiler, I mean somehow I have to tell Nim when to free 
memory right?


Re: asynchttpserver and big request body

2016-08-25 Thread vega
WIP is here: 
[https://github.com/vegansk/asyncstreams](https://github.com/vegansk/asyncstreams)


Re: httpclient extraHeaders not working

2016-08-25 Thread euant
@dom96: That reminds me that I was going to submit a PR for that...


Re: Concept[T] design question

2016-08-25 Thread zahary
Hi @boia01,

It will be possible to create concepts based on type lists, but I don't 
consider this a feature of the concepts per se, but rather a general support 
for variadic generics. You can take a look at this github issue:

[https://github.com/nim-lang/Nim/issues/1019](https://github.com/nim-lang/Nim/issues/1019)

As explained in the issue, type lists can be emulated right now with a single 
parameter, expecting a tuple type. Then within the concept, you can have a 
`static:` block containing arbitrary code for the actual checks. I tried to put 
something together quickly as an example, but I ran into several issues, so 
this explanation will have to do for now, sorry.


Re: asynchttpserver and big request body

2016-08-25 Thread dom96
> Thats why I want to write asyncstreams module for the standard library. What 
> do you think about it?

Sounds like a good idea :)


Re: Nim in Action is now available!

2016-08-25 Thread dom96
Last chance to get 50% off Nim in Action! Use code `pbbutcherlt`: 
[https://manning.com/books/nim-in-action?a_aid=niminaction&a_bid=78a27e81](https://manning.com/books/nim-in-action?a_aid=niminaction&a_bid=78a27e81)


Re: Nim in Action is now available!

2016-08-25 Thread dom96
> Hi @dom96! > Just ordered the book. Thank you for the discount!

Thank you for ordering it!

> Because now to understand which methods for example the seq type supports the 
> fastest is to use Internet search. setLen is in system, some others are in 
> sequtils and etc.etc.

Keep reading, i'm pretty sure I talk about seq in that level of detail 
somewhere. In fact it might even be in the second chapter.


Re: asynchttpserver and big request body

2016-08-25 Thread vega
I created the fork of asynchttpserver for the test: 
[https://github.com/vegansk/asynchttpserver2](https://github.com/vegansk/asynchttpserver2)
 where you can read entire body using `request.body.readAll`, get the length of 
the request without reading it via `request.body.len`. And the main feature - 
you can read it via stream: `request.body.getStream`.

And the latter method is bothering me. asynchttpserver is async, standard 
streams are not. Thats why I want to write asyncstreams module for the standard 
library. What do you think about it?


Re: asynchttpserver and big request body

2016-08-25 Thread _tulayang
Suggest to export the data received at each time, so that users can use this 
api to customize how their datas are stored (copy to their buffer or disk 
files).