Re: Nim-based IoT thermostat

2018-05-23 Thread r3d9u11
Nice It would be cool to see Arduino's firmware on Nim to get full-stacked application on Nim

Re: which part of std. lib can work without GC?

2018-05-08 Thread r3d9u11
jba, did you have any problems with GC? I saw the project [Ardunimo](https://github.com/gokr/ardunimo) and it have some troubles with GC

Re: which part of std. lib can work without GC?

2018-05-08 Thread r3d9u11
Stefan_Salewsk, thanks for detailed answer and thanks for useful link!

Re: which part of std. lib can work without GC?

2018-05-08 Thread r3d9u11
Ok, I will ask a question differently, more specific: when programming microcontroller 1. is there risk that not disabled GC will eat an additional resources (program size, ram-memory size, proccess time)? 2. is there risk to drop a most part of Nim's stdlib with disabled GC?

Re: which part of std. lib can work without GC?

2018-05-07 Thread r3d9u11
Thanks for answer, but it looks like GC cannot be disabled in future versions of Nim but, there still many situations in system programming, where GC will be superfluously (in the low-level for example or dynamic modules).

which part of std. lib can work without GC?

2018-05-04 Thread r3d9u11
Hi. I saw notice from some Nim's users, that Nim's standard library is broken when GC is disabled. It would be cool to see which part of Nim's standard library works fine without GC and which part requires GC (to avoid negative surprises in the future). Thanks.

How to count varargs[untyped] inside of template?

2018-04-02 Thread r3d9u11
Hi. I have a template with vararg[untyped] parameters, can I get count of parameters and realize branching like a: template tmpl*(args: varargs[untyped]): untyped = when args.len > 0: # here is compilation will be excepted #... else: #... Thanks.

Re: How to get string representation of int inside of the macros?

2018-04-02 Thread r3d9u11
cool, thanks for another solution!

Re: Why macros can't find a local module?

2018-04-02 Thread r3d9u11
many thanks!

Re: Why macros can't find a local module?

2018-04-01 Thread r3d9u11
yes, it works without macro. probably, your code works because strutils is a global module.

Re: Why macros can't find a local module?

2018-04-01 Thread r3d9u11
Thanks for hint, but idea that module name isn't hardcoded and contained inside of string.

Why macros can't find a local module?

2018-04-01 Thread r3d9u11
Hi. Why a local module can't be found at macro-time? myModyle.nim: echo "myModule loaded" main.nim: macro loadModule(): typed = result = parseStmt("import myModule") loadModule() # will rise exception "cannot open 'myModule'" Is it possible

Re: How to get string representation of int inside of the macros?

2018-03-30 Thread r3d9u11
many thanks, it works! (I'll try to search and read about static types)

How to get string representation of int inside of the macros?

2018-03-30 Thread r3d9u11
Hello. I tried to represent int to string inside a macros: import macros macro initNui(a:int): typed = result = parseStmt("const b=" & $a) initNui(1) but I had compilcation error: unhandled exception: false Invalid node kind nnkIntLit for

Re: Dynamic import of packages at macro-time

2018-03-30 Thread r3d9u11
well, I'm found [similar theme](https://forum.nim-lang.org/t/3061/2). This works: import macros macro load*(modulesSeq: varargs[untyped]): untyped = result = newStmtList() for module in modulesSeq: result.add parseStmt("from " & $module & " import nil")

Dynamic packages import at macro-time

2018-03-30 Thread r3d9u11
Hi. Does Nim supports anything like a "dynamic packges loading"? For example, I have 3 packages: pack0.nim (root package) contains: var dstBack = 0 # some variable-indetifier (will indicate, from wich poackage someProc will be called) macro init*(back:int) = #

Re: how to call a function by name?

2018-03-30 Thread r3d9u11
Thanks for clarification regarding Nim! (but, as I know, "reflection" is a conception relating only for runtime. everything else is something different)

Re: how to call a function by name?

2018-03-30 Thread r3d9u11
But is it possible in Nim to call procedure with parameters who name and parameters will be known at runtime (and get result value)? Does Nim support reflection?

Is there reflection in Nim?

2018-03-29 Thread r3d9u11
Hi. Is it possible in Nim to call procedure with parameters who name and parameters will be known at runtime (and get result value)?

Re: How to dealloc complex object correctly?

2018-03-29 Thread r3d9u11
thanks!

How to dealloc complex object correctly?

2018-03-24 Thread r3d9u11
Hi. I have a complex object declared in shared memory: type SubObj = object idata: int fdata: float sdata: string MyObj = object title: string data: SubObj var lock: Lock var shrObj {.guard: lock.}: ptr MyObj

Re: how to get value of object's field from second thread?

2018-03-20 Thread r3d9u11
Thanks!

Re: how to get value of object's field from second thread?

2018-03-20 Thread r3d9u11
well, "\--threadAnalysis:off"+globalvar+lock looks nice: import os, threadpool, locks type MyObj = ref object flag: bool var olock: Lock var obj {.guard: olock.}: MyObj proc someThread() {.gcsafe.} = {.locks: [olock].}: if

Re: how to get value of object's field from second thread?

2018-03-20 Thread r3d9u11
Thanks, I saw your examples in previous posts with similar theme (I've post link before). Well, I did "simple" application, who demonstrate exchanging process of object between two threads. This model looks it is logical, but code looks really mad and inflexible (for 21th), sorry:

Re: how to get value of object's field from second thread?

2018-03-19 Thread r3d9u11
I trying to do workaround for [this issue](https://github.com/filcuc/nimqml/issues/21) and also try to understand, how to correctly pass data beetween threads in Nim for future projects (in other languages I had not any difficulties or problems with this ).

Re: how to get value of object's field from second thread?

2018-03-19 Thread r3d9u11
How to do it correctly and, probably, elegantly? (sorry, but constructions like [this](https://forum.nim-lang.org/t/1572/2#9868) looks a bit mad for this easy task I tried something like a: import os, threadpool type MyObj = object flag: bool proc

Re: socket.close crashes in multithreaded application

2018-03-19 Thread r3d9u11
my bad, this works fine proc stop*(server: Server) = server.started = false server.clients.setLen(0) if server.loopTask != nil: server.loopTask.complete() server.loopTask = nil if server.socket != nil: server.socket.close()

socket.close crashes in multithreaded application

2018-03-19 Thread r3d9u11
Hi. Why does crash "socket.close" when it called from second thread? server.nim: ... type Server* = ref object socket: AsyncSocket ... ... ... proc newServer*(): Server = Server( socket: nil, ... )

Re: Need more detailed examples with async/await

2018-03-13 Thread r3d9u11
Many thanks for this discussion! Now everything became clear

Re: Need more detailed examples with async/await

2018-03-13 Thread r3d9u11
Really, the answer to question about understanding Nim's async/await went out of borders of question about using it directly in Nim. Shortly as I understand: behavior of this feature similar to C#, but Nim's "async/await" can be used specially for IO operations (stdin/out, network sockets,

Re: Need more detailed examples with async/await

2018-03-13 Thread r3d9u11
Thanks for example. Yes, I saw that notice in manual (about singlethreaded). Think this code does same my C#-example: import asyncdispatch, threadpool from os import sleep proc sum (count: int): int = result = 0 for i in 0..count: result += i proc

Need more detailed examples with async/await

2018-03-13 Thread r3d9u11
Hi. I need little more help with Nim's async/await. I did two samples: for C# and Nim. C#: using System; using System.Threading.Tasks; namespace AsyncSample { class MainClass { static bool ap1Done = false;

Re: Need help with async client/server

2018-03-12 Thread r3d9u11
I thought that all code into async function will be async too my bad. A lot of thanks for all for your clarifications and hints!

Re: Need help with async client/server

2018-03-12 Thread r3d9u11
ok, problem solved. just need to wait before sending data. I don't know why: proc sendClientMsg (c: AsyncSocket) {.async.} = while true: waitFor sleepAsync(1000) let msg = stdin.readLine() echo "<- " & msg await c.send(msg & "\c\L")

Re: Need help with async client/server

2018-03-12 Thread r3d9u11
something wrong when I tried to read data from stdin! this code works fine: client.nim proc readServer(c: AsyncSocket) {.async.} = while true: let msg = await c.recvLine() echo "-> " & msg proc sendClientMsg (c: AsyncSocket) {.async.} = while

Re: Need help with async client/server

2018-03-12 Thread r3d9u11
this code works fine: proc sendClientMsg (c: AsyncSocket) {.async.} = #while true: let msg = stdin.readLine() echo "<- " & msg await c.send(msg & "\c\L") why code with loop doesn't work? how to organize parallel/async read/write?

Re: Need help with async client/server

2018-03-12 Thread r3d9u11
well, I changed code. server.nim: import asyncnet, asyncdispatch, nativesockets var clients {.threadvar.}: seq[AsyncSocket] proc processClient(client: AsyncSocket) {.async.} = while true: let msg = await client.recvLine() for c in clients:

Need help with async client/server

2018-03-12 Thread r3d9u11
Hi. I'm trying to write simple async network client and server via AsyncSocket (by [sample from manual](https://nim-lang.org/0.13.0/asyncnet.html#examples-chat-server)). But client and server don't read any data. What I'm doing wrong? server.nim: import asyncnet, asyncdispatch

Re: what use instead of 'capitalize'?

2018-03-11 Thread r3d9u11
thanks!

what use instead of 'capitalize'?

2018-03-11 Thread r3d9u11
Hi. I have warning: "message: 'capitalize is deprecated [Deprecated]'". What function I can use instead of it?

Re: Operations with files in nimscript?

2018-03-04 Thread r3d9u11
Many thanks!

Operations with files in nimscript?

2018-03-04 Thread r3d9u11
Hi. Module os doesn't allow in nimscript lib/nim/pure/times.nim(79, 9) Error: cannot 'importc' variable at compile time How I can to manipulate files from nimsript? (for example by function walkDir and etc.)

Re: Resources embedding

2018-03-04 Thread r3d9u11
Thanks! But it will work only for text, what about binary files?

Re: how to define compiler's options in .nimble file?

2018-03-03 Thread r3d9u11
yep, I maked something like a build_debug.nims: import ospaths mode = ScriptMode.Verbose version = "1.0" author = "Username" description = "Build with debug configuration" license = "MIT" let out_dir = "bin/debug" let qml_files =

Re: how to define compiler's options in .nimble file?

2018-03-03 Thread r3d9u11
I think I should use NimScript

how to define compiler's options in .nimble file?

2018-03-03 Thread r3d9u11
Hi. I'm trying to make a two build-files for nimble: main_debug.nimble and main_release.nimble. I want to define in .nimble file: * compiler: cc * compiler config: debug (-d:debug) or release (-d:release) * nimcache directory (set to "bin/nimcache") Is it possible?

Re: Need help with GUI and data visualisation (charting/plotting) in Nim

2018-03-02 Thread r3d9u11
UPD: just now found gtk widget [GtkDatabox](http://www.eudoxos.de/gtk/gtkdatabox/screenshots/index.html), also it works with Gtk3. Will try to wrap it.

Re: Need help with GUI and data visualisation (charting/plotting) in Nim

2018-03-02 Thread r3d9u11
mratsim, thanks! (but how arraymancer-vision it's something lika a gnuplot, I think)

Need help with GUI and data visualisation (charting/plotting) in Nim

2018-03-02 Thread r3d9u11
Hi. Is there somebody, who works with data visualisation and have a success experience in this theme with Nim? I'm looking for gui-frameworks or libraries, who provides to make a GUI interface with Data Visualization. For example application for displaying a spectrogram or osciloscope. I'm

Re: properties fo objects

2018-02-24 Thread r3d9u11
Yep, but host and h are both fields of Socket, no? (Perhaps I do not fully understand procedural programming for the present, I'm used to OOP only defore). Ok, it is works: main.nim: import InfoModule var info: Info new info info.level = 5 echo info.title

Re: properties fo objects

2018-02-24 Thread r3d9u11
The [manual page](https://nim-lang.org/docs/tut2.html#object-oriented-programming-properties) shows that setter have same name as field of object. And it is implicitly called (s.host = 34). What differents?

properties fo objects

2018-02-24 Thread r3d9u11
Hi, I need a help with properties. Why setter isn't call? Also how to set property "title" to readonly state (disable setter)? type Info* = ref object of RootObj level: int title: string proc `level=`*(info: var Info, level: int) {.inline.} =

Re: need an explanation of strings/add behavior

2018-02-23 Thread r3d9u11
Thanks for answer!

Re: How to call original procedure from overloaded?

2018-02-23 Thread r3d9u11
Thanks!

Can I call

2018-02-22 Thread r3d9u11
Hi! Can I call "original" procedure from overloaded? I Can't find any example for this theme for example: proc `$` (x: int):string = "Integer " & ($x) echo 5 is infinite recursion as solution a tried to make additional procedure proc toString (x:

Re: for loop and pairs question, explanation needed

2018-02-22 Thread r3d9u11
Thanks! (I was misled by string representation of pair. its string representation is string representation of contained element. Also after C/C++/C#/JS the syntax is still little bit unaccustomed for me, yet ;)).

for loop and pairs

2018-02-22 Thread r3d9u11
Hi. I have a little question: what differents between samples? And why first sample works? for index, item in ["a","b"]: echo item, " at index ", index # => a at index 0 # => b at index 1 for index, item in ["a","b"].pairs: echo item, " at index ", index

Re: Nim's status discussion

2018-02-22 Thread r3d9u11
Wow, many thanks for detailed answer! This is very usefull post about Real Valley! Under "MultiMedia engine" I mean library/framework/engine for making visual crossplatform application, who can be rendered to opengl/directx/webgl, something like a [Kha](https://forum.nim-lang.org/kha.tech),

Re: Nim's status discussion

2018-02-21 Thread r3d9u11
Many thanks for your answer! Is [it a port for android](https://play.google.com/store/apps/details?id=com.onsetgame.reelvalley) of Real Valley that you noted? Can I ask, wich engine was used for this project? I'm looking for a good cross-platform multimedia engines, too. I'm found gotod

Nim's status discussion

2018-02-21 Thread r3d9u11
Hey, Nimers! I'm a novice in world of Nim, my generic/work languages is C/C++/C#, sometimes JS/Haxe as a hobbie. But also I was interested in Nim. Wich status of Nim? * Does standard library is stable for usage in the enterprise? * As I understand, Nim allows to use it's **GC** to manage

nimue4: bidings to Unreal Engine 4 discussion.

2018-02-21 Thread r3d9u11
Hey all! Did somebody used [nimue4](https://github.com/pragmagic/nimue4) (bindings to Unreal Engine 4 for Nim) for the real projects? How well this is realized, is it worth starting a gaming project on this (mobile + html5)? Thanks!