Nice It would be cool to see Arduino's firmware on Nim to get full-stacked
application on Nim
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
Stefan_Salewsk, thanks for detailed answer and thanks for useful link!
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?
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).
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.
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.
cool, thanks for another solution!
many thanks!
yes, it works without macro. probably, your code works because strutils is a
global module.
Thanks for hint, but idea that module name isn't hardcoded and contained inside
of string.
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
many thanks, it works! (I'll try to search and read about static types)
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
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")
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) = #
Thanks for clarification regarding Nim! (but, as I know, "reflection" is a
conception relating only for runtime. everything else is something different)
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?
Hi. Is it possible in Nim to call procedure with parameters who name and
parameters will be known at runtime (and get result value)?
thanks!
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
Thanks!
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
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:
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 ).
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
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()
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,
...
)
Many thanks for this discussion! Now everything became clear
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,
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
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;
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!
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")
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
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?
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:
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
thanks!
Hi. I have warning: "message: 'capitalize is deprecated [Deprecated]'". What
function I can use instead of it?
Many thanks!
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.)
Thanks! But it will work only for text, what about binary files?
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 =
I think I should use NimScript
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?
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.
mratsim, thanks! (but how arraymancer-vision it's something lika a gnuplot, I
think)
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
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
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?
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.} =
Thanks for answer!
Thanks!
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:
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 ;)).
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
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),
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
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
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!
61 matches
Mail list logo