How to hot reload a Jester web app?

2020-11-18 Thread saem
I haven't used Jester before, but the custom router example shows how to get a proc: Additionally, I took a quick scan of the code and `routes:` is a macro, so it's just dumping a bunch of code at the top level, try putting the routes: block in a

Why does JSON serializing a table not work properly?

2020-11-18 Thread benjamindlee
Whoops! Thanks for pointing that out Araq–I completely forgot about that requirement.

Blog post about strict funcs

2020-11-18 Thread benjamindlee
I was thinking the same thing. In the style guide you have "Constants do no harm, variables do!" Along the same line of reasoning, making everything a `func` with exceptions for `proc`s seems like a better design choice. Same with `let`. Maybe even a compiler warning when `var` or `procs` don't

Blog post about strict funcs

2020-11-18 Thread Araq
> (though i wonder if the compiler can be ran with some options to analyse all > procs and find all that can be made funcs) ? We had such a tool but it didn't make it in any release. But yeah, more explicit annotations make sense for the stdlib. Beware of application level code though, ripple e

Why does JSON serializing a table not work properly?

2020-11-18 Thread benjamindlee
> E2: There does seem to be a hook for tables, not sure what's wrong then... > That's exactly why I was wondering. Seems like it should work out of the box which is why I was surprised.

Why does JSON serializing a table not work properly?

2020-11-18 Thread aEverr
ah good point, using numbers is valid for js objects but not json i assume.

Why does JSON serializing a table not work properly?

2020-11-18 Thread Araq
`{1: "one", 2: "two"}` is not valid JSON, JSON keys must be strings. This works just fine: import json import std/jsonutils import tables var a = {"one": 1, "two": 2}.toTable var j = jsonutils.toJson(a) echo j Run

Why does JSON serializing a table not work properly?

2020-11-18 Thread aEverr
looking at , there is no toJsonHook for Table[int, string]; this means you have to provide one, unfortunately.

Why does JSON serializing a table not work properly?

2020-11-18 Thread benjamindlee
I'm playing around with JSON and a bit surprised at its behavior. I can't for the life of me figure out how to write a table out to JSON. Example code: import json import std/jsonutils import tables var a = {1: "one", 2: "two"}.toTable var j = toJson(a) ech

Question about async

2020-11-18 Thread jackhftang
`runForever` will raise exception when no more pending timers, callbacks, file descriptors. import asyncdispatch var f = sleep_async 1000 f.add_callback proc() = echo "Sleep_async finished" try: runForever() except ValueError: if getCurrent

Nim c stuck at 99% CPU

2020-11-18 Thread jasonfi
This is only for a webapp I'm testing, other programs compile, including other webapps. With verbosity set to 3 these are the last few lines of output: /Users/user/.nimble/pkgs/jester-0.5.0/jester.nim(1298, 9) Hint: Asynchronous route: match. [User] hint(fmt"Asynchronous r

How to hot reload a Jester web app?

2020-11-18 Thread jasonfi
In web apps for Python, if you change the source, you can immediately see the difference in your web app. Can this be done with Nim and Jester? I read about hot reloading, but it requires that your main module calls another module that can be reloaded. But how to do this with Jester? From what I

Question about async

2020-11-18 Thread gcao
Hi, I got question about below code. Maybe my understanding on how async works in Nim is wrong. Please feel free to point that out. In the code if "poll()" is commented out, the callback is not triggered. I was expecting the dispatcher to kick in once sleep_async finishes. I was hoping I could

Getting random non-equal int pairs, comparison of routines.

2020-11-18 Thread Zoom
What threw me off is that we have values < 900 and they got clamped to the lowest temperature of the scale. Which points me to an idea of a feature: separate colour for overshoots and undershoots. Also, the default temp gradient has lower contrast and discernibility in the lower part than the

imgui

2020-11-18 Thread sekao
Strange...well [this SO answer](https://stackoverflow.com/a/12187682) says it comes from the `libxxf86vm-dev` package, so maybe try installing that with apt.

trouble , name etc...

2020-11-18 Thread JPLRouge
https://nim-lang.org/docs/posix.html#Key

ANN: NimDBX, a super-fast persistent key-value store

2020-11-18 Thread Araq
> Well, Nimterop has the advantage of being automatic: if some functions are > added in the header, it will be easy to keep it up to date And it has the disadvantage that you cannot ship the Nim code as it's OS and CPU specific. So what if functions were added to the header, who says that you n

Error: system module needs: appendString

2020-11-18 Thread Araq
What kind of information do you want though? If you develop an OS, chances are you cannot use `echo` / IO... Thanks to `-d:StandaloneHeapSize=1048576` you can use a heap though. And you can always read Nim's internals.

Sample compiler/interpreter (like kaleidoscope/llvm, monkey/go etc)

2020-11-18 Thread treeform
I prefer the way Araq writes his parser. He writes them pretty much from scratch without parser generators. It's actually not that hard and you can give better errors to the user. See an example for json: See an example

Error: system module needs: appendString

2020-11-18 Thread AlectronikHQ
Ok, thanks, but I am looking for actual information about these internals to continue, so that I don't have to ask for every next error appearing. Sorry if I have been unclear.

ANN: NimDBX, a super-fast persistent key-value store

2020-11-18 Thread ITwrx
For some reason this forum didn't notify me of your reply. That's great! I hope you'll consider documenting install and usage with us poor souls coming from high level languages, frameworks and ORMs in mind. :) I, for one, like the Arch wiki style: short code examples that show all the necessar

a DSL to construct Nim AST based on karax

2020-11-18 Thread b3liever
Damn and I liked that example because it showed pretty much all the basics. Anyone has a small macro that can be used as an example?

Optional var out proc parameters

2020-11-18 Thread Araq
I wasn't aware of this trick. Please add it to the test suite immediately so that we can keep it working.

C library bindings generator

2020-11-18 Thread snej
[Nimterop](https://github.com/nimterop/nimterop) is a more powerful bindings generator.

Optional var out proc parameters

2020-11-18 Thread Stefan_Salewski
In C we may pass a pointer to a valid storage location to functions when we are interested in that out parameter, and NULL when not. Full story at demotomohiro explained recently that we can indeed fake that behaviour for Nim's var parameter

trouble , name etc...

2020-11-18 Thread JPLRouge
I have defined an enum Key to work in a terminal everything worked perfectly except that I needed to use import OS which also has a definition of Key suddenly the compiler rightly pointed out a conflict to me This is one of the reasons why I ask questions

Sample compiler/interpreter (like kaleidoscope/llvm, monkey/go etc)

2020-11-18 Thread spip
Have a look [here](https://github.com/nim-lang/Nim/wiki/Curated-Packages#language) and then you can extend your search to nimble packages...

trouble , name etc...

2020-11-18 Thread Araq
Well `os.nim` has no public symbol named `key`. And the compiler tells you how to disambiguate, use `moduleName.key`.

A nice read about Nim (blog article)

2020-11-18 Thread cblake
I took another look at this with a month having flown by. :) Taking @Araq's excellent advice and just using `parsejson` directly, this program is 2.13x faster (gcc-10 PGO with `--gc:orc`) than the Kostya version, and needs no weird patches to the Nim stdlib: when defined(cbFParse)

Error: system module needs: appendString

2020-11-18 Thread Araq
As I said, compile with `--gc:arc --os:any -d:StandaloneHeapSize=1048576`.

Sample compiler/interpreter (like kaleidoscope/llvm, monkey/go etc)

2020-11-18 Thread AlectronikHQ
I am both learning nim and how programming languages work in general, and thought about writing some toy compiler in nim. First (and only) thing I found about parser generators which are both somewhat mature and actively maintained for nim is npeg, but that one looks pretty good. Still would pre

C library bindings generator

2020-11-18 Thread AlectronikHQ
Do we have such a thing for nim, besides c2nim? If not, do we have up-to-date bindings to clang (they change an awful lot of stuff with each and every release, I do absolutely not intend to mess with them) to build such one? Or does a clang based binding generator for e.g. ruby, nodejs, python

imgui

2020-11-18 Thread enthus1ast
i would start the compilation with an strace and have a look where it searches the .so

imgui

2020-11-18 Thread pihentagy
I do installed those, but the error message remains the same. Maybe I should complain at the developers of imgui ~ ⌚ 19:12:33 $ sudo apt-get install xorg-dev libglu1-mesa-dev [sudo] password for pihentagy: Reading package lists... Done Building dependency tree Rea

Error: system module needs: appendString

2020-11-18 Thread AlectronikHQ
Any hints about the nimErrorFlag?

imgui

2020-11-18 Thread pihentagy
I do installed those, but the error message remains the same. Maybe I should complain at the developers of imgui :) ~ ⌚ 19:12:33 $ sudo apt-get install xorg-dev libglu1-mesa-dev [sudo] password for pihentagy: Reading package lists... Done Building dependency tree

internal error : where to report

2020-11-18 Thread enthus1ast
like this? import os, strutils iterator stripped(fh: File): string = for line in fh.lines : yield line.strip proc read(input: File) = for line in stripped(input) : echo line read(stdin) Run

internal error : where to report

2020-11-18 Thread HJarausch
@cblake I'd need some help with this iterator wrapper. I have tried import os, strutils iterator stripped[T](orig:iterator : T) : T = for l in orig.lines : yield l.strip proc Read(Input:File) = for L in stripped(Input) : echo L Read(s

ANN: NimDBX, a super-fast persistent key-value store

2020-11-18 Thread snej
My wrapper was pretty incomplete, probably less than half of the C API. As I expand my library's coverage, it’ll be easier since I now have a complete wrapper.

trouble , name etc...

2020-11-18 Thread Hlaaftana
You can qualify symbols with their module name, if that helps. # a.nim type int* = object # b.nim import a var x: a.int Run

internal error : where to report

2020-11-18 Thread cblake
You should report the error on [the Nim github](https://github.com/nim-lang/Nim). In this case you are applying a proc/iterator `strip` to the `lines` iterator which is not valid. You probably want this instead which compiles fine: import os, strutils proc read(input: File) =

internal error : where to report

2020-11-18 Thread jackhftang
The problem is that you called `strip` on `iterator`. import strutils proc read(input: File) = for line in input.lines: echo line.strip read(stdin) Run This should be considered as a bug in compiler, you may report it on github.

trouble , name etc...

2020-11-18 Thread jackhftang
Could you give some examples??

internal error : where to report

2020-11-18 Thread HJarausch
The following naive proc generates an internal error /usr/lib/nim/system/io.nim(911, 10) Error: internal error: proc has no result symbol No stack traceback available To create a stacktrace, rerun compilation with './koch temp c ', see https://nim-lang.github.io/Nim/intern.

trouble , name etc...

2020-11-18 Thread JPLRouge
I may not be explicit enough: I can make or use a module with "proc" which works but not in all cases and end up with "proc" which has the same name and do not do the same thing ... that's what I'm talking about , of course what you tell me works but not in the case I am talking about

Possible usage of Nim & Z3 for embedded?

2020-11-18 Thread mratsim
Related RFC Correct-by-Construction Nim programs **Motivating examples** You are designing software for one of the following scenarios: * A safety system that prevent opening doors while a vehicle is moving * A scheduler for complex urban crossr

trouble , name etc...

2020-11-18 Thread Yardanico
Just check that the name you're using is not the same of some stdlib module or not in

trouble , name etc...

2020-11-18 Thread JPLRouge
Hello , I will try to relate my problem. it happens that when I use a module there are antinomy in fact they are "proc ... var etc" with names that already exist ... Couldn't there be a standard that would and make this more consistent already having a full "nim" dictionary and a controller to

Question to tables & objects

2020-11-18 Thread AlectronikHQ
I tried to nest a table into an object as follows: import tables > type Dict = Table[string, int] > type My = ref object > dict: Dict > idx: int > > > var m = new My > m.dict[0] = "Hello" Now the last statement causes a long type mismatch error: (sorry, need to RST style) Thanks for any hints

Question to tables & objects

2020-11-18 Thread Yardanico
Your mistake is that you're: 1) not using initTable 2) doing the wrong order, Table[string, int] means that it's a mapping from strings to integers, not the other way. The correct way to do what you want (if I understood you correctly) would be: import tables type Di

ANN: NimDBX, a super-fast persistent key-value store

2020-11-18 Thread andrea
Well, Nimterop has the advantage of being automatic: if some functions are added in the header, it will be easy to keep it up to date

ANN: NimDBX, a super-fast persistent key-value store

2020-11-18 Thread Araq
> Also using Nimterop to generate a Nim wrapper of the C header, instead of my > hand-written one. Er, please keep the hand-written one... :-( IMO Nimterop is for when you don't have the time to hand-craft a wrapper.

Possible usage of Nim & Z3 for embedded?

2020-11-18 Thread elcritch
> Btw, there have been found north of 1000 bugs in Z3 and other solvers are > unlikely to be much better. > Maybe we need a solver written in Ada, F star > or at least in Nim ... That's only really an issue if the bugs compound. Bugs in Z3 as a language proofer should mostly be independent of b

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-18 Thread Araq
There is also

Possible usage of Nim & Z3 for embedded?

2020-11-18 Thread Araq
I'm not worried about that at all, Z3 works well and I wrote a proof engine before, eventually we can replace it with a custom one written in Nim. But it's much too early to even consider that.

Passing iterators as arguments

2020-11-18 Thread Sixte
> I wanted to avoid passing around containers that would then get copied, and > pass around iterators instead This is exactly what @timothee's proposal is good for. It allows you to pass iterators directly. The compiler expands the iterator structurally via inlining, or, at least, it has the po

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-18 Thread mildred
I managed to reduce gc insafety in my codebase to few things only: * [scram](https://nimble.directory/pkg/scram), client package (shown above) but it is actually gcsafe becaue when threads are enabled the global variable is replaced by a thread local variable * [scram](https://nimble.directo

Win10 terminal game

2020-11-18 Thread lepot311
This looks cool. Right now we are just sticking to the standard library, but I can imagine using something like this on my own side projects. Bookmarked!

Win10 terminal game

2020-11-18 Thread lepot311
The goal is to eventually leverage libraries like SDL2. Today was hello world. I'd like him to have the experience of writing a basic-style game, even if it's just text based or uses characters on a terminal to represent tiles.

Win10 terminal game

2020-11-18 Thread lepot311
Thanks that looks helpful! I'll investigate tomorrow.

Win10 terminal game

2020-11-18 Thread enthus1ast
Have a look at illwill this does double buffering the output and read the input keys asyncronously If you need buttons etc you could also have a look at my illwillwidgets library: Or as araq suggest use sdl2