Re: Nim Days progress

2019-06-04 Thread aredirect
Thank you! I'm happy you think that way :) I'm update it the code when I can ^_^

Re: Owned refs

2019-06-04 Thread GordonBGood
> How does it work with threads? It works the same with threads as with everything else: When you need to pass anything as a thread argument that is subject to being destroyed, you need to "move" it to a sink parameter with everything that implies including that it must then be an owned ref

Re: create array at runtime

2019-06-04 Thread bpr
You can use [this](https://github.com/bpr/vla) which looks a bit broken now but if you remove the deprecated pragma it runs fine. I'll fix that ASAP.

Re: create array at runtime

2019-06-04 Thread treeform
* p = (int*) malloc (size * sizeof (int)); Run translated to nim: p = cast[ptr cint](alloc(size * sizeof(cint))) Run

Re: create array at runtime

2019-06-04 Thread GULPF
It's better to cast to `ptr UncheckedArray[cint]` since it's more semantically correct. Otherwise you need to add indexing operations to `ptr cint` which is not a good idea.

Re: create array at runtime

2019-06-04 Thread GULPF
The equivalent in Nim would be `ptr UncheckedArray[T]`, which is a pointer to an array without any range checking. That said, unless you have a good reason for using it you're better of with `seq[T]`.

Re: create array at runtime

2019-06-04 Thread treeform
You should use a seq. You would not need size as its part of seq as .len. type Stack[T] = object top: int A: seq[T] Run If you NOT going interface with C there is no point in using C style arrays. BUT if you want to emulate C ... some thing you

Re: create array at runtime

2019-06-04 Thread cantanima
> Variable-length array is a new feature in C99, which is not used much **and > is not available in C++**. Come again? This compiles _and runs_ just fine in `clang++`. I mean, just fine for a C++ program. // usage: ... // example: ./a.out 5 8 4 3 1 6 // has output 8 4

Re: TechEmpower Web Framework Benchmarks

2019-06-04 Thread dom96
> Rust is also close to winning "JSON serialization" (99.1% of the winner). So... not the "absolute dominant champion in every category..." then, this was my point and I did look at your "now" link. Nim really isn't that far behind. I don't have time, nor the will to optimise httpbeast even

Re: create array at runtime

2019-06-04 Thread Santanu
int* p = (int*) malloc (size * sizeof (int)); Is there a way to write this in Nim or do I have to ffi malloc (and will it work?). I don't want a variable length container but to set the size dynamically. type Stack = object A: array[5, int] This works but the array size is fixed. I

Re: TechEmpower Web Framework Benchmarks

2019-06-04 Thread Libman
You're probably looking at their last publication, [Round 17](https://www.techempower.com/benchmarks/#section=data-r17=ph=json) from Oct 30th. See the "now" link in my previous post. Rust is way ahead in their flagship "Fortunes" benchmark (next language is at 62%).

Re: TechEmpower Web Framework Benchmarks

2019-06-04 Thread dom96
How so? I see Scala in JSON serialization as being #1.

Re: CORS in Jester

2019-06-04 Thread dom96
I think you need to set appropriate headers, doing so in Jester is trivial (didn't test this but should work): routes: get "/": resp Http200, {"Access-Control-Allow-Origin": "http://www.example.com"}, "Content" Run (Source:

Re: Owned refs

2019-06-04 Thread GordonBGood
> 1\. Well yes, that's how it works... > > 2\. There is an implicit type conversion from owned to unowned... @Araq, I assumed as much, just wanted to confirm, and just to notify you that the spec 2 should likely have a clarification for these.

Re: create array at runtime

2019-06-04 Thread Stefan_Salewski
Variable-length array is a new feature in C99, which is not used much and is not available in C++. For variable size containers in C++ Vector data type is generally used, and in pure Nim we generally use seq data type. (For C interop you may consider UncheckedArray.)

create array at runtime

2019-06-04 Thread Santanu
type Stack[T] = object top: int size: int A: array[size, T] Run This does not work as size is unknown at creation. How to create a ptr to array like in C?

Re: TechEmpower Web Framework Benchmarks

2019-06-04 Thread Libman
On [TechEmpower dailies](https://tfb-status.techempower.com) Rust is [now](https://www.techempower.com/benchmarks/#section=test=019d5c9b-823f-4890-8ed9-28c0a2718bdd) the absolute dominant champion in every category...

Re: Nim Advocacy & Promotion Strategies

2019-06-04 Thread Libman
> @libman please calm down and be less verbose in these quite offtopic > discussions. Yes, you like MIT and dislike GPL, we know, you don't have to > repeat it again and again... I didn't repeat it, I brought up a new point about an exodus of Python programmers not happy with the growing SJW

Re: Nim Days progress

2019-06-04 Thread treeform
This is really a great resource! Very, minor nitpick is that your lines are pretty long. Maybe nimpretty the code? Other wise, its flawless.

Re: Owned refs

2019-06-04 Thread treeform
How does it work with threads? Can data structures like seq and tables be shared now? Does threaded code becomes simpler to write? Are there any examples of the simplifications?

Re: Owned refs

2019-06-04 Thread Araq
Well usually ownership works by introducing an owner. For your example, you could keep the owned refs in a separate dedicated seq and have both your caches work on unowned refs. Then when the seq loses a ref you need to update the two Tables before and remove the corresponding unowned refs from

Re: Owned refs

2019-06-04 Thread andrea
Thank you for the explanation. I am still curious, though, since it is not difficult to create a variant of the problem where one needs to actually keep a thing into two different collections. For instance, say I am designing a cache where I keep objects of type `ref T`. I want to be able to

CORS in Jester

2019-06-04 Thread revilotom
I would really appreciate it if someone could provide me an example of how to enable CORS with Jester. Thanks.

Re: Nim Advocacy & Promotion Strategies

2019-06-04 Thread gemath
> Proprietary software is a non-issue to people who don't choose to use it. In the narrow, license-dependency related sense we are discussing here, yes. In a wider sense: don't get me started. > Restrictive licenses... They do not constitute a legitimate contract Depends on the legal system

Re: Owned refs

2019-06-04 Thread Araq
1. Well yes, that's how it works, as in the B/D paper and in the current implementation of `--newruntime`. 2. There is an implicit type conversion from owned to unowned and afterwards the ordinary `=` for unowned is used,

Re: Nim Advocacy & Promotion Strategies

2019-06-04 Thread Araq
@libman please calm down and be less verbose in these quite offtopic discussions. Yes, you like MIT and dislike GPL, we know, you don't have to repeat it again and again... Currently you're more harmful then helpful in protomoting Nim, I'm afraid.

Re: Owned refs

2019-06-04 Thread GordonBGood
Some thoughts on what isn't yet clear about the speci 2: 1, I believe that it is the intention that all ref's must be first be created as owned ref's but it doesn't seem to be specified. It is clear that once they exist, owned ref's can then only be destroyed or moved so how else will they

Re: Any SSL sockets example?

2019-06-04 Thread enthus1ast
@treeform it seems [https://github.com/niv/websocket.nim](https://github.com/niv/websocket.nim) also have wss support.

Re: Owned refs

2019-06-04 Thread GordonBGood
> so when you explicitly call system.move(arg) the arg must still be mutable. @Araq, thanks for that, so we need to declare it as the following then: proc split[T](things: sink seq[T]): tuple[even, odd: seq[T]] = var counter = newTableCount[T]() for thing in things:

Re: Owned refs

2019-06-04 Thread Araq
A rewrite rule is a code generation rule, semantic checking happens much earlier and so when you explicitly call `system.move(arg)` the `arg` must still be mutable.