Re: Iterating over anonymous enums?

2019-07-27 Thread mratsim
You can use a {.experimental: "ForLoopMacros".} to rewrite the for loop. See for example the impelmentation of Python enumerate import macros {.experimental: "forLoopMacros".} macro enumerate*(x: ForLoopStmt): untyped = expectKind x, nnkForStmt # we strip

Re: Echo a NimNode

2019-07-27 Thread solo989
try echo treeRepr nimNode Run

Echo a NimNode

2019-07-27 Thread vitreo12
Hello everyone, I would need to debug the NimNodes returned from getImpl Run calls, and I was looking for a function that would print out a NimNode tree structure given a NimNode, not a block of nim code. I looked at dumpTree Run , but

Re: Data loss with async sockets

2019-07-27 Thread Araq
Well ... I'm sure it doesn't help much, but I agree with both @dom96 and @cheatfate. Since I'm still on holidays, please expect a longer answer here later.

Re: Iterating over anonymous enums?

2019-07-27 Thread jasper
`for c in Color.low..Color.high` produces enums, its what the `for c in Color` iterator does. Anyway, its pretty easy. The enum values are scoped. With some more state keeping and macro sugar you can even define and use anon enums as function params. import macros

Re: Iterating over anonymous enums?

2019-07-27 Thread Stefan_Salewski
The above example seems to be exactly the desired solution, thank you all for your proposals.

Re: Data loss with async sockets

2019-07-27 Thread cheatfate
Issues from this list if async issue which you still ignoring, but still important: 1. [https://github.com/nim-lang/Nim/issues/3590](https://github.com/nim-lang/Nim/issues/3590) "asyncnet.recv hangs when the socket is closed" 2.

Re: Data loss with async sockets

2019-07-27 Thread cheatfate
Also i want to remember about very important part of asyncdispatch - selectors.nim, and your work with this part. Do you remember

Re: How to Maintain a Nim Chinese Community

2019-07-27 Thread jiyinyiyong
No using QQ for long. Maybe try WeChat if you got a WeChat group for Nim.

Assign string to seq[uint8]

2019-07-27 Thread Stefan_Salewski
I would like that strings can be assigned directly to seq[uint8], as a cstring generally is a valid uint8 sequence. Something like var s: seq[uint8] s = seq[uint8]("Text data for proc with uint8 based parameters".cstring) Run The actual fact is, that we have some

Re: Assign string to seq[uint8]

2019-07-27 Thread SolitudeSF
`converter toSeqUint8(s: string): seq[uint8] = cast[seq[uint8]](s) let s: seq[uint8] = "test" doAssert s == @[116'u8, 101, 115, 116] ` Run

Re: Assign string to seq[uint8]

2019-07-27 Thread mratsim
>From a type-safety point of view, I think such a conversion should not be the >default, while `string`, `seq[byte]`, `seq[uint8]` and `Taintedstring` are all >equivalent at a low-level, they should represented completely different >semantics. Implicit conversion should be left at the library

Re: Assign string to seq[uint8]

2019-07-27 Thread Stefan_Salewski
OK, so a cast does indeed work, and lenientops may also support it (will visit that module soon) but a plain safe type conversion does not work? Strange -- is that just because no one had the time to implement the type conversion yet? A cast is too unsafe of course, no one can guarantee that

Re: How to Maintain a Nim Chinese Community

2019-07-27 Thread kidandcat
Nim is not backed by a large company, the devs efford is already very high. Just go ahead and collaborate. I've translated many open source websites to Spanish. I'm sure if any of you provide the Chinese translation of nim-lang.org the team will be very happy to public it.

Re: What do you think about the programming language NIM?

2019-07-27 Thread kidandcat
Of course it completely depends on the IT field you work on. I have experience working with mastodon apps in big teams with teams of more than 20 developers. In that kind of scenario the performance is the smallest problem you will have to handle. And of course the performance is very

Re: How to Maintain a Nim Chinese Community

2019-07-27 Thread Stefan_Salewski
> I've translated many open source websites to Spanish. How do you manage to keep them up to date? I have not even managed that for my own homepage -- started that page 20 years ago in english/german, and keep both in sync in the first years. But later I updated only the english content, and

Re: Assign string to seq[uint8]

2019-07-27 Thread mratsim
what I meant by lenientops is that it's better to have strong default in system.nim and that extra libraries like lenientops would be better to introduce unsafe auto-conversion between types. To be clear, lenientops only does conversions for numerical operators at the moment. The safe

Iterating over anonymous enums?

2019-07-27 Thread Stefan_Salewski
Sometimes I have loops like for state in 0 .. 1: if state == 0: Run It would be better iterating over enums, like type Color = enum red, green, blue for c in Color: echo c if c == red:

Re: Iterating over anonymous enums?

2019-07-27 Thread Stefan_Salewski
No, will not try that, as that is iterating over integers, and I would have to define the enums in a type section before. Not really my intension.

Re: Iterating over anonymous enums?

2019-07-27 Thread Ward
try c in Color.low..Color.high: echo c Run