Re: Some rant about nim

2020-03-03 Thread r3c
Yap, compiling with -d:release only adds range checker helper function static N_INLINE(NI, chckRange)(NI i, NI a, NI b) Run This is a design decision, should the codegen generate range checker with -d:danger, not my call :P

Re: Some rant about nim

2020-03-03 Thread r3c
type iX = range[1..5] var a: iX = 3 var b = 10 a = b Run When you compile this with -d:release -d:danger it doesn't throw any error. In the generated C file, type iX doesn't exist at all

Re: Bug with makeNimstrLit on JS backend

2020-02-26 Thread r3c
True, by changing it into cstring, the output is correct, and the generated js is much smaller.

Bug with makeNimstrLit on JS backend

2020-02-26 Thread r3c
This is the source file import jsffi var console {.importc, nodecl.}: JsObject type Person = object name: string age: int32 var p: Person p.name = "foo" p.age = 90 console.log(p) Run in the output js, the str

Re: Interlanguage communication

2020-02-25 Thread r3c
Like in any other language node script.js -param1 -param2 etc. But if you want to pass data from client to server, you do that with Ajax or RESTful service.

Re: Nim's float issue?

2020-02-25 Thread r3c
I think @adnan is right, in the round function output like 88.91 is expected, but fmt should trim it to 2 decimals.

Re: Using the JS Backend as transpiler

2019-10-08 Thread r3c
@Araq my intent is to output more readable and debbugable code. Im currently looking at **jsgen.nim** Lets say I want to make a new backend target - Typescript The resulting code shoud look like this: const msg:string = "TS Backend"; for(i = 0; i<=10 ; i++) {

Using the JS Backend as transpiler

2019-10-07 Thread r3c
Lets say we have this code: const msg = "JS Backend" for _ in 0..10: echo msg Run The loop is converted to while-do block, and the echo is passed trough rawEcho(makeNimstrLit("JS Backend")); function rawEcho() {

Re: Nim v1.1 and beyond roadmap

2019-10-05 Thread r3c
TreeOfDepth benchmark :P

Re: Introducing Norm: a Nim ORM

2019-10-05 Thread r3c
Right, i had DateTime field in the User type. Commented it out, and there are no errors :)

Re: Introducing Norm: a Nim ORM

2019-10-05 Thread r3c
With nim 0.20.2 or newer theres an error: template/generic instantiation from the withDb macro and getOne/getMany procs It compiles, but its very frustrating because nimsuggest marks them as errors.

Re: Karax/Jester simple CRUD example?

2019-10-01 Thread r3c
I found this: [https://github.com/enthus1ast/nimWebTemplates](https://github.com/enthus1ast/nimWebTemplates) Its very similar to Jinja templates in Django, and it has some nice examples  For passing data to FE you must use restful api, just like any other frontend framework

Re: Karax/Jester simple CRUD example?

2019-09-30 Thread r3c
Thanks Huan, but I was looking for the most simpe CRUD example with Jester/Karax and all I found is this: [https://github.com/emekoi/joker](https://github.com/emekoi/joker) Which is useless, because its rendering static strings on the FE. Too bad, the frameworks are there, but there is lack of

Re: Persistent data structures

2019-09-30 Thread r3c
You mean something like [immer.js](https://immerjs.github.io/immer/docs/introduction) ? I think not, but it would be very easy to create library like this

Karax/Jester simple CRUD example?

2019-09-30 Thread r3c
In other frameworks like Django, you can read from the DB into array/list, pass the array onto view and display it trough HTML Template. So you can do this without single line of JS code. Is it possible something similar with Jester? How do I pass the array from the BE to FE?

Re: Split on whitespace except for between quotes

2019-09-07 Thread r3c
Try this import strutils var str = "spam eggs \"spam and eggs\" asd zxc" var spl = str.split("\"") for s in 0..spl.high: if spl[s].startsWith(" ") or spl[s].endsWith(" "): spl[s] = spl[s].strip echo spl Run

Re: nimble configuration for local/publicated library

2019-09-05 Thread r3c
You can do import V:/src/anygui as vg Run then use vg.someprocinvg

Re: Help me optimize this small Nim port to the speed of the original C version

2019-08-27 Thread r3c
Tested on devel, its fixed now. That was fast :P

Re: Help me optimize this small Nim port to the speed of the original C version

2019-08-26 Thread r3c
I can confirm this: withouth 'f32: Time [LightWorld ] 3.094s CPU Time [WriteEntities] 0.256s Run

Re: Help me optimize this small Nim port to the speed of the original C version

2019-08-26 Thread r3c
Yes, I have hidden converters :) Its in ptrmath.nim from @Jenah About c2nim, yes i converted the code initialy, but i changed the types like cint, cfloat, cuint, if I remember correctly, the object types had some issues with the sizes. Also they had {.bycopy.} pragma

Re: Help me optimize this small Nim port to the speed of the original C version

2019-08-26 Thread r3c
Im using MinGW 4.9.2, used TDM GCC 5.1, but its even slower with it. 4.9.2 compiles faster, produces faster code and smaller binary. Tried with: **-O2** , no difference **-flto** , speeded up the parser, wich uses .split(), but did nothing to TestLine **\--gc:nome** , did nothing except

Re: Help me optimize this small Nim port to the speed of the original C version

2019-08-26 Thread r3c
@Stefan_Salewski thanks for the feedback. I compared the sizes of the structs, they same as the C version, ("Tnode_t size: ", 32) ("Tracestack_t size: ", 20) Run

Help me optimize this small Nim port to the speed of the original C version

2019-08-25 Thread r3c
I'm almost finished with the porting of the original Quake map compiling tools from 1996, written in C. To be more precise, the tool that calculates the light for the map, nothing special, it a straight 1:1 port. After initial benchmarks i ran on various maps, it turned out that the Nim

Re: getFilePos - inconsistent output

2019-08-17 Thread r3c
I do f = open(filename) Istrere any way to open it in text mode, or binary?

getFilePos - inconsistent output

2019-08-16 Thread r3c
Im reading binary file, storing the data into arrays, and then writing the data into another file. Basicly, a copy. Everything was fine, but then suddenly, out of nowhere, the output file was corrupt. the size of the output is exact like the input, however, if loaded in Quakespasm (Q1 engine)

pointer arithmetic example?

2019-08-13 Thread r3c
How to substract two pointers like in C, to get the distance between them in some array? Concider this example byte *filebase, *file_p, *file_end; byte dlightdata[MAX_MAP_LIGHTING]; byte *GetFileSpace (int size) { byte*buf; file_p =

Re: Tables - can't get the address of value

2019-08-01 Thread r3c
When im creating the faces, i know their exact number, but to speedup the rendering, I want to merge them by their common texture. I dont know the number of the merged faces, so I have to make one [loop trough all the

Tables - can't get the address of value

2019-08-01 Thread r3c
I use table in type like: type RenderableObject* = object vertices_tbl*: Table[int, seq[float32]] indices_tbl*: Table[int, seq[uint32]] # init var FACE : RenderableObject FACE.vertices_tbl = initTable[int, seq[float32]]() FACE.indices_tbl

Re: Nim Seq.add vs. C++ Vector.push_back performance

2019-07-30 Thread r3c
Damn, that's fast!

Re: Nim Seq.add vs. C++ Vector.push_back performance

2019-07-30 Thread r3c
Yes, but the container is seq[seq[float]], Im adding 10 floats 1000 times :)

Nim Seq.add vs. C++ Vector.push_back performance

2019-07-30 Thread r3c
/* g++ -O3 -pedantic -Wall -std=c++11 vecbench.cpp -o vec.exe && ./vec.exe */ #include #include #include std::vector> vec; int main(int argc, char *argv[]) { vec.resize(1000); clock_t begin = clock(); for

Re: Noob question: proper way to read binary files byte by byte

2019-02-24 Thread r3c
[check this out](https://bitbucket.org/DraganJanushevski/q3bsp/src/cee3bf04b30414672939c0ffde25011ec026a822/src/coreBSP/bspfile.nim#lines-18)

Re: std::pair, std::make_pair, std::find, std::distance in Nim?

2019-02-23 Thread r3c
Thanks, it works! In my case, i dont need std::distance, because system.find does the job. Can it be implemented with slice maybe? Another question, is there something similar to std::map in Nim?

Re: Geometry Library

2019-02-22 Thread r3c
Im looking forward to replace glm with vmath, because its oure and more portable.

std::pair, std::make_pair, std::find, std::distance in Nim?

2019-02-22 Thread r3c
Hi, I have block of code in C++ like this: ++ std::vector> TL; int texture, lightmap; auto p = std::make_pair(texture, lightmap); // make pair auto it = std::find(TL.begin(), TL.end(), p);// iterator int pos = std::distance(TL.begin(), it); //

Re: OpenGL glTexImage2D from GLfoat problem

2019-02-16 Thread r3c
:) Well it compiled, but didn't work because all those lacking casts Anyway, we have lightmaps now :)

Re: OpenGL glTexImage2D from GLfoat problem

2019-02-16 Thread r3c
Tnx Stefan, it works. So as i understood, this is similar to () when using c++ vector?

OpenGL glTexImage2D from GLfoat problem

2019-02-16 Thread r3c
I want to load raw texture from floats like this: var missingLM : GLuint # missing lightmap index let white : seq[float32] = @[1.0'f32, 1.0'f32, 1.0'f32, 1.0'f32] glGenTextures(1, missingLM.addr) glBindTexture(GL_TEXTURE_2D,missingLM) glTexImage2D(GL_TEXTURE_2D,