Caller line numbers in templates?

2019-02-07 Thread zielmicha
Still haven't found a solution :( .

(looking for it today again, I've only found my old post)


Bug (?) with templates

2018-01-02 Thread zielmicha
This doesn't work: 


template bar() {.dirty.} =
  echo a


template foo() =
  let a = 5
  bar()

foo()


but this does: 


template bar() {.dirty.} =
  echo a


template foo() {.dirty.}  =
  let a = 5
  bar()

foo()


Is this a bug or I don't understand something about templates? 


Re: collections.nim and reactor.nim v0.3.0 released

2017-04-21 Thread zielmicha
I've just released version 0.4.0 of reactor.nim. It contains substantial 
performance improvements and multicore support (i.e. running multiple threads, 
each with its own event loop, possibly communicating).

There is also very very basic support for MTCP/DPKD userspace networking stack, 
for the cases when kernel TCP support is too slow.

0.5.0 will hopefully use the same Future implementation as stdlib (and maybe 
more).


Re: collections.nim and reactor.nim v0.3.0 released

2017-01-11 Thread zielmicha
I started this project with the following assumptions:

  * use libuv (or something similar) to avoid having to support code for every 
platform (this is really important, I don't want to test everything on >3 
platforms even when making small changes)
  * have API as clean as possible.



I don't thing you and Araq would accept rewriting asyncdispatch to use libuv 
and dramatically changing the API of asyncdispatch/asyncnet. Future and 
Input/Output objects are incompatible with stdlib for good reasons - for 
example, using my abstractions, it's possible to:

  * efficiently implement `readLine` without using internals of socket object
  * do async calls without allocations in a more elegant way than `FutureVar`
  * write SSL/TLS support module without inlining it into module that supports 
sockets (!)



To avoid the situation you described, I'm planning to write drop-in 
asyncdispatch/asyncnet replacement that will use reactor.nim loop. In the long 
run, I think the way to go is to define portable API for event loops (in a same 
way [Python 
does](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio-event-loop)).
 This way, different async libraries could be bridged together.


Re: collections.nim and reactor.nim v0.3.0 released

2017-01-11 Thread zielmicha
There is no direct compatiblity with standard async, but porting code from 
stdlib should be easy (many features have similar syntax).

Currently there is support for running tasks in a thread pool, but the tasks 
can't use event loop at all 
([https://networkos.net/nim/reactor.nim/doc/api/reactor/threading.html)](https://networkos.net/nim/reactor.nim/doc/api/reactor/threading.html\)).
 I'm planning for quite a long time to add multithreaded HTTP server to 
reactor.nim, libuv already supports passing sockets between threads. 


collections.nim and reactor.nim v0.3.0 released

2017-01-10 Thread zielmicha
I have just released version 0.3.0 of collections.nim and reactor.nim libraries!

reactor.nim is an alternative asynchronous networking engine for Nim based on 
libuv. The main addition in this release is much improved documentation 
([Github](https://github.com/zielmicha/reactor.nim), 
[tutorial](https://networkos.net/nim/reactor.nim/doc/tutorial.html), [API 
docs](https://networkos.net/nim/reactor.nim/doc/)).

collections.nim is a collection of several mostly independent module 
([Github](https://github.com/zielmicha/collections.nim), [API 
docs](https://networkos.net/nim/collections.nim/doc/)). Notably, is has 
[weakref](https://networkos.net/nim/collections.nim/doc/api/collections/weakref.html)
 module that implements weak references and 
[pprint](https://networkos.net/nim/collections.nim/doc/api/collections/pprint.html)
 which is a more readable alternative to built-in repr.


Re: Stream data type

2016-09-23 Thread zielmicha
You might want to look at 
[https://github.com/zielmicha/reactor.nim/blob/master/reactor/async/stream.nim](https://github.com/zielmicha/reactor.nim/blob/master/reactor/async/stream.nim)
 from my reactor.nim - it implements asynchronous streams. The implementation 
is a bit involved (mostly for performance and to properly implement stream 
closing), but in it's core it just invokes receive callbacks when data is 
written to it. You could implement something really similar on top of async API 
from stdlib.


Re: Awesome language

2016-09-13 Thread zielmicha
There is [https://gitter.im/nim-lang/Nim](https://gitter.im/nim-lang/Nim) (it 
is bridged with IRC channel #nim-lang on freenode).


Re: Windows built version of Nim producing casting errors

2016-09-08 Thread zielmicha
As I've replied on 
[https://github.com/zielmicha/reactor.nim/issues/3](https://github.com/zielmicha/reactor.nim/issues/3),
 reactor.nim is not supported on Windows yet. I'm cleaning reactor.nim up a bit 
today, maybe I'll add Windows support soon.


Re: reactor.nim 0.0.1 - an asynchronous networking library - is released

2016-08-29 Thread zielmicha
Use createTcpServer from 
[https://networkos.net/nim/reactor.nim/doc/api/reactor/tcp.html](https://networkos.net/nim/reactor.nim/doc/api/reactor/tcp.html)
 or newUdpSocket with bindAddress from 
[https://networkos.net/nim/reactor.nim/doc/api/reactor/udp.html](https://networkos.net/nim/reactor.nim/doc/api/reactor/udp.html)
 . There is still no support for HTTP servers.


Re: Partial casing is foo_bar

2016-07-19 Thread zielmicha
I agree it causes problems, but having identifiers in existing libraries with 
same partial-cased names is very rare. (It might be a good idea to allow _XX 
and XX_)

Making partial-casing a compiler flag is a worse idea than disabling it (most 
existing code anyway won't compile with this flag).


Re: zipping strings

2016-07-12 Thread zielmicha
If you need to iterate over Unicode characters, use runes iterator in unicode 
module 
([http://nim-lang.org/docs/unicode.html)](http://forum.nim-lang.org///nim-lang.org/docs/unicode.html\)).


Re: Bug in `.`?

2016-07-11 Thread zielmicha
Unfortunately it does not: 


type
  B = object
j: int
  
  A = object
myB: B

converter toB(a: A): B =
  return a.myB

var a: A
echo a.j # f.nim(13, 7) Error: undeclared field: 'j'


I think I will settle on autogenerating accessor procs.


Re: Love nim but at the same time starting to hate it...

2016-07-07 Thread zielmicha
The documentation is not ideal, but in this case you haven't found the "real 
documentation" of split on the same page: 
[http://nim-lang.org/docs/strutils.html#split.i,string,set[char],int](http://forum.nim-lang.org///nim-lang.org/docs/strutils.html#split.i,string,set\[char\],int)

The discoverability could certainly be improved, but [Ctrl-F + enter several 
times] finds the right proc in most cases. (I think the procs should be grouped 
by argument types in the index)


Re: Bug in `.`?

2016-07-07 Thread zielmicha
I'm using it to create a type that should behave like pointer/ref. pointer/ref 
types get automatic dereference automatically - it there a better way to get 
this behaviour? I could probably autogenerate accessor procs (fieldname and 
fieldname=) for all fields, but I'm not sure if it is cleaner.


Re: Bug in `.`?

2016-07-07 Thread zielmicha
I don't need to use the same name for local variable and field, it has just 
happened by accident. This behaviour seems to be a compiler bug, I've created 
[https://github.com/nim-lang/Nim/issues/4461](https://github.com/nim-lang/Nim/issues/4461)
 for it


Bug in `.`?

2016-07-06 Thread zielmicha
This code works if let field1 is commented out, but with it it compiles returns 
test_deref.nim(19, 9) Error: type mismatch: got (untyped). It seems that the 
macro doesn't even run. Is this a bug?


import macros

type
  B = object of RootObj
field1: int

type
  A[T] = object
inner: T

macro `.`*(obj: A, v): untyped =
  echo "running macro"
  newDotExpr(newDotExpr(obj, newIdentNode("inner")), newIdentNode(v.strVal))

proc t1*() =
  var f: A[B]
  let field1 = 777 # <- if you comment this out, the code works
  echo f.field1

t1()



Re: Newest member on this forum

2016-06-28 Thread zielmicha
It is possible to get notifications about posts on the forum. I'm not sure how 
I have signed up, but I get mails about all posts.


Re: How to access segment (similar Go slice) of seq[byte]?

2016-06-26 Thread zielmicha
On 2016-06-26 18:50:53, zielmicha said: 

@andrea - I'm using reactor.nim in an internal project and it general it works. 
Most likely I'll devote more time to it this month.