Thank you! I'm happy you think that way :) I'm update it the code when I can ^_^
> 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
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.
* p = (int*) malloc (size * sizeof (int));
Run
translated to nim:
p = cast[ptr cint](alloc(size * sizeof(cint)))
Run
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.
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]`.
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
> 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
> 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
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
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%).
How so? I see Scala in JSON serialization as being #1.
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:
> 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.
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.)
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?
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...
> @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
This is really a great resource!
Very, minor nitpick is that your lines are pretty long. Maybe nimpretty the
code?
Other wise, its flawless.
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?
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
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
I would really appreciate it if someone could provide me an example of how to
enable CORS with Jester. Thanks.
> 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
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,
@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.
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
@treeform it seems
[https://github.com/niv/websocket.nim](https://github.com/niv/websocket.nim)
also have wss support.
> 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:
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.
30 matches
Mail list logo