Changer VSCode pour VSCodium

2020-11-22 Thread gemath
Microsoft's binary distribution of VSCode is under a non-open license and has monitoring/tracking built in. People who have a problem with that (like me) can build VSCode themselves from the MIT-licensed sources following [these instructions](https://github.com/microsoft/vscode/wiki/How-to-Contr

Example of a simply UDP client

2020-11-22 Thread jrfondren
Sending and receiving UDP while accepting stdin, with just selectors: import std/[net, selectors, strformat, strutils] const cfgMaxPacket = 500 cfgPort = 8800 localhost = "127.0.0.1" let socket = newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)

help with calling Nim-generated JS function from html page

2020-11-22 Thread Niminem
I found 1 issue, I wasn't using the `{.exportc.}` pragma (still a noob with any of the FFI stuff). I'm still not able to call the second proc, the one passing the param. Here is the proc: nim proc delCompetitor(divIdNum :cint) {.exportc.} = echo "deleting competitor"

help with calling Nim-generated JS function from html page

2020-11-22 Thread Niminem
Thanks man, didn't see your reply during my last comment here. Amazing.

help with calling Nim-generated JS function from html page

2020-11-22 Thread ElegantBeef
I'm uncertain as I've never actually touched the JS backend for anything, but should it not just be an `int`?

help with calling Nim-generated JS function from html page

2020-11-22 Thread ElegantBeef
You can use the `exportc` pragma to have Nim export the proc non mangled into a js file as follows. proc add(a, b: int): int {.exportc.} = a + b Run When using `nim js -d:release` it outputs this js function function add(a_385875971, b_385875972) {

help with calling Nim-generated JS function from html page

2020-11-22 Thread Niminem
Hey guys, I'm trying to call two functions using the onclick attribute like so: `` `Add Competitor` `Del Competitor` These functions are defined in a JavaScript file generated by Nim. when serving my page, I keep getting errors when I click either button saying they're undefined:

Changer VSCode pour VSCodium

2020-11-22 Thread Yardanico
VSCode itself is open source as well, there's no need to mention VSCodium IMO.

Changer VSCode pour VSCodium

2020-11-22 Thread JPLRouge
hello please say we could not change or modify the editor page because vscodium is there and bug-free on linux no more warning with the setlocale ect open-source extensions, and for nim 1.10 and it does almost everything so a language extension ex: a Nim, a drawio 1.03, Vs code printing f

Example of a simply UDP client

2020-11-22 Thread enthus1ast
since recently there is also async udp functionallity. So no need using useing threads

Example of a simply UDP client

2020-11-22 Thread JohnAD
Reading a string from the terminal is easy. Receiving a UDP packet is easy and there are ready examples. Sending a UDP packet is really easy. So SURELY doing all three at once is also easy I just spent many days on working out different ways to do that. Fortunately since UDP is connectionl

NimSuggest Not Working with Karax's or Jester's Macros

2020-11-22 Thread doofenstein
> Do you know any workaround for that? > >unfortunately no, though it used to > be worse > > Huh, didn't know about nim check. Tried running it on my Jester > files, no errors pop. Great! > >But with Karax files, it's a disaster. > Screens and screens of errors. > >Also, AFAIU nim check can't be

Unhandled exception in httpbeast

2020-11-22 Thread Peter
I'm testing my app on FreeBSD 13.0-CURRENT with NIM 1.4.0 (built from ports). After ~5 minutes of working, the web thread (Jester, communicating with web browser and some external modules) fails with the following error: /home/freebsd/Programming/noogest/noogest.nim(547) web /h

can't create seq in callback function

2020-11-22 Thread BarrOff25
Thank you, this seems to work, but I have to also add `--tlsEmulation:off`. However I can't try the other gc algorithms, as I am restricted to 1.0 releases. Reason for this is listed in opening post.

can't create seq in callback function

2020-11-22 Thread BarrOff25
Hello, I am currently implementing a little project using the [sdl2_nim](https://github.com/Vladar4/sdl2_nim) wrapper for SDL2. To handle the sound output I use the [openAudio](https://wiki.libsdl.org/SDL_OpenAudio) function, which takes an [AudioSpec](https://wiki.libsdl.org/SDL_AudioSpec)-po

can't create seq in callback function

2020-11-22 Thread Yardanico
Try calling `setupForeignThreadGC()` at the start of that callback or use --gc:arc or --gc:orc :)

a DSL to construct Nim AST based on karax

2020-11-22 Thread slonik_az
Actually, fixing `min` macro example is very simple. Just submitted a pull request against `fusion`

a DSL to construct Nim AST based on karax

2020-11-22 Thread b3liever
Nice, thanks!

C++ FFI - basic example

2020-11-22 Thread mantielero
I have manage to compile and run a simple example using OpenSceneGraph library: {.passL: "-losg -losgViewer", passC:"-I/usr/include/osg" } type Vec3Obj {.importcpp: "osg::Vec3", header: "Vec3", bycopy.} = object proc Vec3*(x,y,z:cdouble):

NimSuggest Not Working with Karax's or Jester's Macros

2020-11-22 Thread moigagoo
> nimsuggest crashing/getting hung up in an endless loop are things I > experienced myself and read other's have experienced as well. Do you know any workaround for that? > And checking for errors via nimsuggest is also not that accurate, which is > why often nim check is often used for that.

NimSuggest Not Working with Karax's or Jester's Macros

2020-11-22 Thread doofenstein
nimsuggest crashing/getting hung up in an endless loop are things I experienced myself and read other's have experienced as well. And checking for errors via nimsuggest is also not that accurate, which is why often `nim check` is often used for that.

NimSuggest Not Working with Karax's or Jester's Macros

2020-11-22 Thread moigagoo
So, I'm having pretty blocker-level issues with NimSuggest, Jester, and Karax. Before I proceed to report them, I'd like to ask the comminity if that's really how thing roll for everybody now. I'll be happy to know that there's something I'm doing wrong and fix it. So far, I'm clueless. Looks li

Nim image libraries

2020-11-22 Thread metasyn
The nim wrapper for ImageMagick looks pretty neat and useful here: *

Are these constants effectively saving computations?

2020-11-22 Thread cblake
@Stefan_Salewski is right. I just tried it out and even with the tcc/TinyC backend and even without any `-d:release` or anything `ord('Z')` translates to a literal `((NI) 90)` in the generated C. So, you shoull just think of `ord('Z')` as a more convenient way to spell `90`.

Is there some thing like `newSeqNoInit`?

2020-11-22 Thread Yardanico
:)

Is there some thing like `newSeqNoInit`?

2020-11-22 Thread treeform
In my quest for speed I want to create a new seq but setting it to all zeros is not necessary because I will be filling it in the next for loop anyways. I want t see if its faster if it just starts with garbage. You can do this for arrays and pointers etc... a {.noInit.}: array [0

Are these constants effectively saving computations?

2020-11-22 Thread Stefan_Salewski
> ord('Z') I can not remember a single compiler -- like old pascal on university mainframes with teletype terminal without monitor screen, or Modula and Oberon compilers where it made sense to introduce a named constant for this. Because 'Z' is already a 8 bit integer constant, so the ord() cal

std/tables [] vs. add()

2020-11-22 Thread cblake
Stdlib criticisms come up a lot, but it bears mention, re-mention, and re-re-mention that Nim programs need not be as dependent upon its stdlib as many other languages by design. Go has no generics (yet?) except weird special case things and Python needs C extensions to be at all performant whic

Why is the implicit `result` so widely used?

2020-11-22 Thread gemath
1) Because it enables some decoupling of control flow from value computation of procedures, and being able to do separation of concerns is generally a good thing, even if it's optional. 2) Most Nim programmers like their code short and concise, but that's not a religion: making important things

std/tables [] vs. add()

2020-11-22 Thread cblake
`adix/lptabz` also provides a two clause `template editOrInit` in case the value type of the table is giant or one prefers that "if-else" branch kind of visual structure. Note, though, that in both cases (stdlib & adix), key,value pairs are packed into one big linear memory area, not indirected

Are these constants effectively saving computations?

2020-11-22 Thread fxn
That is pretty neat too. Generally speaking, if there is a standard function that does what I need, I prefer it. Two reasons: * The code is concise: In `c in 'A'..'Z'` the reader has to infer what you are testing, whereas in `c.isUpperAscii` you need 0 brain cycles, it is obvious. In this pa

std/tables [] vs. add()

2020-11-22 Thread mildred
I didn't think mgetOrPut().add() would work, I was under the false impression that it was necessary to assign back the seq in the table after the add operation. I probably programmed too much in Go lately. Thank you, it does the job perfectly.

Are these constants effectively saving computations?

2020-11-22 Thread Hlaaftana
Well doing it like this would make it a little slower since you're passing it to a proc at runtime. You can do this: import strutils func rotateLetter(c: char, ordZ: static int, n: int): char = var rotatedCode = ord(c) + n if rotatedCode > ordZ: rotatedCode -

Are these constants effectively saving computations?

2020-11-22 Thread juancarlospaco
Code looks good. You can "unroll" the `if` into a `case`: case c of 'A'..'Z': rotateLetter(c, 90, n) of 'a'..'z': rotateLetter(c, 122, n) else: c Run Switching to ROT26 will also save computations.

Are these constants effectively saving computations?

2020-11-22 Thread cblake
Probably optimized to the same, but it depends on the compiler. E.g., TinyCC/tcc would probably not. gcc -O3 almost certainly would. Maybe Javascript engines would only optimize it so after 10 calls and some hotspot metric got hit. How "performance safe" you should be in such things likely depen

Why is the implicit `result` so widely used?

2020-11-22 Thread cblake
To maybe add some more details here, when Araq says "structured programming" he is referring to things like [the structured programming theorem](https://en.wikipedia.org/wiki/Structured_program_theorem) where all you need is if-else-while and bool variables. On the other hand, almost every prac

std/tables [] vs. add()

2020-11-22 Thread cblake
To explain the name weirdness a bit, it was meant to be similar to/consistent with "containsOrIncl", "hasKeyOrPut"-type language in other places. Sometimes explanations help people remember. :-)

Are these constants effectively saving computations?

2020-11-22 Thread fxn
Hi! Have a look at `rotateChar` in this ROTn cypher: import strutils func rotateLetter(c: char, ordZ: int, n: int): char = var rotatedCode = ord(c) + n if rotatedCode > ordZ: rotatedCode -= 26 chr(rotatedCode) func rotateChar(c: char, n: int):

std/tables [] vs. add()

2020-11-22 Thread Araq
Use `mgetOrPut` (the name is a bit weird): import tables proc add*(t: var Table[string, seq[string]]; key, value: string) = t.mgetOrPut(key, @[]).add value Run

std/tables [] vs. add()

2020-11-22 Thread cumulonimbus
The Python way is collections.defaultdict, which you provide a default value when creating the table (would be `@[]` in this case), and then you can just do `table[x].add y`. It's convenient to have in the stdlib, but I don't think it's worth considering outside of a bigger tables revision (e.g

closure in hashset, fail to compile with c++ backend

2020-11-22 Thread tommo
Hi, new Nim user here. I'm trying to use closure type in hashset, while the c backend works well, the c++ backend fails to compile. A minimal example: import sets type callType = proc() {.closure.} var tableA = initHashSet[callType]() let foo = proc()= discard