Re: Unicode display

2018-05-23 Thread Hlaaftana
There's a utility method in the json module you can [directly 
use](https://nim-lang.org/docs/json.html#escapeJson,string,string).


import os, json
echo escapeJson(paramstr(1))


[The 
implementation](https://github.com/nim-lang/Nim/blob/master/lib/pure/json.nim#L1026)
 is quite simple and if you want special string quoting syntax you could 
implement it differently yourself with little effort.


Re: Unicode display

2018-05-23 Thread Krux02
strings in Nim don't have any special Unicode support. Unicode is just designed 
in a way that it is compatible with ASCII. When a utf8 string contains a 
non-ASCII character, it will create it as a multibyte character. But all 
individual bytes of this multibyte character will have a value above 127 so 
that no single byte can be interpreted falsely as a 7 bit ASCII character. As 
long as Nim doesn't need to actually process the content of the string it can 
simply forward the string to the terminal. The terminal then knows what to do, 
as long as your source file and the Terminal are both encoded as utf8.


Expose `awaited` flag in `FlowVarBase` just like `isReady()`

2018-05-23 Thread allochi
Hi,

I would like to suggest to have a method that returns the value of `awaited` 
flag in `FlowVarBase` just like `isReady()`.

Usually when multiple threads return `FlowVar` values, you can check when their 
values are ready using `isReady()` method, and then do something with the value 
returned using `^` operator (which calls `await()`), you can call this operator 
multiple times without knowing if you already called and used the returned 
value, unless you keep a track somewhere, like an auxiliary array, which is an 
extra code that blot the code and logic flow.

The other scenario would be waiting for multiple thread to finish with 
different return types, again having an auxiliary array to keep track of the 
process is not ideal for the clarity and flow of the code and logic.

If `awaited` is exposed through a method like `isRead()` or `isReturned()` 
means the code can keep track of return values that has been read from within 
FlowVar itself.

Basically we can then have:


var tasks: seq[FlowVar[int]] = @[]

# ... spawn some tasks

while true:
  for task in tasks:
if task.isReady() and not task.isRead():
  echo ^task
  # ... Break if all task.isRead() are true



I hope this makes sense and that I'm not confused about how threadpool works.

Other than that I'm enjoying working on a Nim project again!!!


Re: Please delete my forum account

2018-05-23 Thread ncx
Okay


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: cannot countProcessor in compile time

2018-05-23 Thread dataman
The best way for this feature is to add a new code to the VM. No chances.