While this is a neat use of templates to create an SQL DSL, where does the ORM
part come in? I don't see any place to automatically load values into an
object/ref, aside from the procedures returning sequences.
I don't quite understand this:
What problems are you having? Can you post code that demonstrates your
problems?
Do you mean something like [NPeg](https://github.com/zevv/npeg)?
Can you post the rest of your code, including the procedure definitions?
That's actually a rather nifty use of the include statement! I can see using
that for something like generating mocks and tests.
Hm, have you looked at the generated C code?
A variable declared with var can be used as both a var and regular parameter.
The following is valid:
type Foo = object
a: int
proc bar(x: Foo) =
echo x.a
proc baz(x: var Foo) =
echo x.a
var y = Foo(a: 1)
bar(y)
baz(y)
It appears that (for some reason) the upper 32 bits of the tree pointer in
PState.tree are being cleared. You can see this if you add printf("Node at
address: %pn", (void *)e); to the mkNode functions, and then print the value of
the tree pointer.
You can also use `echo repr(variable)` to print out a basic representation of a
variable.
Test Text
How are the owned/unowned reference concepts different from the strong/weak
reference concepts found in other languages?
It would help if we had more context for your problem. Is the server sending a
lot of data? Are you using threads? What have you tried with regards to
debugging?
I would double-check the ZLIB binding code that you have, to make sure that
everything is correct. This looks suspiciously like a memory-corruption issue,
which tends to happen when Nim bindnigs don't accurately represent the
functions/structures they are wrapping.
You
Ok, so I was able to get the Nim and C++ examples to compile when using the
heap (rather than the stack).
Comparing the code, I think the difference in performance is caused by two
things:
* The Nim code isn't in a main procedure
* The C++ code is using int`s (32 bits) while Nim is
No.. I'm running it on a MacBook with 16GB of ram
Hm, when I compile the C++ code, I get a segfault.
Are all the incoming types from the database strings? How does this handle NULL?
Hm, are you sure you need pointers? Usually references are better (as
references are tracked by the garbage collector).
Also, runtime type data doesn't work like this. The is operator works at
compile time. What I think you want to do is this:
type
NodeValueKind = enum
Woops, yes, I meant to say alloca.
If you _really_ need to know the number of processors on a system, you could
always compile a sub-program during compile-time and invoke it.
Regarding allocating arrays at runtime, is there a reason that a
[sequence](https://nim-lang.org/docs/manual.html#types-array-and-sequence-types)
won't
Your setupDepFile macro can only take static parameters - the parameter values
must be known at compile-time. On line 53, your are passing a string and
boolean that have may have values unknown at compile-time values. Yes, the
function calls on lines 54 and 55 have known values, but the
Huh? Why does UE4 only work with vcc?
Visual Studio support for assembly has always been tricky (if I recall
correctly, it to a whole for inline assembly to be supported).
Have you tried using Gcc/Mingw? That's what most people use.
>From the [compiler
>manual](https://nim-lang.org/docs/nimc.html#compiler-usage-command-line-switches):
\--overflowChecks:on|off \- turn int over-/underflow checks on|off
Are you accepting part-time applications?
geo555: I don't see how this is unexpected - Nearly all languages that have a
"namespace" or "module" concept restrict namespace/module names to valid
identifiers. This is so the module can be referenced within the code.
* Python allows running scripts with invalid identifiers, however it
I like Stefan_Salewski's version as well. It reminds me of python generator
expressions.
@Udiknedorm: The biggest problem with the current GC is that it doesn't support
shared memory (though, I don't know why we can't do something like Go's
channels).
To me, these changes seem like an effort to reasonably support programs that
don't want to rely on the GC.
Well, the only way to do type checking like this is through static analysis,
which is typically performed by the compiler. The other way to do this is to
make a variant of a procedure that accepts static parameters, and then use when
to test their value.
You can always run your output code through [Google Closure
Compiler](https://developers.google.com/closure/compiler/).
@LeuGim Look under the line, in the same area as the 'Run' button.
Python caches hashing of strings. Nim does not (it would be a challenge, as Nim
strings are mutable). I suggest using string references or Hash objects if you
want to compare performance.
Has anyone benchmarked C++ for this kind of test?
Copying semantics in Nim are fairly straightforward:
* Object types, sequences, and strings copy on assignment
* References do not copy on assignment
shallowCopy and shallow sidestep the fact that strings and sequences copy on
assignment. If you use these procedures, any affected
V2:
import tables, times, hashes
const WORD_SIZE = 4
const K = 1
iterator wordSlices(line: string, size: int): Slice[int] =
for startIndex in 0 .. len(line) - size:
let endIndex = startIndex + size - 1
yield startIndex..endIndex
I've come up with an optimized version which takes about 5 seconds on my
machine, vs the 48 seconds that the Python script takes. This version doesn't
print out the top words (that would take a bit more work, and another map of
hashes to strings)
import tables, times, hashes
Could you post your Python source code too? Often when people post these kinds
of comparisons, their programs are doing slightly different things.
With the exception of code that is interfacing with some external language (C,
C++, etc) this doesn't really make sense. Nim is module based, so you just
import the types from the files you need and Nim takes care of all the type
linking. If you need to use mutually recursive types, put all the
Are you exporting a const?
It will probably be solved:
* After all other higher-priority features/bugs are solved
* When someone contributes a patch that resolves the ambiguity
It's not really a big problem. Just use "foo[T](42)" or "foo(42)[T]". I don't
think it warrants a syntax change.
It's likely that this is a bug in the threadpool implementation - I suggest you
file an issue in the main repository.
Probably. I wouldn't be surprised if part of the reason Nim's allocator is
slightly slower is due to zeroing memory too.
Krux02: It would be better to store the index. Using addr is unsafe - the
object won't have the same address if it's copied from place-to-place on the
stack.
mratsim: First, I would look at the section of the manual regarding [reference
and pointer
What do you mean by 'bind'?
It looks like you're mixing standard C io functions with Windows IO functions,
which usually leads to trouble. The standard output handle on Windows isn't
exactly like a normal file handle, and doesn't sort all the states that a
regular handle does.
The Nim compiler knows nothing about CFLAGS and related things, however the C
compiler it uses should (if you're using GCC or Clang). You can also pass in
arguments via `--passC` and `--passL` arguments.
When benchmarking, it's good to remember some things:
* Nim's `int` datatype is
Hello all!
Unfortunately, due to a recent increase in work and educational demands, I
don't have any free time left to devote to
[NimLime](https://github.com/Varriount/NimLime), the Nim integration plugin for
Sublime Text. As such, I'm reaching out to the community to request if there's
The big problem with a self-extracting executable is that we need the
capability to download extra components - namely MinGW. Bundling MinGW with all
installs dramatically increases download size, not to mention that if the MinGW
component needs to be updated, so does the rest of the installer.
Anyway, does anyone know some alternative that we might try out? I know that
we've tried WiX (too much XML), NSIS (too much assembly), and Inno (way, way
too much programming needed). Any others?
@mindplay I suspect the main reason for araq's vehemence is not malicious, but
maintenance fatigue.
The old installer used [NSIS](http://nsis.sourceforge.net/Main_Page), which is
a headache to deal with (the installer is built using the NSIS language, which
closely resembles assembly and a
The symbol binding rules for generics are outlined in the manual
[here](http://manual.nim-lang.org/docs/manual.html#generics-symbol-lookup-in-generics).
It might help if the section defined what exactly 'open' and 'closed' symbols
are, since most programmers don't know about compiler-specific
Why should it be surprising? Procedure calls and field accesses in generics
aren't resolved until instantiation time. What if wuff was a field of 'a'?
Anyway, if by 'inlining' you mean, 'can the Nim compiler/backend compiler
inline generics', then yes, it can be inlined.
I don't quite
Yes, objects need to be reference counted for methods to work. This is because
only reference types can point to variable-length memory regions.
Take the below code:
type
Animal = ref object of RootObj
name: string
Dog = ref object of Animal
> I guess that one could put the return value as the first one on the stack
> frame, so there is no copy involved. It seems to me that this is safe to do
> when one uses the special variable result. It depends on the calling
> convention, but I think it should be doable?
This is close to how
**TL;DR**: Strings and sequences, like objects and integers, are copy on
_assignment_. References are not.
Technically, values are always copied when returned from a procedure - there's
not really any other way.* If values were to be always passed by
pointer/reference, how would values that
Turning on cycle detection doesn't seem to affect the pause times for me. I
still get sub-millisecond pauses for Araq's Nim snippet.
This is the snippet I'm using:
# Compile and run with 'nim c -r -d:useRealtimeGC -d:release main.nim'
import strutils
#import times
Here's an amendment to my previous timing. I compiled the Go snippit with
standard arguments (I don't know if there's a 'release' mode) and Nim with
'-d:release', then ran each executable 20 times.
Nim
---
Mean: 0.08501 ms
Median: 0.07966 ms
Std Dev.: 0.03227
@jlp765 It varied ±1 millisecond for the Go snippet, and ±0.1 millisecond for
the Nim snippet.
Or if you want to compare the addresses only:
echo "IS IT THE SAME? ", (cast[int](xobjref) == cast[int](result))
This looks mainly like an edge case that hasn't been covered. You should
probably file an issue for it.
You could also roll your own mechanism via shared memory maps (although this
world better for fixed-length structures).
Personally I dislike that particular behavior. The c runtime that ships with
Windows is meant for internal use.
[https://blogs.msdn.microsoft.com/oldnewthing/20140411-00/?p=1273](https://blogs.msdn.microsoft.com/oldnewthing/20140411-00/?p=1273)
Eh, my biggest complaint about strings is (and probably always will be) their
copy-on-assignment behavior. At least UTF8 handling can be implemented fairly
transparently through subtyping.
(Yes, I'm aware that changing current string assignment behavior would break
things)
Don't forget link-time-optimizations. Turning those on tends to make code quite
a bit smaller.
This actually puzzles me too, especially since Nim are particularly inefficient
for this kind of work (strings are copy-on-assignment, meaning the data is
going to be copied at least twice on its way to a socket)
@Araq This sounds like object mapping, in which data from a database is mapped
into a set of objects. That's quite common, and makes working with data much
easier.
I'd love interfaces like the ones shown by
[requests](http://forum.nim-lang.org///docs.python-requests.org/en/master/) and
[unirest](http://forum.nim-lang.org///unirest.io)...
@Araq By "implemented", I believe jyelon meant "design"; using existing
database software (postgresql).
Anyway, your reply still doesn't answer the question - how would he use json
functions in one thread to act on data from another thread?
In those cases, do you really need to access the exact same memory, or will a
copy do?
Since COM has a C interface, it's quite possible (although I have yet to see a
real-world example). What kind of scenario are you planning to use COM in?
Jester relies on Nim's built-in async modules, which are unfortunately built on
a single-threaded _asynchronous_ approach. This means any blocking operation
done on the main thread will stall all operations.
If your aim is to pause a route, I suggest using something like
I'd prefer throwing an error (or returning the original string). Splitting with
a delimiter of 'nothing' makes little sense, and doesn't have an intuitive
result.
This looks to be more a limitation in the current concept implementation
(although whether the limitation will be lifted is a design decision that Araq
will have to make).
Currently the compiler only considers globally-scoped procedures when testing
of a concept "fits" a type, likely for
Could you retry the above actions with an elevated process explorer (one run as
an administrator)? Also, do you have an Antivirus program or something similar
that could be causing this? Have you had any similar problems with other
programs in the past?
Sorry for the questions, it's just that
It's possible to 'suspend' (pause) threads in various ways - a process can be
created in a suspended state, a debugger can pause threads, or threads can be
suspended via an undocumented kernel function
:
:
:
78 matches
Mail list logo