<<03-06-2012>>

05:38:01*llm joined #nimrod
05:43:41*llm quit (Quit: ChatZilla 0.9.88.2 [Firefox 12.0/20120420145725])
08:13:31zaharyAraq, unittest is using scope injection is some of the templates
08:13:51Araqzahary: yeah I noticed too
08:14:07AraqI was too focussed on the 'var/let' keywords :D
08:14:22zaharyI suggest we also have a pragma that keeps the current behavior. e.g. {. verbatim .}
08:15:35Araqwhy? 'template t() {.inject.}' # t is injected, not t's body contains all injected symbols
08:15:53Araqis only a little more verbose
08:17:14zaharyhm, yeah, you need 2 pragmas to support "contains all injected symbols" - the question is will this be useful
08:20:34Araqwith 'inject' per symbol you gain full control already; 'verbatim' is a bit nicer for keeping backwards compatibility
08:22:53Araqwhich I heard nobody cares about for now ;-)
08:23:33zaharymy reasoning was that after examining all my templates I couldn't quite see the one side prevailing
08:24:02zaharybut I don't mind too much, we could try just inject and see how it goes
08:26:03Araqin fact, I think it's based mostly on symbol kind
08:26:23Araqa 'var/let' is rarely 'inject', but a local template/proc is
08:26:58zaharycould be
08:27:40Araqwe could also go the other way and have a 'private' pragma for 'gensym'; that would keep compatibility
08:27:46zaharyinject, injectAll, genSym (reverts injectAll)
08:27:57zaharythat's what I proposed originally
08:30:13Araqit's nicer if gensym is the default though; I like scope injection to be explicit
08:32:05Araqthe 'eval' template is broken as it needs a 'block' for the 'payload'
08:32:17Araqno problem with gensym as default
08:33:10Araqthough we could also make all declarations in a block gensym'ed
08:33:21Araqand eliminate the block in a template ...
08:33:40Araqso a 'block' in a template subtly changes its semantics ...
08:34:17Araqwhich is however exactly what the original designer (==me) had in mind :D
08:34:34zaharywell, yes, gensym as default is my suggestion too. only if you used injectAll, then one must use explicit gensym. or if we decided that procs and templates are injected by default, then gensym could be used for them too
08:36:07Araqin fact the "block changes its meaning in a template" leads to natural intuitive code IMO
08:36:14zaharyone little problem with block is that it affects variables lifetimes too - so the user can have this in mind and be surprised by the alternative handling
08:36:35Araqyeah it's "intuitive" but dirty ...
08:40:29Araqyou can use 'if true:' instead of 'block' in a template to get the lifetime stuff
08:41:05Araqbut these are exactly the thing that require long winded comments in the resulting code
09:03:56Araqok, I'll implement 'inject', 'gensym' and 'injectAll'
09:04:35Araqmacros don't have this problem as soon as 'gensym' is an accessible magic, right?
09:05:27Araqor did I miss something? the imperative AST construction is not ambiguous, or is it?
09:05:47Araqhm
09:07:49AraqI guess the compiler handles nkIdent vs nkSym not consequent enough and re-evaluates nkSym too; that seems bad for macros
09:17:25dom96hrm, when there is a type mismatch for a template the possible matches don't seem to be listed
09:54:04Araqdom96: fix it :P
09:54:30dom96Araq: What's the difficulty level? :P
09:56:08Araqdunno, 3/5?
09:56:28dom96That sounds tough.
09:57:13Araqok 1/5 then
09:57:24dom96Still too tough heh
09:58:05Araq0/5?
09:58:24Araqmy cat could do it :P
09:58:58dom96You have a cat?
09:59:15Araqno ...
09:59:31Araqthats why it is not implemented yet :P
09:59:37dom96hehe
09:59:50dom96ok, I will try it. When I feel like it :P
10:01:16dom96Hrm.
10:01:17dom96error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher
12:38:35*Zerathul joined #nimrod
12:50:20*Zerathul quit (Quit: ChatZilla 0.9.88.2 [Firefox 12.0/20120420145725])
15:04:55Araqzahary: hu?
15:05:05zaharytry the test case in your nimrod
15:05:34Araqer why should they?
15:05:50Araqhm
15:07:30zaharywell, that's how it works in every other language and finally is for guaranteed clean-up after all
15:07:39Araqyeah alright
15:07:49Araqit's an edge case though IMO
15:10:07zaharyI stumbled upon it why thinking how the C++ code should work (so I had to see what the C backend does)
15:10:07zaharyI have an idea to implement a simpler solution if C11 is detected. have you ever considered some kind of configure step to detect the local compiler?
15:10:19zahary* while thinking *
15:14:45Araqin fact, there is somebody working on autoconf support for niminst/the compiler
15:15:22Araqwhat is the simpler solution for C11?
15:16:05zaharyit's possible to use the new lambda syntax to create a local variable whose destructor is going to call the finally block
15:17:31Araqso you're talking about C++11, alright
15:18:03zaharyyes, was there C11 too? sorry
15:18:13AraqI think so
15:19:08zaharyyes, there is indeed
15:22:24Araqzahary: dom96 is working on SSL support for sockets
15:22:52Araqand now TSocket is not a 'distinct cint' anymore but an object with a buffer
15:22:59dom96Araq: I think i'm done. Unbuffered sockets are working too.
15:23:08Araqand as such
15:23:25Araqproc acceptAddr*(server: TSocket): tuple[sock: TSocket, address: string]
15:23:41Araqbecomes inefficient
15:24:04Araqany ideas?
15:24:20AraqI'd say 'acceptAddr' has to change its interface
15:24:47zaharywell, how inefficient? how big is the new TSocket? I guess it still holds a handle to the underlying OS object
15:25:41Araqyeah but it also contains a 4K array of char buffer
15:26:47zaharyI see
15:27:06Araqproc p: TSocket # doesn't cause problems I think
15:27:39Araqas Nimrod's backend or perhaps the C compiler transform that into an implicit pointer parameter
15:27:48zaharyI could look up how it's done in some other libraries - maybe it's popular to keep the buffer in some kind of external SSL adaptor that's passed to the ssl socket functions
15:28:08Araqthe buffer is not only for SSL though
15:28:42Araqmany protocols rely on a 'recvLine' which can't be done efficiently without buffering
15:29:04Araq(the OS's sockets API is a PITA ...)
15:30:47Araqwe used to do 'recv(s, addr(ch), 1)' and receive a single character
15:30:55Araqfor recvLine()
15:30:58zaharyI'm most experience with boost.asio, where there is a streambuf object that you pass in the readline operation
15:31:13zaharyyou can also pass a fixed buffer
15:32:33Araqafaik this perforrmed an OS switch for every single character ...
15:32:57Araqdunno how it could perform decently
15:33:53dom96With buffering it seems to perform better: 0.021 with buffering, 0.063 without (In seconds)
15:35:08Araqi suppose glibc did some buffering too?
15:42:17dom96So, should I hold off with committing this?
15:42:50Araqugh just change acceptAddr please
15:43:17Araqso that gets a var tsocket and a var string
15:45:12dom96acceptAddr only gets a TSocket, no string.
15:45:46Araqno ...
15:46:33dom96I can't return a 'var string'...
15:49:41Araqlol
15:50:01Araqit should be another param
15:50:36dom96oh, that's what you mean
15:50:47dom96... that will break a lot of code :(
15:50:57Araqreally?
15:51:06dom96well maybe not that much.
15:51:19Araqwell TSocket now has to be 'var TSocket' ...
15:51:29Araqwe break every module that uses sockets already
15:52:33Araqzahary: C++11 is not something that needs to be detected I think; GCC, Visual, Clang and Intel do support large parts of it already, right?
15:53:23zaharywith command line switches
15:54:23Araqgood enough for me
15:56:39zaharywell, I'll implement both more verbose C++98 version and the simpler C++11 version
15:57:23Araq*shrug* if you feel like it :-)
16:03:20Araqabout the threading stuff: I suppose there are a lot of abstractions that hide thread creation, right?
16:03:25dom96Araq: I'll deprecate ssl, ok? (btw how do I do it? :P)
16:03:36Araqdom96: what? why?
16:04:00dom96Araq: Perhaps I should clarify, I mean the ssl module.
16:04:14Araqwhy?
16:04:25Araqbecause sockets now support everything of it?
16:04:30dom96yeah, and more.
16:05:30Araqalright, add a {.deprecated.} top level statement
16:05:38Araqto deprecate a module
16:06:05dom96ok
16:26:08*Boscop quit (Ping timeout: 240 seconds)
16:29:34dom96Araq: Well as soon as I change the accept function to what you suggest it stops working...
16:29:38dom96And I don't get why
16:29:47*Boscop joined #nimrod
16:31:58dom96Araq: Never mind
16:32:46Araqok
16:39:46dom96Araq: ok, i'm ready to commit, have you found any other things that need adjusting?
16:45:00Araqdom96: perhaps we can make "SMTP module compiled without SSL support" a compile-time error message?
16:45:38dom96Sure, how do I do that?
16:45:48dom96when not defined(ssl): {.error: "...".}
16:45:49dom96?
16:46:07Araqyeah
16:46:46Araqit should be 'initSocket', not 'newTSocket'
16:47:17Araqbut it's not important as you don't export that
16:49:07Araqsleep(500) # SSL supports no async io? or why is it needed?
16:49:20Araqand half a second seems a bit long
16:49:32Araqmake that 50 or something
16:51:02*Boscop is now known as Boscop_
16:51:18dom96I guess I could use select
16:51:53dom96But i'd need to forward declare it...
16:51:57*dom96 got a bit lazy there :P
16:52:46Araqand waitFor() should be a proc, not a template
16:57:02dom96alright
16:57:49Araqand your recv*(socket: var TSocket, data: pointer, size: int): int implemenation is inefficient :P
16:58:08Araqit should copyMem() bulks, not handle single characters
17:06:38dom96Anything else?
17:10:46Araqno :-)
17:11:23dom96hrm
17:11:30dom96I don't think i'm doing this right:
17:11:31dom96copyMem(addr(socket.buffer[socket.currPos]), data, chunk)
17:11:36dom96help? :P
17:14:50Araqflip the args
17:14:57Araq'data' is the destination
17:16:02dom96oh god.
17:16:09dom96Apparently I don't know English anymore.
17:31:33zaharycan someone try "nimrod —cc:gpp cpp hello.nim" for me. I'm getting some undefined symbols and I'm not sure whether I broke it somehow
17:32:17zaharyisObj, systemInit, newObj - something in common about them?
17:34:44Araqzahary: sorry, I can't bootstrap atm
17:35:38zaharynevermind, executing some random build command fixed the issue, I guess some o file was bad
17:39:52Araqyummy :-)
18:11:00dom96Finally.
18:28:34*apriori_ joined #nimrod
18:48:54Araqso zahary since I'll be busy with the closure stuff the next week, do you want to to 'inject' stuff?
18:50:41apriori_btw., when trying to create a c->nimrod binding (in my case opencl) .. how shall I treat C unsigned types?
18:52:07Araqapriori_: use the signed versions, it only matters they have the same size
18:52:34apriori_Araq: ok
18:52:43Araqyou should however use types like 'type cunsignedInt = cint' so that we can change it easily once we got unsigned support
18:52:59apriori_ok
18:57:39Araqoh and please apriori_ put you code on github :-)
18:57:45Araq*your
18:57:53apriori_well.. I will .. if it works some day :)
18:58:14apriori_I might run into tons of issues with forced alignments etc.
19:05:10*XAMPP joined #nimrod
19:25:19apriori_how would I translate: void (CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, void *) as a parameter to a function?
19:25:38apriori_c2nim did the following:
19:25:41apriori_a5: proc (a2: cstring, a3: pointer, a4: TCLSize_t,
19:25:45apriori_a5: pointer): proc (a2: ptr CL_CALLBACK),
19:26:42Araqc2nim doesn't like function pointers ;-)
19:26:52apriori_yeah, i though that, too
19:27:04Araqbut it's not too bad
19:27:08apriori_but could you resolve that example? I got numerous cases like that
19:28:16AraqI think you need to replace 'ptr CL_CALLBACK' with 'CL_CALLBACK' and then it's fine
19:28:45apriori_well, maybe.. but CL_CALLBACK is a define which either expands to nothing or __stdcall
19:28:49Araqand 'size_t' is 'int'
19:29:05Araqoh simple then, use:
19:29:19Araq #def CL_CALLBACK __stdcall
19:32:27Araqso the proper translation is:
19:32:54Araqparam: proc (a1: cstring, a2: pointer, a3: int, a4: pointer) {.stdcall.}
19:33:07apriori_ok
19:33:20apriori_and btw..
19:33:31Araqyou can also do {.push callConv: stdcall.} for the whole module I think
19:33:35apriori_proc (....) : proc (...)... somehow reads like a higher order function
19:34:01Araqmaybe that is because it *is* a higher order function :P
19:34:14apriori_ok ;)
19:34:27apriori_just feels a bit strange for a function pointer
19:34:35apriori_but in a way.. it even makes sense
19:34:55Araqthere is no difference between them
19:35:38apriori_thank you
19:35:47Araqthere is however a {.closure.} calling convention which makes the function pointer "fat" :-)
19:36:03apriori_ok
19:41:40Araqdom96: smtp.nim The SMTP module should be compiled with SSL support. Compile with -d:ssl. no
19:41:55Araqyou broke some test :P
19:42:05dom96Yeah... I noticed
19:42:30dom96But I dunno how to tell the test suite to compile the smtp module with -d:ssl
19:43:55Araqcreate some nimrod.cfg?
19:45:03Araqor edit the tester
19:46:38dom96argh, i'll do it later
20:25:28apriori_ohm, how do I decribe a null pointer?
20:25:36apriori_addr(0) doesn't quite seem to do it
20:26:07dom96nil
20:26:11apriori_k
20:26:14apriori_thank you
20:52:13*Boscop_ is now known as Boscop
21:16:37apriori_hm, any hints on debugging a SIGSEGV when calling one of the binding functions?
21:17:59Araqit likely couldn't be loaded then
21:18:44Araqbut hm, no
21:18:56Araqit should give an error message then
21:19:30apriori_ah, well, my error..
21:20:31apriori_should have passed in a PCLPlatform_Id*{.pure, final.} = ptr TCLPlatform_id TCLPlatform_id*{.pure, final.} = object
21:20:35apriori_but passed in the object
21:21:42Araq?
21:21:55Araqshouldn't the compiler moan about that?
21:22:08apriori_not if I construct a improper function prototype
21:22:16Araqtrue ...
21:43:30apriori_yet another strange case...
21:43:40apriori_I need a pointer to the beginning of a dynamic array
21:43:47apriori_I guess that's the sequence type?
21:44:07apriori_but what would be a pointer to its beginning? addr(platformIDs[0]) doesn't quite seem to be it
21:44:39Araqbut it is
21:44:48apriori_ah, damn it..
21:44:55apriori_pretty much the same error ^^
21:45:00apriori_wrong function prototype
21:45:06apriori_ptr ptr needed...
21:45:35Araqwell if you used c2nim it should be *consistently* wrong :-)
21:45:44apriori_yup, it is
21:45:55apriori_but I'd need to test every single function anyway
21:46:20apriori_luckily there aren't many
21:47:52apriori_awesome.. 2 functions already working :P
21:49:13apriori_oh.. just 71 left :P
21:50:10Araqmaybe you should search and replace for TCLPlatform?
21:50:18Araqand replace it by PClPlatform?
21:50:41apriori_yeah, I did that already
21:52:48Araqproof reading should be faster than testing
21:55:10apriori_well, maybe..
21:55:21apriori_I'm checking signatures with the khronos documentation
21:55:41apriori_but sometimes.. its kinda weird
21:55:51apriori_not quite sure, what convention I should follow, because:
21:56:16apriori_e.g. clGetDeviceIDs takes "cl_platform_id".. which is a typedef struct _cl_platform_id * cl_platform_id
21:56:21apriori_so a pointer
21:56:56apriori_but.. TCLPlatform_id{.pure, final.} = object, PCLPlatform_id = ptr TCLPlatform_id
21:56:59apriori_its kinda confusing
21:57:21apriori_because also cl_platform_id * occurs in other functions
21:57:42apriori_so maybe I should just make the pointer to the objec the "base type" and call it TCLPlatform_id..
21:57:50apriori_any recommendations about that?
21:57:54Araqif that helps you sure
21:57:54zaharyAraq, what exactly does happen when I say type csize {.importc: "size_t".} = int? does this somehow alter the existing representation of int?
21:59:08Araqzahary: there is no canonicalization for integral types, see ccgutils.GetUniqueType
21:59:20apriori_Araq: but its not really possible to direct write: TClPlatform_id*{.pure, final.} = ptr object
21:59:25apriori_so I need a dummy type, I gues
21:59:27apriori_*guess
21:59:54Araqto answer your question, there will be 2 or more tyInt objects, one of name "size_t" (typ's sym)
22:00:25Araqapriori_: yeah; 'ptr object' is planned though
22:00:47apriori_ok
22:02:30Araqzahary: the compiler has not been written with this in mind though, so there should be bugs with this feature
22:02:31zaharywell, I would expect that, but suddenly after adding an innocent "unsigned int" in os.nim, I started to get errors in other modules - some var int procs became unsigned int*
22:03:58AraqC++'s type safety is hurting us, hu?
22:04:02zaharythe PITA is that C++ doesn't like int* to unsinged int* conversions
22:06:25Araq*shrug* introduce unsigned ints to the compiler instead
22:07:09Araqmy plan was to get rid of tyInt8..tyInt64 and have tyInt, tyIntX, tyUInt and tyUintX
22:07:09zaharywell, yeah, but not tonight :)
22:07:29Araqthe type's size can be used to determine the number of bits
22:07:41Araqbut most of the time the code doesn't care anyway
22:07:56Araqso it's better to conflate them and make the enum smaller
22:09:11zaharythe migration to C++ also triggered some kind of memory corruption involving sequences - I haven't quite figured out what's going on, but it's related to the use of Sup in C vs the direct inheritance in C++
22:09:29Araqthat's strange
22:09:41Araqsome different alignments ...
22:09:48Araqbut that shouldn't happen
22:11:52zaharyI don't know how often is triggered, I need only to comment a single use of the fileinfos sequence (global variable) in the compile to get a successful bootstrap
22:13:25Araqmaybe you just triggered different code generation and the compiler keeps a negative offset pointer as root
22:13:58Araqwe talked about it, it's a possibility and we can't work around it
22:14:07Araqthough it's unlikely
22:18:17zaharyI'm curious, why try blocks have a call to setFrame?
22:19:02zaharyisn't that duplicated effort with the normal pushFrame at the start of the proc?
22:20:07Araqbecause it's non local control flow and the framePtr points beyond the current stack
22:20:26Araqit points into garbage if it returns via a longjmp
22:20:32Araqand that's bad for stack traces :-)
22:20:45zaharyaha, that's required after the jump
22:27:21apriori_I assume it makes no sense to actually "port" headers guards, does it?
22:27:46Araqapriori_: no ... :-)
22:28:26apriori_good
22:30:31apriori_is there a "defined" thingy for unix systems?
22:30:54apriori_in the docs I just see a block of defined(windows), defined(macosx), else...
22:30:57Araqthere is a 'when defined(unix)'
22:31:06apriori_good
22:31:09Araqand a 'when defined(posix)'
22:31:24apriori_ok, thank you
22:32:32Araqgood night
22:32:37apriori_bye
23:19:52*apriori_ quit (Quit: Konversation terminated!)