\--skipParentCfg:on|
> are the runtime checks also deactivated for g? Is there a difference if g is
> a template or macro?
No, yes. Templates/macros "insert" the code into the proc so it is affected by
the checks, whereas proc calls merely call already generated code elsewhere, in
this case `g` was not instantiated
" cpu:i386 is specified to compile the dll as 32bit" \- of course, yes, that's
what it means.
"And if yes, do you know if it is actually needed or it’s just for convenience
of some type?" \- maybe the game itself is 32-bit, then the DLL should be
32-bit as well
That’s really nice, I didn’t know that. Do you know if, in the url I sent,
cpu:i386 is specified to compile the dll as 32bit? And if yes, do you know if
it is actually needed or it’s just for convenience of some type?
Yes, exactly - Nim is sometimes smarter than people think - with --app:lib on
Windows Nim automatically makes a DllMain entry-point which calls into your
starting code. There's no need to add it manually at all
I guess I will have to gave up on this one for now. Need more time to get used
to the language to tackle this one on my own. But I'm still impressed how fast
it was to build and test all the other parts not related to the socket itself.
Appreciate all the replies on the issue. Thanks All.
I think we were in a dialog of deaf.
You were focused on the difference between uninitialized (with {.noinit.}) and
initialized sequences (other sequences) whereas I was focused on the difference
between sequences with no explicit initialization and sequences with explicit
initialization.
What
Beginner here.
I'm trying to compile a simple binary (`nim c binary.nim`) without using parent
directories' `config.nims` or `nim.cfg` but it seems `--skipCfg` and friends
don't do anything. What am I missing?
.net allows passing a HttpMessageHandler to the HttpClient constructor. The
handler is responsible for sending a request:
[https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpmessagehandler?view=netcore-3.1](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpmessagehandle
I think it depends, if it is `template` or `macro` or `proc` or `proc
{.inline.}`. But "normal" proc outside push/pop should not be affected. You can
try using `macros.expandMacros` and friends.
I used jester to serve json to a karax frontend. I loved it. Best part was I
used the same objects in karax and jester.
The karax frintend app would populate and serialize one or more objects to JSON
as the request body. The jester app would then deserialize, do backend things,
and respond with
I know I can use `-d:danger` to deactivate runtime checks for the whole
program, but let's assume I usually want the checks, but only deactivate them
for a certain section of my code.
The
[manual](https://nim-lang.org/docs/manual.html#pragmas-compilation-option-pragmas)
describes pragmas to do
@Shucks I have made a little research, this guy doesnt seem to have any
problems using winim functions, and another method to do things, have a look at
it also
[https://guidedhacking.com/threads/internal-with-nim.15281](https://guidedhacking.com/threads/internal-with-nim.15281)/
I haven't used it yet but this web framework seems nice as well:
[https://github.com/planety/Prologue](https://github.com/planety/Prologue)
Yeah, .NET is the closest thing to what SOIL apparently trying to be. I meant
that C is the closest thing to an UNCOL ... but for interop with .NET, the JVM,
and other such "hosted" environments, I suppose it isn't.
Thats because you disnt define DllMain, rename entryPoint to DllMain
Oh, I see it now. Thank you.
[https://nim-lang.org/docs/manual.html#types-cstring-type](https://nim-lang.org/docs/manual.html#types-cstring-type)
> A $ proc is defined for cstrings that returns a string.
> I did try to make sense of his ideas in those diagnostic ways
Yeah, sorry, I seem to have missed your comment earlier.
> To me, const was always meant to be used for things who represent something
> like a physical constant
That's just one usage. In a language like Nim, which takes compile-ti
> $(exc.name)
No need for the parentheses ... $ binds less tightly than .
If someone isn't aware that there are compiler options to influence the
runtime, they may not understand the implications of "debug build" vs. "release
build" either. ("I don't want to release this, so the 'debug build' should be
fine." :-) )
That said, the message that a debug build is generat
> It doesn't matter, actually.
Note my comment above: "there is a subtlety: the quoted C standard says that
"pointer arguments on such a call shall still have valid values", which is not
true of NULL (nil). But few implementations check the pointer when the len is
0, so people get away with it.
I don't think there is one :)
> But, then there is a inconsistency as some sequences of length 0 (those non
> allocated) will return nil, while others (those empty) will return a non nil
> value. It would be better to return nil in both cases.
It doesn't matter, actually. Any two zero-length byte ranges (slices) are
equival
What's the bug ID for this leak? I'd like to read and understand it, or at
least get notifications.
> Yes, indeed, except that the compiler processes them the same way, i.e. both
> are considered to have length 0.
No, you're misunderstanding, and making the same mistake. An uninitialized seq,
which you can get with {.noinit.}, has not been zero-filled ... it contains
junk, and using it is lik
After researching this for a bit I found this playlist useful:
[https://www.youtube.com/playlist?list=PL6RpFCvmb5SGw7aJK1E4goBxpMK3NvkON](https://www.youtube.com/playlist?list=PL6RpFCvmb5SGw7aJK1E4goBxpMK3NvkON)
Gosh dang it to heck! 🤬 I can't seem to keep track of which features are
incompatible with which other features. So ARC/ORC works with threads but not
with async. And non-ARC works with async but not with threads (in the way I
want, i.e. passing objects between threads.)
Is this async leak supp
In general yes maybe. But in this case a PR against the Nim repo so that we can
review your spec additions is totally appropriate.
According to the manual, the correct conversion from `cstring` to `string` is
the `$` operator — so use `$(exc.name)`. (Tested on bleeding-edge devel.)
No, you can’t avoid the test as the area containing the length, the capacity
and the items may not have been allocated yet, as in `var s: seq[int]`. You
can’t return the address of something which doesn’t exist.
Now, I agree that if this area has been allocated, it would be possible to
simply r
If the website used a wiki, it'd be super easy for people to fix these little
documentation omissions (hint, hint)
Brilliant ! Thank you very much!
Thank you!
Option 1 won't work, it's just a duplicate method and I assume the compiler
will complain.
Option 2 is workable but requires minor changes to the HttpClient class,
because Nim objects don't support dynamic dispatching by default. (In C++
terms, the overriding is non-virtual.) So if you implemen
Thats true, is too complicated to make it red color and green when is
release/danger ?, is just "Discoverability" of the feature.
I am joking about Observable stores, I wonder how that will evolve.
:)
A predefined proc for this could avoid the unnecessary range check and simply
return the internal `seq` field that points to the items — that would boil down
to one CPU instruction.
If the seq is empty the result would presumably be `nil`, but as explained
several times above (thanks, @jibal!)
Compiler already mentions if it's a debug or a release build - it's user's
issue if they didn't read it :)
And for heap profiling - compile with -d:useMalloc and possibly
--debugger:native
I like that idea of a warning. Maybe not in _all_ builds, but if the source
code contains the strings `fibonacci` or `benchmark` ;-)
As far as I know ORC sadly still leaks memory with async :(
I think `waitfor A() and B()` is cleaner ... that way you can handle any errors
that occur.
"others might have their interest piqued, wondering what all means, and start
reading the documents"
Yeah. And thats the point. I happened to be such one who is interested and
ready to read the documents, and got confused in the current, overwhelming and
chaotic documentation.
I actually offer
That code snippets I've coded are ofcourse compiled with --noMain. However the
"nim" way didn't produces a valid dllmain. The emitting one does but I wan't to
keep my code on nim.
Yeah, its the language barrier, although all the people involved in this thread
already got the idea right, also cblake.
I understand that there are details to the implementation who change the
meaning of those things, while I try to keep it simple and understand those
things on a practical sid
Ok, now is not too complicated to add:
`Warning: Compiling on Debug mode, compiled result is slow, compile with
-d:danger for performance.`
It may even be more useful than the current `Warning: Observable stores.` (?)
:P
But... a let can have compile-time parts and run-time parts, like when you use
`let foo = block:`, that may or may not have `static( )` or even macro code
somewhere in between.
I just noticed that my little WebSocket-based server is leaking memory like
crazy — about 1GB for every time I run the test suite (serving ~40MB of data.)
If I turn off `--gc:orc`, the leaks go away. (This is on devel from a few days
ago, not 1.2.x.)
Unfortunately my macOS heap-profiling expert
You can define DllMain and compile your code with —NoMain so that there are no
issues, however I did have problems when using winim functions, I think it was
because it tried to load kernel32, even though it was already loaded (in the
injected process)
So this got asked [here](https://forum.nim-lang.org/t/3190) already. How to
define a DllMain Entrypoint without emitting raw c code? My example doesn't
works. Looking at the raw cache .c file it also doesn't looks correct at all.
import winim/inc/[windef, wincon]
proc mainT
@arch \- Well, in Nim I am pretty sure you can just implement your own `proc
or` to do whatever you want on two `openArray[SomeInt]` params { `SomeInt` if
you want something that could operate in bigger chunks than 1 byte. :-) }
Lol. :-) I mostly meant "schedulable on >1 CPU at a time" which then happens to
be non-deterministic because the OS is scheduling who knows what, but yeah. I
probably should have mentioned weave, too, which can presumably do this without
crashing?
For the curious it matters quite a bit to do floating point arithmetic because
a "big" optimization in question relates to FP vectorization. There are more
details in the @xyz32, @aedt @cblake and @oyster comments in
[https://forum.nim-lang.org/t/1779](https://forum.nim-lang.org/t/1779) (which
See also [https://forum.nim-lang.org/t/4253](https://forum.nim-lang.org/t/4253)
/ [https://github.com/drujensen/fib](https://github.com/drujensen/fib) where
Nim C++ was 8 times faster than C, Nim C or C++.
Single-threaded Fibonacci is a benchmark of tail-call optimizations and
tail-call folding
@mratsim thank you for the libs. I'm going to check them out.
P.S. Unfortunately I didn't get a chance to rebase a PR last weekend. I'm still
working on it, but work priorities have kept me elsewhere for a bit.
> Personally, I don't like this approach. If we have --os:esp-idf, then will we
> have --os:companly_a, --os:company_b, etc, later?
Yah, that's part of why I realized really it's about supporting FreeRTOS +
LwIP. Then each cpu is just setting the RTOS people might be using. Though I
imagine com
Use `seq[byte]` (heap allocates), `array[N, byte]` or `openArray[byte]`
(equivalent pointer+length)
The following libraries are battle-tested for raw byte manipulation and are
being audited by security firms:
* stew/byteutils:
[https://github.com/status-im/nim-stew/blob/master/stew/byteutils
If you want non-deterministic ordering you need to use multithreading. But
usually we use multithreading **despite** non-determinism.
Thank you @cblake. But it seems that openArrays can be used only as params. And
sequences don't support bitwise operators like this: seq1 or seq2.
> Empty is not uninitialized--they are two completely different concepts.
Yes, indeed, except that the compiler processes them the same way, i.e. both
are considered to have length 0.
In fact, there are no uninitialized objects in Nim. If you write `var s:
seq[int]`, the memory area representin
> Nim (that is, Araq) made a wise choice and targeted the closest thing to it: C
Heh, IMO .NET is actually the closest thing to it, it supports many dynamic
features, it supports GC, it supports reflection and value based datatypes.
Yes, it's from Microsoft so now we need webassembly instead. Bu
Thanks!
Right. This produces "lock step" A,B,A,B,A,B. He had referred to "A,B,B,AA,B"
which I took to refer to non-deterministic/truly parallel work. He'll have to
chime in with what he really meant. :-)
Yes, it is possible:
import asyncdispatch
proc A() {.async.} =
for _ in 1..10:
echo("A")
await sleepAsync(0)
proc B() {.async.} =
for _ in 1..10:
echo("B")
await sleepAsync(0)
asyncCheck A()
no I mean why newFileStream("libadd.dll").readAll() can't return binary data
well, but staticRead("libadd.dll") returns binary data without problem.
What is the reasonable relationship between static and binary data, and
bad-relationship between readall and binary data?
It sounds like what you want is less "async output" and more "truly parallel
execution with whatever work happens to finish earliest" winning the race. This
is similar to the Unix process level `wait4(-1,..)` or `waitpid(-1,..)` which I
have found quite useful from time to time, but on the finer
While I am 100% sure @jibal already knows, it perhaps bears mention for others
that the idea has had **_many_** incarnations -- only a tiny fraction of which
are on that Wikipedia page. Things like SUIF, C--, the internals of practically
any retargetable compiler, and on and on. The Wikipedia pa
In Python i was able to override a class method that handler to socket
connection. Bellow is the simplified sample:
from http.client import HTTPConnection # Core Library
class HTTPConnectionUnixSocket(HTTPConnection):
def connect(self):
sock = socket.soc
I did try to make sense of his ideas in those diagnostic ways (which I think
could add value though maybe not be a high priority), but I guess my
description was not to @ShalokShalom's liking. :-(
I think @arch should probably use seq[char] or maybe seq[uint8], but the first
class openArray[T] idea may also be relevant:
[https://github.com/nim-lang/RFCs/issues/88](https://github.com/nim-lang/RFCs/issues/88)
There are also existing ways (toOpenArray[uint8]) where you could probably
write
Is it possible to modify:
The following snippet so as to print alternatively "A" and "B", like:
A, B, B, A, A, B, etc...
import asyncdispatch
proc A() {.async.} =
for _ in 1..10:
echo("A")
proc B() {.async.} =
for _ in 1..10:
How do other languages solve this problem?
FWIW, I copy-pasted his code, ran it with PGO and the Nim was actually 1.5x
faster than the C...I believe this is due to a quirky/sensitive gcc
optimization that the very specific layout of the Nim C code allows that the
most natural C code does not.
Recursive Fibonacci was only ever useful as
Goal: Use the _HttpClient_ to communicate with a _ReST API_ through a _UNIX
socket_ provided by a _daemon_.
Details: _Podman_ is providing a brand new _ReST API_ (v2.0) and the _podman
daemon_ creates a _unix socket_ to which we can connect and start talking with
the application using _HTTP_.
@Serge \- it looks like you probably want CountTable which also has a sort proc
available. See
[https://nim-lang.org/docs/tables.html](https://nim-lang.org/docs/tables.html)
I learned recently that there is an ordered table, and a sort() proc which can
be applied to that ordered table. But I have not used it myself.
Or use a sorted Seq and binary search
I want to build a web app using Nim. It would have several pages, but each page
should have AJAX abilities if required. Would Jester + htmlx work for this? For
reference htmlx is the successor to intercooler js:
[https://github.com/htmlx-org/HTMLx](https://github.com/htmlx-org/HTMLx)
Could some
I was confronted, when switching to gc-arc for typeinfo the compilation did not
find any error except for the encapsulation in C. But I quickly understood the
mode of operation and the associations with the references (line) of the code.
This allowed me to correct;).
As for debugging the module
to say nothing is also to let it go, approved. therefore validated. I agree
with @Stefan_Salewski, impossible to say, it gives a bad opinion ...
Here is an example (snippet):
> # Dico is a table var Dico = initTable[string, int]()
>
> #wc is a tuple
>
> type wc = tuple
> word: string count: int
>
> # wc_seq is a sequence var wc_seq: seq[wc]
>
> for p in Dico.pairs:
> wc_seq.add(p)
>
> # sorting the sequence: wc_seq.sort(myCmp)
> we don't need to call the author stupid or a fool.
Sometimes I try to make a friendly face.
But when I see a fool I call him a fool, and when I see garbage I call it
garbage.
The author has been told about his debug mode issue 4 days ago. And did he
care? Not at all. Writing about something
> slurp or staticRead sounds too weird for me to recall what they really do
What would be _more_ obvious and explanatory of a name than staticRead, given
that one is familiar enough with the language to know that "static" refers to
compile time values?
Independent of whether the article is good or bad, we don't need to call the
author stupid or a fool.
Also, we should be happy people outside the main community take note of Nim and
write articles about it. If they get something wrong, we should educate and not
insult them.
Especially given th
> why is Person in a capital letter P in the let statement and with some small
> one in the following for .. in?
One's a type and the other is a variable of that type.
[https://nim-lang.org/docs/nep1.html#introduction-naming-conventions](https://nim-lang.org/docs/nep1.html#introduction-naming-co
This idea is almost as old as I am (it does predate my entry into programming
by a few years):
[https://en.wikipedia.org/wiki/UNCOL](https://en.wikipedia.org/wiki/UNCOL)
Nim (that is, Araq) made a wise choice and targeted the closest thing to it: C
I'm sorry, but I don't think Nim should consider targeting SOIL at this point.
It seems to be in a design stage, and doesn't have exact answers for how it
will solve problems of current IR representations, it just promises that "it
will be better". Also it seems to be heavily geared towards the
I came across the
[SOIL-initiative]([http://soil-initiative.org/](http://soil-initiative.org/))
which aims to create a Single Open Intermediate Language. I believe perhaps if
there is a collaboration with this initiative it might be of mutual benefit for
this project also. This can help further
> So nim's way is to make you implement all the methods you need by hand ?
No, Nim's way is to not do wrongheaded subclassing, as explained.
They try to pretend to be more professional than they are or just want to try
to gain some followers :P I only wrote one article about Nim sadly, in 2017
when I was relatively new to the language (and it's very small and just shows
generics/converters).
You can store any type in a HashSet as long as hash and == are defined on the
type (this is explained in the tables documentation but is omitted in the sets
documentation). If you still have trouble, maybe post what you've tried.
> I mean a transpiler for Nim to Python, like it already exists for C, C++ and
> ObjectiveC
The Nim compiler is a compiler, not a transpiler. I realize that many people
don't understand the difference between a compiler for language A that
generates code in language B, and a transpiler from lan
It may partially be the language barrier, but your comments are incoherent. You
could replace every const with let and it wouldn't affect program behavior
unless the variable is used in a when or {.compiletime.} context. And you could
replace every let with const as long as the initializer can b
C and C++ define the address of the element one beyond the end of an array to
be referable but not dereferenceable ... that is, you can take its address but
you can't access its content. Nim considers merely taking the address of the
element one beyond the end of an array or sequence to be a ran
94 matches
Mail list logo