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
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
True, by changing it into cstring, the output is correct, and the generated js
is much smaller.
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
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.
I think @adnan is right, in the round function output like 88.91 is
expected, but fmt should trim it to 2 decimals.
@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++) {
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() {
TreeOfDepth benchmark :P
Right, i had DateTime field in the User type. Commented it out, and there are
no errors :)
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.
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
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
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
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?
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
You can do
import V:/src/anygui as vg
Run
then use vg.someprocinvg
Tested on devel, its fixed now. That was fast :P
I can confirm this: withouth 'f32:
Time [LightWorld ] 3.094s
CPU Time [WriteEntities] 0.256s
Run
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
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
@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
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
I do f = open(filename)
Istrere any way to open it in text mode, or binary?
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)
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 =
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
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
Damn, that's fast!
Yes, but the container is seq[seq[float]], Im adding 10 floats 1000 times :)
/* 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
[check this
out](https://bitbucket.org/DraganJanushevski/q3bsp/src/cee3bf04b30414672939c0ffde25011ec026a822/src/coreBSP/bspfile.nim#lines-18)
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?
Im looking forward to replace glm with vmath, because its oure and more
portable.
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); //
:) Well it compiled, but didn't work because all those lacking casts
Anyway, we have lightmaps now :)
Tnx Stefan, it works.
So as i understood, this is similar to () when using c++ vector?
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,
38 matches
Mail list logo