<< 10-08-2013 >>

01:11:31*q66 quit (Quit: Leaving)
01:24:10*BitPuffin quit (Read error: Connection reset by peer)
02:05:47*Associat0r quit (Read error: Connection reset by peer)
02:06:57*Associat0r joined #nimrod
02:06:57*Associat0r quit (Changing host)
02:06:57*Associat0r joined #nimrod
05:06:06*OrionPK quit (Read error: Connection reset by peer)
05:16:04*xilo quit (Ping timeout: 264 seconds)
06:53:04zaharyhi dom96, sorry for not being around yesterday
06:55:01zaharycan you summarise what kind of problems you are having with the async design?
09:39:30*BitPuffin joined #nimrod
09:48:33*alexandrus joined #nimrod
09:50:06*q66 joined #nimrod
09:58:20*alexandrus quit ()
10:19:16dom96hey zahary, you still around?
10:29:56zaharyyep
10:32:27dom96ok, well the problem is storing the return value in a Promise object
10:33:02dom96I can't use a generic because I need to store a list of these promises
10:33:47dom96I can use a PObject but then I can't store the original type as a separate field so I have to hack around to get it to work
10:34:40*troydm quit (Ping timeout: 264 seconds)
10:38:33zaharyyou need to do what people usually call type erasure in C++. you have a common promise base type that a "virtual" function handling the completion event implemented in the PRomise[T] instances
10:38:33zaharyhttp://thbecker.net/free_software_utilities/type_erasure_for_cpp_iterators/start_page.html
10:38:57zaharyif you send me some work in progress gist, I
10:39:16zahary.. I'll probably be able to help you get started
10:39:39zahary* with a virtual function *
10:40:23dom96https://gist.github.com/dom96/65cecdb76deb08a455c9
10:40:35dom96That's my PPromise and my Dispatcher object
10:40:52dom96the 'requests' field in the second object is only revelant
10:40:55dom96*relevant
10:41:04dom96and yes I should rename it to 'promises'
10:42:21dom96The way this works is that I generate a P<procNameHere>RetObject type definition
10:42:43dom96So when doing 'await sendAsync(sock, "blah")'
10:43:10dom96It becomes PsendAsyncRetObject(promise.value).returnVal
10:44:09dom96of course when you have a Promise object defined earlier there is no way to know the name of the proc
10:45:45zaharythe dispatcher here represents the event loop?
10:45:50dom96yes
10:46:03zaharyand what is pdelegate is?
10:46:25dom96that doesn't matter
10:46:40dom96That's how the old async is implemented
10:48:49BitPuffindom96: how's async going?
10:49:19dom96ok-ish. Having some problems with return values though.
10:51:04BitPuffinwhat kind of problems?
10:51:17dom96read what I just wrote :P
10:52:58zaharyok, the first step would be to write some regular procs based on the async sockets api that return promises. shall we use my "download" as an example?
10:53:16dom96I already have
10:53:38dom96I already changed the macro to transform it properly.
10:53:50zaharyis it online too?
10:53:55dom96no
10:57:33BitPuffindom96: you mean above?
10:57:38dom96yes
10:59:07zaharycan you upload the download proc example? your TPromise definition suspiciously lacks notification mechanisms for when it's resolved and rejected and I'd like to see how the code works
11:00:11dom96well I haven't gotten as far as a download proc
11:01:11zaharyyou probably have something like async connect, async read, etc? any of them would do
11:02:33dom96https://gist.github.com/dom96/0c73a80b0dba2453956a
11:02:46dom96That's accept
11:02:52dom96after macro expansion and before
11:14:29zaharyhttps://gist.github.com/dom96/0c73a80b0dba2453956a
11:15:04zaharyI left you some comments. my example is not particularly good, because accept is not one-off operation
11:15:59zaharythere are two general approaches to async network APIs - the most widely used one is when each operation has it's own completion callback
11:16:29zaharysocket.async_read(number_of_bytes, completion_handler_proc)
11:16:46dom96but then that's just a callback API?
11:17:38dom96Why are iterators a wrong idea?
11:17:50zaharythis is how boost.asio (C++), node.js (libuv), etc are written. this is very easily married to promises, because the callback just resolves the promise
11:18:18dom96You yield a promise and the dispatcher resurrects your iterator once that promise has been completed
11:18:53zaharythe other kind of APIs (like python's async socket and nimrod's) will resolve the promise in similar way, but the ownership of the handleXX fields in the socket object is a bit more messy
11:20:05zaharyyes, the benefits of the promises come with the iterator style procs - but these procs need a basic API to work with written in the classic style - that's what I meant
11:20:51dom96well I don't get how this solves my problem
11:21:19zaharywell, what is the next problem?
11:21:48dom96that's really the only problem currently
11:23:49zaharyso what is it? how to advance the iterator?
11:24:16dom96Didn't I just describe the problem?
11:24:21dom96the return values
11:24:27*BitPuffin quit (Ping timeout: 260 seconds)
11:25:05zaharynotice how in my example, I'm supplying the return value when I resolve the promise
11:25:49zaharysince the promise is strongly typed, the return value can be stored as a field or just immediately dispatched to any handlers subscribed to the promise
11:26:36zaharyalso, notice how callers of asyncAccept are working with TPromise[Connection], so the simple await templete will read the proper TConnection value
11:28:03dom96well you still need iterators don't you?
11:28:52zaharyas I said, iterators is what the user of library write most of the time (that is .async. procs)
11:29:06*EXetoC joined #nimrod
11:29:14zaharyfor example in their code there will be
11:29:15zaharyvar connection = await acceptAsync(socket)
11:29:21dom96yes, and won't we arrive at exactly the same problem?
11:29:47dom96the iterators will yield a promise right?
11:29:57zaharyyes, base promise type
11:30:10dom96base promise type?
11:30:34zaharyyou need to do what people usually call type erasure in C++. you have a common promise base type that a "virtual" function handling the completion event implemented in the PRomise[T] instances
11:30:34zaharyhttp://thbecker.net/free_software_utilities/type_erasure_for_cpp_iterators/start_page.html
11:31:18dom96yes, I have no idea what that means or how to do that in Nimrod
11:36:21zaharyhttps://gist.github.com/dom96/0c73a80b0dba2453956a
11:47:26zaharydid the code compile in your head?
11:48:21dom96no, I don't really get it
11:48:43zaharyany part in particular?
11:49:18dom96Any reason why we can't go with my solution?
11:49:36dom96is it impossible to fix the 'return value problem' with the way I implemented this?
11:51:24zaharywell, what is your solution? the way I see it, the missing part of you current approach is the step where you resolve the promises (resolving means that the async operation completes)
11:53:38dom96in my iterator, when I yield the 'readPromise' I am asking the dispatcher to bring back execution into the iterator when the socket becomes readable.
11:54:00dom96So when line 16 begins execution, `socket` is readable.
11:54:52zaharyaha, this is encoded in the reqKind field
11:55:01dom96yes
11:55:17dom96There are two possible 'requests', either a read or a write.
11:58:14zaharywell, the promises are really a task agnostic mechanism. they are not just for socket operations and the user can compose them or create his set of "async tasks"
11:58:49zaharyso it's not a good idea to tie them to the sockets module and encode the type of the operation as a closed enum
11:59:27dom96hrm, yes.
12:01:00zaharywhich parts of my example code seem complicated btw? maybe I can explain them some more
12:01:23dom96I think I understand it a bit better now. Hrm.
12:02:37dom96still not 100% sure how the event loop will work with the iterators.
12:02:44dom96What will the iterators do exactly?
12:02:51dom96yield a PromiseBase?
12:04:03zaharyyes
12:04:42zaharywhen you call an async proc for the first time in non-await context - it starts the iterator with stepIterator()
12:05:26dom96but how will that work?
12:05:39dom96say I have: var a = accept(sock)
12:05:48dom96will the macro transform it somehow?
12:06:27zaharywhat is accept here? async proc?
12:06:39dom96yes
12:06:44zaharythen a is a promise
12:07:04zaharythe code returns immediately and execution continues
12:07:55dom96what will 'accept' do then?
12:08:16dom96where will the iterator be stored?
12:08:29dom96(the state of the iterator)
12:08:40zaharyyou can scratch my previous line about calling asyncProc for the first time
12:09:06zaharythe iterator is actually advanced in dispatcher.run()
12:09:35dom96how will the dispatcher know about the iterator?
12:11:09zaharythe stepIterator function actually represents the yield statement in the iterator
12:12:39*dom96 is really confused
12:12:57zaharyso the dispatcher only knows about sockets (and other events implemented in system libraries such as libuv); the socket resolves the promise; the onComplete handler of the promise advances the iterator
12:14:15dom96well I know you gave me an example of acceptAsync
12:14:32dom96but I don't get it
12:14:45dom96well first of all, why are you calling .listen?
12:14:53zaharyI updates my example to call the former stepIterator proc "wrapYield"
12:14:53zaharyhttps://gist.github.com/dom96/0c73a80b0dba2453956a
12:15:43dom96where is the iterator stored then?
12:15:47zaharyyes, my example for accept is a bit lame; it would be much easier to understand with some other operation like asyncRead
12:16:06dom96show me asyncread then
12:16:17zaharyI request asyncRead; the async socket fire some callback when the operation is complete - this callback resolves the promise
12:17:48dom96Ok I understand that.
12:18:00zaharythe iterator is created at the entry of the .async. proc
12:18:03dom96So say I have an async proc of my own which wants to read from a socket
12:18:29dom96I write: var data = readAsync(sock)
12:18:56dom96well, I suppose 'dataPromise' is a more appropriate name for that var
12:18:57dom96but w/e
12:18:59zaharystored as a local variable and referenced from the onComplete callback in wrapYield
12:19:11zaharythus, it also ends up in a closure
12:19:19dom96hrm
12:20:04dom96not sure I get that
12:20:12dom96lets just go with my example, k?
12:20:41dom96proc myRead(sock: PAsyncSocket) {.async.} =
12:20:48*BitPuffin joined #nimrod
12:20:50dom96 var dataPromise = readAsync(sock)
12:21:14dom96 let data = await dataPromise
12:21:30dom96How does that look after macro expansion?
12:36:22zaharyhmm, it's a bit more complicated indeed
12:36:23zaharyhttps://gist.github.com/dom96/0c73a80b0dba2453956a
12:36:48zaharyyou also need a special promise for the whole iterator
12:41:45*BitPuffin quit (Read error: Operation timed out)
12:43:06dom96you're calling onComplete on an iter?
12:43:49zaharywell, it should be an object wrapping the iterator and the promise we created
12:43:57zahary… at the start of the async proc
12:44:25zaharyis it possible to instantiate an iterator without starting it now?
12:44:54dom96you need to keep the state of the iterator and the arg you pass to it somewhere
12:45:02dom96the arg must be the same on each call I think
12:45:25dom96well I dunno
12:45:28dom96This is really confusing
12:45:51dom96and i've rewritten it once already
12:50:29zaharyalright, I was able to simplify it significantly
12:50:59zaharythe iterator should get the .async. result promise and returns in the iterator should resolve that promise
12:51:07zaharyhttps://gist.github.com/dom96/0c73a80b0dba2453956a
12:53:46dom96wait why is onCompleted a seq?
12:55:15zaharyit should be a signal (aka event)
12:55:27zaharyto allow for multiple subscribers
12:56:54zaharythis is quite nice feature for adding additional cross cutting logic to the async operations: for example, every async network operation, should change the mouse cursor to hourglass, etc
12:59:10zaharyhttp://msdn.microsoft.com/en-us/library/aa645739(v=vs.71).aspx
12:59:10zaharyhttp://en.wikipedia.org/wiki/Signals_and_slots
13:05:29dom96argh
13:05:59dom96i have to leave for a while.
13:06:22dom96but yeah, i'm still not entirely sure how this is meant to all come together.
13:06:27dom96Perhaps you should just implement it zahary
13:06:38zaharyyou can start without signals; just make onComplete a regular proc pointer for a single subscriber
13:07:18zaharybut otherwise, go ahead and read my latest example code- it's getting quite simple and I think the code is complete now
13:07:39dom96right. bbl
13:45:22dom96back
14:28:08*xilo joined #nimrod
14:44:45*BitPuffin joined #nimrod
14:48:53*OrionPK joined #nimrod
15:06:42*Mat2 joined #nimrod
15:06:44Mat2hello
15:10:07OrionPKyo
15:10:18Mat2ho OnionPK
15:13:20dom96hello
15:13:33Mat2hi dom96
15:13:42dom96hi Mat2
15:19:22OrionPKfunny
15:19:50OrionPKyou call me Onion, even though it's Orion right now ;P
15:20:19Mat2*g*, sorry - typo
15:20:48OrionPKlol, no dont worry about it, people call me onion all the time in another community
15:21:04OrionPKthats why i think its funny, onion is basically my nickname
16:02:33BitPuffincan nimrod write any function call of two parameters inline?
16:02:52BitPuffinlike a `toThePowerOf` b
16:03:06BitPuffinthat's just haskell style
16:03:16BitPuffinI was just wondering if nimrod has anything equivalent
16:05:00dom96I think someone asked this before.
16:05:05dom96in fact was it not you? :P
16:38:19AraqBitPuffin: no, use a.toThePowerOf(b) instead
16:38:25Araqor a real operator
16:38:31BitPuffindom96: perhaps :P
16:38:45BitPuffinAraq: that's what I'm currently doing, real operator?
16:39:13Araqa ^ b
16:39:22BitPuffinoh
16:39:28BitPuffinI was thinking real, the type
16:39:29BitPuffinlol
16:39:50EXetoCtype class? :>
16:53:16*BitPuffin quit (Ping timeout: 264 seconds)
17:06:52*shevy joined #nimrod
17:07:36dom96hey shevy
17:07:44shevyheya
17:07:54Mat2hi shevy
17:07:57dom96where have ya been
17:08:42shevyhmm, struggled with computer related problems for a while, also had no electricity in my flat for like 10 days and so on and so forth
17:08:58shevythe only proud thing I did was that I finally managed to switch from ruby 1.8.x to ruby 1.9.x :P
17:09:38shevyI am on gtk3 now too though
17:10:09Mat2what are your experiences with GTK3 ?
17:10:46shevyI am not sure yet, I am just slowly getting into things with it again with ruby-gtk ... but it looks nicer than gtk2
17:13:09shevyhas aptana gotten better?
17:13:11*OrionPKM joined #nimrod
17:13:15dom96gtk3 apps still look shit on my desktop.
17:14:44Mat2I'm curious because some open-source projects which used GTK2 before (beside Gnome of course) seem switching to Qt
17:16:08shevyyeah
17:16:23shevythe gtk guys need to work harder
17:17:50Mat2I think there need some seperation from the Gnome project - then more developers will probably interested in development
17:18:22shevydoes not qt require one to have a project in C++?
17:18:42Mat2yes
17:49:48*OrionPKM quit (Ping timeout: 276 seconds)
17:51:40*OrionPKM joined #nimrod
18:04:22EXetoCdom96: with the default theme I assume
18:05:17dom96Adwaita-X-dark
18:07:59EXetoCdoes it look different elsewhere?
18:09:18EXetoCor is it ugly because of gtk3 in general?
18:12:12*OrionPKM quit (Remote host closed the connection)
18:12:51dom96maybe the theme just doesn't support it
18:13:28dom96what is the name of the default theme?
18:14:29EXetoCI don't know
18:15:25EXetoCwanna try some game today?
18:16:01EXetoCbtw, do you know what kind of game you want to make?
18:16:23dom96I'm working on a Nimrod benchmark currently so maybe a bit later.
18:17:37dom96did I say I want to make a game?
18:19:23EXetoCyou were thinking about it at least
18:19:43dom96well I wanted to try creating a minecraft clone to learn some stuff about opengl
18:20:58EXetoCok
18:21:10dom96why do you ask?
18:22:25EXetoCjust out of curiosity
18:39:25*jbe_ joined #nimrod
18:39:51jbe_hello everyone
18:40:02dom96hi jbe_
18:40:10Mat2hi jbe
18:40:56jbe_i just noticed the generics sample code from the manual won't compile.. is it a bug?
18:43:23*Associat0r quit (Quit: Associat0r)
18:44:33dom96hrm, perhaps.
18:44:34Araqjbe_: which example?
18:44:46jbe_lets see..
18:44:52dom96The binary tree one?
18:45:06jbe_yep!
18:45:23dom96Looks like generics in iterators are broken.
18:45:37Araq # inorder traversal of a binary tree
18:45:39Araq # recursive iterators are not yet implemented, so this does not work in
18:45:40Araq # the current compiler!
18:45:43Araqsays the code
18:45:53dom96hah
18:45:57jbe_ah whoops sorry
18:45:59*dom96 didn't even read the comments
18:46:30dom96Might be a good idea to add a "Note" underneath that example.
18:46:35Araqwell
18:46:46Araqwe should implement an 'inorder' that does work
18:47:01Araqas iterators won't be getting recursion any time soon
18:47:07Mat2hi Araq, what's the state of your VM by the way ?
18:47:31AraqMat2: it runs some quite complex code
18:48:08AraqI'm now integrating it so that the it can replace the old VM
18:51:16Mat2well, I will take a look after integrating mine in retro (curious about some benchmark results of both)
18:52:22Araqwell I haven't even started on .interpreterLoop and the 'c.code' expression needs to be hoisted out of the loop
18:53:09Araqalso my design is quite constrained by the AST operations that need to be supported efficiently
18:53:28Araq(it is after all used for macro evaluation in the first place)
18:56:26Mat2ok, that's then the first example for misusing Nimrod vm-engines for testing :D
18:57:04Mat2^purposes
18:57:51*BitPuffin joined #nimrod
19:09:58*BitPuffin quit (Read error: Connection reset by peer)
20:46:40Araqjbe_: are you the guy who ported quite some benchmarks to nimrod?
20:57:29dom96that's jmb, could still be the same person though heh
20:59:05Araqoh ... lol
20:59:34Araqwell the names are similar :P
21:02:04jbe_Araq & dom96: nope
21:02:38jbe_and jdp is here too. confusing..
21:02:52dom96hah, true.
21:02:57*dom96 didn't even notice
21:24:59*Associat0r joined #nimrod
21:24:59*Associat0r quit (Changing host)
21:25:00*Associat0r joined #nimrod
21:59:47*BitPuffin joined #nimrod
22:00:45*jbe_ quit (Quit: Leaving)
22:01:25Mat2ciao
22:01:34*Mat2 quit (Quit: Verlassend)
22:04:40*BitPuffin quit (Ping timeout: 264 seconds)
22:08:23*Associ8or joined #nimrod
22:08:23*Associ8or quit (Changing host)
22:08:24*Associ8or joined #nimrod
22:10:14*Associat0r quit (Ping timeout: 240 seconds)
22:29:15*Associ8or quit (Quit: Associ8or)
22:30:29*Associat0r joined #nimrod
22:30:29*Associat0r quit (Changing host)
22:30:29*Associat0r joined #nimrod
22:30:38*Associat0r quit (Client Quit)
22:40:51*Trix[a]r_za is now known as Trixar_za
22:41:23*Associat0r joined #nimrod
22:41:23*Associat0r quit (Changing host)
22:41:23*Associat0r joined #nimrod
23:03:28*EXetoC quit (Ping timeout: 264 seconds)