00:01:11 | * | araq0 joined #nim |
00:02:25 | * | araq0 quit (Client Quit) |
00:05:09 | * | ics quit (Quit: Connection closed for inactivity) |
00:14:39 | * | Demos quit (Ping timeout: 260 seconds) |
00:28:11 | * | sp33der89 joined #nim |
00:28:49 | * | Demos joined #nim |
00:32:07 | * | brechtm quit (Remote host closed the connection) |
00:35:29 | * | mcc joined #nim |
00:38:59 | * | ftsf_ joined #nim |
00:46:34 | * | brson quit (Ping timeout: 240 seconds) |
00:49:16 | kier | vktec: the most robust way is probably to write a wrapper function in C that unpacks the struct into some reference parameters |
00:49:59 | vktec | kier: So, like, getters and setters? |
00:50:10 | kier | but I think that in most circumstances, a Nim tuple/object will be binary compatible with a C struct (so long as all the element types are binary compatible and are in the same order) |
00:50:36 | kier | you could do individual getters and setters, but that'd probably mean calling the function every time you want to get a single field |
00:51:43 | vktec | kier: Okay, so if they're binary compatible, can I just create a tuple with the same attributes/types and use that? |
00:52:43 | kier | yeah. I don't guarantee that it'll work, and it's definitely not portable, but it's a hack that ought to work |
00:53:18 | * | yglukhov joined #nim |
00:53:19 | kier | vktec: this is what i was getting at with the wrapper function: https://gist.github.com/kierdavis/d17b59d78bcbfbd497fc6354a7459f6a |
00:55:49 | vktec | kier: Ahh, so that wrapper would translate to Nim as `proc call_and_unpack(a: var cint, b: var cstring, c: var cuint8)` (or something similar) |
00:57:06 | kier | yeah something along those lines |
00:57:26 | kier | (disclaimer: I haven't tested any of this) |
00:57:40 | * | yglukhov quit (Ping timeout: 258 seconds) |
01:07:13 | * | Demos quit (Ping timeout: 244 seconds) |
01:15:21 | * | desophos_ joined #nim |
01:20:22 | * | desophos_ quit (Ping timeout: 272 seconds) |
01:38:52 | * | chemist69 quit (Ping timeout: 264 seconds) |
01:47:09 | * | sp33der89 quit (Ping timeout: 246 seconds) |
01:48:26 | * | zodiak_ joined #nim |
01:48:34 | * | zodiak quit (Read error: Connection reset by peer) |
01:52:09 | * | chemist69 joined #nim |
01:54:06 | * | Demos joined #nim |
02:13:29 | * | bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
02:29:51 | * | hendi_ joined #nim |
02:33:30 | * | hendi quit (Ping timeout: 258 seconds) |
02:49:04 | * | Demon_Fox joined #nim |
02:49:12 | * | Demos quit (Read error: Connection reset by peer) |
02:49:18 | * | bjz joined #nim |
02:58:23 | * | Jesin quit (Quit: Leaving) |
02:58:58 | * | dmitry_p joined #nim |
03:02:31 | * | chrisheller quit (Ping timeout: 252 seconds) |
03:05:47 | * | bjz quit (Read error: Connection reset by peer) |
03:06:00 | * | chrisheller joined #nim |
03:15:22 | * | Jesin joined #nim |
03:19:18 | * | arnetheduck quit (Remote host closed the connection) |
03:24:03 | * | arnetheduck joined #nim |
03:26:21 | * | arnetheduck quit (Remote host closed the connection) |
03:27:17 | * | fredrik92 quit (Quit: Shutting down...) |
03:28:14 | * | arnetheduck joined #nim |
03:32:36 | ftsf_ | what's the difference between static binding and dynamic binding? |
03:32:41 | ftsf_ | proc vs method |
03:42:46 | * | yglukhov joined #nim |
03:47:03 | * | yglukhov quit (Ping timeout: 244 seconds) |
03:50:38 | * | fvs joined #nim |
03:53:06 | fvs | howto test for IndexError if {.push checks:off, line_dir:off, stack_trace:off.} is used as in pure stats module? |
03:56:51 | * | GangstaCat quit (Quit: Leaving) |
03:56:51 | fvs | trying to implement median proc that should fail for @[] |
03:59:39 | * | kssreeram joined #nim |
04:03:37 | * | fvs quit (Ping timeout: 250 seconds) |
04:21:27 | * | chrisheller quit (Remote host closed the connection) |
04:23:33 | * | kssreeram quit (Ping timeout: 250 seconds) |
04:26:52 | * | kssreeram joined #nim |
04:30:31 | * | dmitry_p quit (Quit: Leaving) |
04:32:49 | * | brechtm joined #nim |
04:33:23 | * | ics joined #nim |
04:37:10 | * | brechtm quit (Ping timeout: 244 seconds) |
04:38:13 | * | kssreeram quit (Read error: No route to host) |
05:01:35 | * | endragor joined #nim |
05:14:49 | * | s4 joined #nim |
05:39:23 | * | yglukhov joined #nim |
05:44:28 | * | yglukhov quit (Ping timeout: 272 seconds) |
05:56:04 | * | chrisheller joined #nim |
06:00:43 | * | chrisheller quit (Ping timeout: 252 seconds) |
06:16:03 | * | endragor_ joined #nim |
06:18:46 | * | endragor quit (Ping timeout: 244 seconds) |
06:22:46 | * | brechtm joined #nim |
06:30:18 | * | endragor_ quit (Remote host closed the connection) |
06:30:24 | chemist69 | fvs: can't you just test for len == 0 ? |
06:30:48 | * | endragor joined #nim |
06:42:52 | * | desophos_ joined #nim |
06:46:51 | * | desophos_ quit (Ping timeout: 240 seconds) |
06:58:05 | hendi_ | PMunch: cool, thanks! |
07:00:21 | * | irrequietus joined #nim |
07:14:32 | * | PMunch joined #nim |
07:17:21 | * | irrequietus quit () |
07:24:48 | * | yglukhov joined #nim |
07:36:15 | * | desophos_ joined #nim |
07:39:20 | * | bjz joined #nim |
07:40:35 | * | desophos_ quit (Ping timeout: 244 seconds) |
07:44:55 | * | Trustable joined #nim |
07:49:28 | * | bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
07:50:27 | * | bjz joined #nim |
07:50:29 | * | bjz quit (Client Quit) |
07:51:42 | dyce_ | dom96: is it fine there is a warning when defining a table before the jester directives? |
07:51:49 | dyce_ | warning about the GC |
08:01:52 | * | kssreeram joined #nim |
08:03:59 | * | ftsf_ quit (Remote host closed the connection) |
08:09:18 | chemist69 | PMunch: concerning yesterday's converter issue with countup(): if you write an iterator that only can use ints, the converter works: https://glot.io/snippets/eg3q4920f2 |
08:09:37 | PMunch | Yeah I saw you posted that on your issue |
08:10:26 | PMunch | http://pastebin.com/y8y2z9A8 |
08:10:44 | PMunch | That's my snippet from yesterday. The part that was failing is line 14 |
08:11:00 | * | coffeepot joined #nim |
08:11:08 | * | Arrrr joined #nim |
08:11:29 | PMunch | So it seems that T is not IntLikeForCount which it would be with only ints (if I'm not mistaken) |
08:14:04 | PMunch | My guess is that since countupn takes generics it messes up the conversion |
08:14:31 | chemist69 | if you import typetraits and insert echo(res.type.name) before the inc (and comment out inc) then the type of res is still float64 |
08:14:44 | chemist69 | I guess you're right. |
08:14:52 | PMunch | Yeah |
08:15:50 | PMunch | Problem is that at the point were it's being passed into inc it is converted to an int |
08:16:00 | PMunch | This int is not a var and thus you get the error |
08:16:47 | chemist69 | yes, so if the iterator would use x = x + 1, then it should work? |
08:16:48 | * | desophos quit (Read error: Connection reset by peer) |
08:17:12 | PMunch | Well, maybe |
08:17:23 | PMunch | But I don't think it would be converted to int at all then |
08:17:37 | chemist69 | you're right again |
08:18:09 | chemist69 | could one write a converter floatToIntlike ? |
08:18:34 | PMunch | Probably, but I don't think it would get called |
08:18:51 | PMunch | The problem is that the code has a valid path for floats, so the converter is never called |
08:19:01 | PMunch | Until it's too late |
08:19:17 | chemist69 | well, okay, then I'll settle for using converters with simple types. |
08:20:08 | PMunch | Ah well, IntLikeForCount is defined as: type IntLikeForCount = int|int8|int16|int32|char|bool|uint8|uint16|enum |
08:20:22 | PMunch | So you already have a converter for it |
08:20:52 | chemist69 | except for the float, which was the starting point... |
08:22:57 | PMunch | Hmm |
08:23:13 | PMunch | In my example http://pastebin.com/raw/y8y2z9A8 |
08:23:35 | PMunch | If you change the types for the variables T and S your code works |
08:23:50 | PMunch | This is simply because it returns a type of the same kind as the second argument |
08:24:53 | PMunch | By swapping them you return a type of the same kind as the first, which is int. This also means that "var res: T = T(a)" will convert your float to an int |
08:25:28 | PMunch | Actually since it does it explicitly it doesn't even need the converter |
08:26:25 | chemist69 | yeah, I get the feeling, that this was a really bad example for using a converter, so maybe we should move on... |
08:26:46 | * | mcc quit (Quit: Connection closed for inactivity) |
08:30:29 | chemist69 | gotta go do some labwork. bbl |
08:31:42 | PMunch | TBH I'm not sure why it does the type checking in the first place |
08:32:41 | PMunch | http://pastebin.com/0FmXz5Vh |
08:32:57 | PMunch | That function works for any types that takes something convertible to an int |
08:33:25 | PMunch | That function works for any type that is convertible to an int* |
08:34:01 | * | rolha joined #nim |
08:41:49 | * | kssreeram quit (Ping timeout: 250 seconds) |
08:50:40 | * | arnetheduck quit (Ping timeout: 252 seconds) |
08:52:38 | vktec | Is it possible to have a Nim variable that is a C pointer, so that complex C structs, etc can be passed around easily? |
08:52:57 | vktec | (I don't need to read information from the struct in Nim) |
08:53:53 | PMunch | ptr cchar? |
08:55:20 | vktec | PMunch: Would that work with something other than a cchar though? |
08:55:28 | yglukhov | vktec: every ptr is a c pointer. there's also type `pointer` which is void* |
08:56:07 | vktec | yglukhov: Okay, so how would I represent a pointer to a C struct in Nim? |
08:56:40 | EastByte | var p: pointer = addr struct |
08:56:50 | yglukhov | there are several ways. |
08:57:14 | PMunch | vktec, C isn't so concerned about what is actually pointed to by a pointer. It's more of a hint to the compiler that allows it to check if your assignments and such makes sense. |
08:57:34 | yglukhov | if you have a nim type that represents your struct (e.g. MyCStructure). then your pointer type is "type MyCStructurePtr = ptr MyCStructure" |
08:57:46 | PMunch | For example you won't be able to access a member of a struct through a char* since the compiler have no idea what offset the member is at. |
08:58:18 | vktec | PMunch: Okay, that makes things much easier |
08:58:21 | vktec | :) |
08:58:31 | yglukhov | also note, that you can get away with only your value type without ptr type, if you annotate function args properly |
08:58:47 | PMunch | But you should still go with yglukhov's way of doing it |
08:58:52 | vktec | Okay |
08:59:03 | PMunch | You could do some weird pointer arithmetic manually but it's not advisable :P |
08:59:05 | yglukhov | e.g. if you define proc myCFunctionThatAcceptsPointerToMyStruct(mystruct: var MyStruct) {.importc.} |
08:59:27 | vktec | Okay, thanks yglukhov, PMunch |
08:59:59 | yglukhov | if your c function accepts a pointer, but doesnt modify the struct it points to, you can use `byref` arg annotation |
09:00:45 | * | LeNsTR|away joined #nim |
09:00:47 | yglukhov | if your struct is an opaque type, then you just define type MyStructRef = distinct pointer |
09:01:39 | yglukhov | as you can see, there's a lot of ways depending on your needs, so that you can bind to C with a nice nimish api, paying no runtime cost |
09:01:51 | vktec | yglukhov: I'm getting "illegal recursion" when using `type MyCStructure = ptr MyCStructure` |
09:02:01 | * | coffeepot quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
09:02:14 | vktec | yglukhov: What do you mean by "opaque type"? |
09:02:42 | vktec | (Disclaimer: I'm by no means good at C) |
09:02:56 | * | cjh`_ joined #nim |
09:03:12 | yglukhov | "illegal recursion" - because you have to define to types with different names. one is actual value type struct. the other is ptr to it |
09:03:17 | * | allan0_ joined #nim |
09:03:19 | yglukhov | * two |
09:04:04 | yglukhov | "opaque type" - is a type that you don't have_acces_to/care_about_its members. |
09:04:09 | * | devn_ joined #nim |
09:04:16 | vktec | Okay |
09:04:37 | yglukhov | like some references, handles, etc. which are created by some public api, and work only with those |
09:05:20 | vktec | I don't need to access the C struct's members from Nim. Would `distinct pointer` work? |
09:05:33 | yglukhov | yes |
09:05:41 | vktec | Okay |
09:05:49 | vktec | Is that the best/easiest solution? |
09:06:14 | yglukhov | that depends =) |
09:06:45 | vktec | :) |
09:06:53 | vktec | I'll give it a go and see what happens |
09:06:57 | * | PMunch quit (Ping timeout: 250 seconds) |
09:07:38 | * | sarlalian_ joined #nim |
09:08:16 | * | lenstr quit (*.net *.split) |
09:08:17 | * | gokr quit (*.net *.split) |
09:08:17 | * | Amun_Ra quit (*.net *.split) |
09:08:17 | * | Satyajit quit (*.net *.split) |
09:08:17 | * | dom96 quit (*.net *.split) |
09:08:17 | * | sarlalian quit (*.net *.split) |
09:08:18 | * | devn quit (*.net *.split) |
09:08:18 | * | cjh` quit (*.net *.split) |
09:08:18 | * | allan0 quit (*.net *.split) |
09:08:18 | * | dyce_ quit (*.net *.split) |
09:08:31 | yglukhov | sure. you can show me a gist with c definitions you want to bind to, maybe ill give you better hints |
09:09:30 | * | dom96 joined #nim |
09:10:03 | vktec | Okay, 1 sec |
09:10:32 | * | PMunch joined #nim |
09:12:18 | vktec | Here's the typedef: http://0bin.net/paste/ugrD1Vj-RuPhIgVO#dmYMuAuycUCiYmGG-yD1pEhj4wBzj/N76SB7ZwueLWQ |
09:12:42 | * | TheLemonMan joined #nim |
09:15:24 | * | rolha quit (Ping timeout: 260 seconds) |
09:16:55 | * | dyce_ joined #nim |
09:16:56 | * | Amun_Ra joined #nim |
09:17:26 | yglukhov | vktec: errr... some function headers please? =) |
09:17:54 | vktec | I'll link you the header file :) |
09:18:07 | yglukhov | kk |
09:18:10 | * | LeNsTR|away is now known as lenstr |
09:18:11 | * | lenstr quit (Changing host) |
09:18:11 | * | lenstr joined #nim |
09:18:25 | vktec | https://github.com/mruby/mruby/blob/master/include/mruby.h |
09:19:37 | yglukhov | ok, so these structs look a lot like opaque. even though you can see their internals, you never have to access them. correct? |
09:19:55 | * | gokr joined #nim |
09:20:40 | PMunch | Hmm, any particular reason why custom converters don't get applied when called eg. int(variable) |
09:21:02 | yglukhov | so yeah, you can go with distinct pointer solution for the start. just don't bind functions by referring to c headers, because you'll have a c ompile error of type mismatch. |
09:21:24 | vktec | yglukhov: Okay |
09:22:12 | vktec | What's the recommended way to link my Nim program to mruby's static library? |
09:22:42 | yglukhov | with distinct pointer you will be able to get up and running pretty quickly, and further on, if you will need to do full-blown struct definitions (to access members from nim), you will be able to do it gradually in a backward compatible manner |
09:23:01 | vktec | yglukhov: Sounds good, thanks |
09:23:24 | yglukhov | dunno... how bout {.passL:"-lmruby".}. kinda hammerish way, but should be ok for start |
09:24:32 | vktec | I'll try that, thanks |
09:24:36 | PMunch | github.com/fowlmouth/mruby.nim |
09:24:38 | yglukhov | anytime ;) |
09:24:41 | PMunch | That might be helpful |
09:25:07 | * | Demon_Fox quit (Quit: Leaving) |
09:25:07 | yglukhov | wow, why thats not on nimble |
09:25:08 | vktec | Oh. |
09:25:18 | vktec | How did I not find that 0_o |
09:25:18 | PMunch | fowl, what's the status of that ^ |
09:25:27 | vktec | Could've sworn I looked... |
09:25:39 | PMunch | I literally found it by searching for "mruby nim" |
09:25:42 | fowl | not good |
09:25:53 | PMunch | Found some IRC log were fowl mentioned it and went to his GitHub page :P |
09:26:07 | PMunch | fowl, how so? Not working at all? |
09:26:26 | vktec | PMunch: Huh. |
09:26:37 | yglukhov | vktec: ok, new plan. get fowls bindings up, and submit them to nimble =) |
09:26:49 | vktec | :) |
09:26:51 | fowl | IIRC its full of macros and ifdefs that change structures, it was a PITA |
09:27:03 | chemist69 | PMunch: maybe you should submit a pull request for your countup function ;) |
09:27:03 | * | pafmaf joined #nim |
09:28:37 | * | Satyajit joined #nim |
09:29:21 | vktec | fowl's bindings look a) _way_ too complex for me (I've literally never written a binding before) and b) a bit OTT for what I need to do |
09:30:52 | PMunch | chemist69, I added the code to the issue. I'm happy to create a PR if no further changes are proposed. |
09:30:55 | PMunch | github.com/nim-lang/Nim/issues/4431 |
09:31:37 | PMunch | But honestly, why aren't custom converters counted in T(variable) statements (any type, int(variable) doesn't call them either) |
09:32:15 | PMunch | The snippet is pretty ugly since it has to define the variables with a type so that implicit conversion will take place and call the custom converters. |
09:46:22 | yglukhov | fowl: btw, what do you think about nake issues? =) |
09:47:37 | fowl | yglukhov, i didnt know there were new issues sry |
09:48:19 | yglukhov | fowl can you take a look at them pls? |
09:49:10 | fowl | yglukhov, your feature request sounds fine and gradha was the guy who cared about releases, but i added you as a collaborator just now so you can make a new release if you want |
09:50:28 | yglukhov | oh ok cool, thanks. |
09:51:05 | yglukhov | i will then add the recursive lookup and do a new release |
09:52:36 | fowl | thanks i dont have a lot of time for programming these days |
09:56:08 | * | chrisheller joined #nim |
09:56:14 | * | vegansk quit (Ping timeout: 260 seconds) |
10:00:31 | * | chrisheller quit (Ping timeout: 252 seconds) |
10:09:40 | * | PMunch quit (Ping timeout: 258 seconds) |
10:15:36 | * | PMunch joined #nim |
10:20:42 | * | Arrrr_ joined #nim |
10:23:28 | * | Arrrr quit (Ping timeout: 258 seconds) |
10:24:07 | * | abruanese joined #nim |
10:30:05 | * | coffeepot joined #nim |
10:39:51 | * | Arrrr_ quit (Quit: WeeChat 1.4) |
10:40:06 | * | Arrrr joined #nim |
10:42:19 | * | Satyajit quit (Ping timeout: 252 seconds) |
10:44:03 | * | kier quit (Ping timeout: 246 seconds) |
10:45:51 | * | kier joined #nim |
10:55:15 | * | Satyajit joined #nim |
10:59:05 | * | KaiXBerg joined #nim |
11:01:31 | * | nsf quit (Quit: WeeChat 1.5) |
11:09:43 | * | fastrom1 quit (Quit: Leaving.) |
11:13:24 | * | ozra joined #nim |
11:32:21 | * | vegansk joined #nim |
11:49:15 | * | brechtm quit (Remote host closed the connection) |
11:59:09 | * | fowl left #nim ("Leaving") |
12:08:00 | PMunch | Hmm, I just realised why I prefer bracketed languages for large projects. It's a lot easier to see the end of large scopes. Many lines of decreasing indentation with a single bracket per line really makes the end of scopes evident. Nim for example can end a huge function in one line, making it hard to distinguish between it and the following code.. |
12:09:15 | * | rolha joined #nim |
12:10:36 | coffeepot | PMunch, this is where IDE tools come in. I use VSCode when working in Nim, which draws dotted lines to mark indent blocks which for me, is equivalent to bracket closes with the exception that bracket close indentations are not guaranteed to be inlined correctly |
12:13:37 | PMunch | Dotted lines? |
12:14:24 | coffeepot | yeah at the tab points. Actually you can also use this https://marketplace.visualstudio.com/items?itemName=oderwat.indent-rainbow |
12:14:34 | coffeepot | is this the sorta thing that'd help? |
12:15:24 | coffeepot | ofc this assumes windows :) |
12:16:04 | PMunch | Linux here, but dotted tab points are available in mostly any IDE |
12:16:15 | PMunch | The rainbow thing could be handy though |
12:16:50 | PMunch | It's not that I have a problem with indented lines |
12:16:54 | PMunch | But rather how they end |
12:17:22 | PMunch | Ending a scope with a large indentation in a single line to be specific |
12:21:22 | * | fredrik92 joined #nim |
12:22:38 | coffeepot | ah yeah, definitely helps to have some kind of ide helper for that if available |
12:23:43 | coffeepot | on the other side, I'm working on some C code atm that uses varying indents and even though the IDE highlights matching braces, it can get a bit confusing |
12:24:52 | coffeepot | but tbf I've not worked on any large nim projects! |
12:26:00 | dom96 | PMunch: Maybe adding empty lines to help you notice the change in scope would help? |
12:26:05 | PMunch | Yeah, varying indents are worse :P |
12:26:19 | PMunch | dom96, yeah. I've thought about doing that |
12:26:30 | dom96 | That's pretty much what I consider clean code to be. |
12:26:52 | dom96 | If everything is in the same long block with no empty line separation then it becomes much easier to read. |
12:26:59 | PMunch | I think it's the Python style guide (or the JavaScript one, can't remember) that specifies the use of two newlines for end of functions |
12:28:47 | PMunch | It makes it pretty simple to see where a function ends |
12:28:53 | PMunch | At least simpler |
12:29:20 | PMunch | But I think there's a difference between published code and code in development |
12:29:40 | * | brechtm joined #nim |
12:31:26 | PMunch | For example while writing code I might add in an experimental if test or remove one. In a language using brackets this is as simple as removing or a line at the top and/or bottom. In indented languages it means indenting the entire block just to remove the indent after you're done testing. |
12:32:39 | PMunch | Good editors obviously have support for indentation changes but it's still cumbersome |
12:44:48 | * | chemist69 quit (Quit: WeeChat 1.5) |
12:47:29 | * | chemist69 joined #nim |
12:47:35 | * | ddl_smurf joined #nim |
13:00:10 | * | KaiXBerg quit (Quit: Page closed) |
13:00:31 | * | KaiXBerg joined #nim |
13:05:59 | ftsf | how would I delete an item from a seq while iterating over it? |
13:07:20 | PMunch | Hmm, theoretically you could remove it and decrease your iteration variable by one (so that the next iteration will use the same value and therefore check the new element in this place) |
13:07:32 | PMunch | Not 100% sure if that works properly though, but it should.. |
13:07:39 | ftsf | PMunch, I get Error: unhandled exception: len(a) == L seq modified while iterating over it [AssertionError] |
13:07:55 | ftsf | I'm just curious how one generally works around that? |
13:07:55 | PMunch | Aaah, no that's not allowed then.. |
13:08:07 | * | saml joined #nim |
13:08:13 | PMunch | You could either create a list of elements to delete and separate it into two loops |
13:08:21 | fredrik92 | Generally, Iteration should imply immutability |
13:08:25 | ftsf | I can mark stuff to be deleted later, but then I have to iterate to check that mark? |
13:08:39 | PMunch | Or create a list of elements to keep which you update and then set the reference to the new list.. |
13:08:47 | ftsf | PMunch, hmm that could work |
13:08:59 | ftsf | seems suboptimal for memory though |
13:09:45 | PMunch | Well, removing stuff from the middle of a contiguous piece of memory is suboptimal |
13:09:59 | PMunch | seqs are implemented as realloced arrays |
13:10:07 | ftsf | ahh |
13:10:12 | ftsf | I guess what I want is a linked list |
13:10:13 | PMunch | So not sure how happy they are about shrinking.. |
13:10:20 | PMunch | That is an option |
13:10:39 | * | nsf joined #nim |
13:10:46 | ftsf | since this container will be containing particles which will be dying regularly |
13:10:57 | ftsf | or i could use a fixed array and find dead ones to replace perhaps |
13:11:12 | PMunch | Depends a bit on how you want to do it |
13:11:35 | ftsf | I'll try the fixed array method |
13:11:46 | PMunch | If you want to have a max cap on particles you could keep a fixed array and look for dead particles whenever you want to add one |
13:11:53 | ftsf | yep, i'll do that =) |
13:11:55 | PMunch | That means scanning the array though which might not be optimal |
13:11:56 | ftsf | thanks |
13:12:05 | ftsf | true |
13:12:26 | PMunch | You could create a linked list of bitmasks |
13:12:27 | ftsf | hmm, I guess linked list might be best as there will be a lot of adding and removing elements |
13:13:13 | PMunch | Then check if the bitmask is not zero (implying that there is space), then calculating the position into a fixed array and add your particle there |
13:13:36 | ftsf | hmm that seems complex =) |
13:13:56 | ftsf | I'll try the fixed thing, if it's a problem i'll switch to a linked list |
13:14:18 | fredrik92 | Yes, genrerally arrays (and realloc'ed arrays) are optimal for appending and removing at the end, Linked lists are easiest when doing inserts and deleted in the middle of the list... |
13:14:35 | PMunch | That would mean 1 link reference for every 32/62 elements, a single == check for every 32/64 elements to check if any of them is filled, and a little arithmetic to find the empty position |
13:15:04 | PMunch | Then of course a bitwise operation for marking and unmarking that a particle is dead/alive |
13:15:29 | fredrik92 | PMunch, done this before, have you? :P |
13:15:59 | PMunch | Haha, yeah. Was part of my Green Computing implementation :) |
13:16:46 | fredrik92 | Btw, Linked lists cam potentially also simplify parallelism issues... |
13:16:48 | PMunch | That level of obsessive detail work is probably not healthy for a human brain :P |
13:17:22 | fredrik92 | yeah, I notice that with myself... Kinda get worried from time to time :P |
13:18:31 | PMunch | The bitmask thing actually isn't too bad when it comes to parallelism for things like this |
13:19:06 | PMunch | A single atomic bit operation to mark a spot as occupied or not |
13:19:49 | fredrik92 | PMunch, you should check this one out: https://vimeo.com/172009499 (What tricks can you make when building a fast web server) :P |
13:19:54 | PMunch | Oh and I guess you won't even have to use a linked list for storing the bitmasks if the size of the particle pool is static :) |
13:20:46 | PMunch | fredrik92, care to send it on Telegram so I can check it out when I get off work? |
13:21:15 | fredrik92 | done |
13:21:31 | ftsf | is it possible to get an iterator that returns a mutable object? |
13:21:54 | fredrik92 | I guess you'd have to implement that one yourself...? |
13:22:43 | chemist69 | ftsf are you aware of <array>.mitems ? |
13:23:54 | ftsf | chemist69, i wasn't |
13:24:13 | ftsf | that sounds much more useful |
13:24:16 | * | rolha quit (Ping timeout: 272 seconds) |
13:25:02 | chemist69 | it's a hidden gem (not in the ruby sense)... |
13:26:02 | ftsf | can be quite hard to find some stuff in the nim docs unless you know what to look for |
13:26:50 | chemist69 | I agree. |
13:27:04 | ftsf | i noticed the "method" keyword doesn't seem to be in the manual |
13:27:15 | * | s4 quit (Quit: Konversation terminated!) |
13:29:36 | ftsf | I guess it does say it's a draft =) |
13:30:17 | PMunch | Hmm, maybe I should write a little library for efficient pools of this kind.. |
13:31:40 | PMunch | Optimized for this kind of random insert/removal with a cap on elements |
13:31:52 | ftsf | perhaps, if you don't have better things to do =) |
13:32:08 | PMunch | Well, define better things :P |
13:33:07 | coffeepot | I wonder if there's a reason why mitems isn't automatically used when a variable is modified, considering this http://nim-lang.org/docs/manual.html#overloading-resolution-overloading-based-on-var-t |
13:33:32 | coffeepot | and considering pairs is used automatically in iterators if you use two variables |
13:35:14 | * | Kaini quit (Remote host closed the connection) |
13:36:49 | * | Kaini joined #nim |
13:44:25 | * | brechtm quit (Remote host closed the connection) |
13:49:09 | * | stisa joined #nim |
13:49:11 | chemist69 | yes, and D uses the syntax "for var i in array" to allow modification of the array elements, which I quite liked. It's analogously to the var arg procedure call. |
13:50:24 | * | brechtm joined #nim |
13:53:14 | * | stisa quit (Client Quit) |
13:57:53 | * | desophos joined #nim |
14:07:17 | * | gokr quit (Ping timeout: 260 seconds) |
14:11:26 | * | gokr joined #nim |
14:15:11 | * | PMunch quit (Ping timeout: 240 seconds) |
14:22:25 | * | endragor_ joined #nim |
14:25:55 | * | freezerburnV joined #nim |
14:26:04 | * | endragor quit (Ping timeout: 240 seconds) |
14:26:53 | * | endragor_ quit (Ping timeout: 258 seconds) |
14:30:11 | * | freezerburnV quit (Ping timeout: 240 seconds) |
14:48:10 | * | coffeepot quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
14:50:29 | * | coffeepot joined #nim |
14:53:25 | * | pregressive joined #nim |
14:54:21 | * | pafmaf quit (Ping timeout: 276 seconds) |
15:15:32 | * | kssreeram joined #nim |
15:21:11 | * | kssreeram quit (Ping timeout: 240 seconds) |
15:24:02 | * | michael_campbell joined #nim |
15:26:20 | * | elrood joined #nim |
15:28:30 | Araq | hey guys, what's up? |
15:29:45 | cheatfate | Are you already in Poland? |
15:30:04 | Araq | yup |
15:31:20 | cheatfate | And hows first day of conference? |
15:31:41 | * | j3rn is now known as J3RN |
15:31:41 | * | ozra left #nim ("Konversation terminated!") |
15:32:11 | Araq | pretty nice, interesting talks and people |
15:33:02 | * | fvs joined #nim |
15:35:26 | cheatfate | And hows your speech? 30min was enough? |
15:35:59 | saml | what's conference |
15:36:20 | Araq | PolyConf 2016 |
15:36:30 | Araq | cheatfate: my talk will be tomorrow |
15:36:39 | Araq | 30 minutes are definitely enough |
15:37:19 | cheatfate | Araq, and when you return do you start `brand new and shiny` async core? |
15:37:53 | Araq | dunno. I thought you now know everything too. |
15:39:44 | cheatfate | I'm still not very strong in macros |
15:41:08 | * | chrisheller joined #nim |
15:41:08 | Araq | bbl |
15:41:29 | cheatfate | and i'm still not sure `switch context` will be faster, than what we have now... |
15:42:26 | avsej | dom96, where I can find how $lib substituted in nim.cfg? is it set during compile time somehow? |
15:47:30 | fvs | i have a proc that runs an sql query to copy a table to csv. No rows are returned in this qry. How do I wait for the csv to be written before returning from the proc? I plan to compress it and send it back to web client. |
15:54:29 | * | minus joined #nim |
15:56:21 | minus | hey, the redis clients page lists a nim binding/client, but that just 404s (http://redis.io/clients#nim). i'm assuming that's been removed and i should just use hiredis' C API directly? |
16:00:12 | * | yglukhov quit (Ping timeout: 244 seconds) |
16:01:54 | * | coffeepot quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
16:02:10 | elrood | minus, it's been moved from the standard library to https://github.com/nim-lang/redis |
16:03:25 | * | TheLemonMan quit (Quit: "It's now safe to turn off your computer.") |
16:03:37 | * | coffeepot joined #nim |
16:06:20 | minus | elrood: does it have docs on the official page or some page on its own as well? |
16:10:31 | minus | seems like no |
16:13:59 | * | kssreeram joined #nim |
16:14:30 | elrood | minus, no clue, sorry, doesn't seem so though. all i have about it is a git commit with its removal and new location |
16:15:13 | michael_campbell | (chuckle) Just realized there's a user here named "so", which is why my IRC client syntax-highlights that word. |
16:15:27 | minus | no problem. thanks for the info, i submitted a PR with the updated docs to redis |
16:15:27 | * | GangstaCat joined #nim |
16:23:42 | * | kssreeram quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
16:26:28 | * | coffeepot quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
16:27:38 | * | coffeepot joined #nim |
16:29:40 | * | pafmaf joined #nim |
16:30:07 | * | kssreeram joined #nim |
16:31:04 | * | brson joined #nim |
16:32:13 | * | coffeepot quit (Client Quit) |
16:38:03 | * | BitPuffin joined #nim |
16:42:55 | * | rolha joined #nim |
16:54:05 | * | yglukhov joined #nim |
16:59:34 | * | yglukhov quit (Remote host closed the connection) |
17:14:04 | * | Arrrr quit (Quit: WeeChat 1.4) |
17:19:00 | * | yglukhov joined #nim |
17:23:43 | * | benwboot_ joined #nim |
17:26:27 | * | benwbooth quit (Ping timeout: 244 seconds) |
17:30:26 | * | yglukhov quit (Remote host closed the connection) |
17:44:22 | * | benwbooth joined #nim |
17:45:03 | * | yglukhov joined #nim |
17:46:59 | * | benwboot_ quit (Ping timeout: 260 seconds) |
17:50:59 | * | kssreeram quit (Quit: Textual IRC Client: www.textualapp.com) |
17:51:44 | * | kssreeram joined #nim |
18:08:18 | * | xet7_ quit (Read error: Connection reset by peer) |
18:15:50 | * | yglukhov quit (Remote host closed the connection) |
18:21:10 | * | rolha quit (Ping timeout: 250 seconds) |
18:26:19 | * | Jesin quit (Quit: Leaving) |
18:40:50 | * | irrequietus joined #nim |
18:42:51 | * | yglukhov joined #nim |
18:47:53 | * | irrequietus quit () |
19:00:08 | * | vendethiel joined #nim |
19:03:40 | * | aziz joined #nim |
19:09:00 | * | TheLemonMan joined #nim |
19:26:57 | * | BitPuffin quit (Read error: Connection reset by peer) |
19:38:31 | * | stisa joined #nim |
19:51:41 | * | shodan45 joined #nim |
19:58:00 | * | Matthias247 joined #nim |
20:02:57 | * | fastrom joined #nim |
20:11:14 | * | stisa quit (Quit: Page closed) |
20:37:37 | * | pregressive quit (Remote host closed the connection) |
20:46:11 | * | GangstaCat quit (Quit: Leaving) |
21:13:14 | * | brechtm_ joined #nim |
21:15:49 | * | brechtm quit (Ping timeout: 260 seconds) |
21:19:45 | * | pafmaf quit (Quit: Leaving) |
21:28:42 | * | shodan45 quit (Remote host closed the connection) |
21:30:10 | * | OnO_ joined #nim |
21:30:41 | * | OnO quit (Ping timeout: 240 seconds) |
21:42:38 | * | benwboot_ joined #nim |
21:44:00 | * | allan0 joined #nim |
21:44:19 | * | KaiXBerg quit (Quit: Page closed) |
21:44:54 | * | fastrom1 joined #nim |
21:45:11 | * | benwbooth quit (Ping timeout: 240 seconds) |
21:45:24 | * | TheLemonMan quit (Quit: "It's now safe to turn off your computer.") |
21:45:37 | * | brechtm_ quit (*.net *.split) |
21:45:37 | * | vegansk quit (*.net *.split) |
21:45:37 | * | allan0_ quit (*.net *.split) |
21:45:38 | * | beatmox quit (*.net *.split) |
21:45:38 | * | pandada8 quit (*.net *.split) |
21:45:38 | * | regtools quit (*.net *.split) |
21:45:38 | * | cncl quit (*.net *.split) |
21:48:28 | * | fastrom quit (Ping timeout: 264 seconds) |
21:57:35 | * | Jesin joined #nim |
22:05:10 | * | Jesin quit (Quit: Leaving) |
22:16:17 | * | elrood quit (Quit: Leaving) |
22:30:21 | dyce_ | is there anything like some_list[-1] to get last element like in python |
22:30:27 | dyce_ | or do i have to use pop |
22:31:49 | * | Demon_Fox joined #nim |
22:35:51 | * | arnetheduck joined #nim |
22:39:25 | * | chrisheller quit (Remote host closed the connection) |
22:48:31 | * | Matthias247 quit (Read error: Connection reset by peer) |
22:51:05 | dyce_ | also home come this doesnt work "1 2 3".split().pop() |
22:51:06 | * | Trustable quit (Remote host closed the connection) |
22:57:53 | * | rolha joined #nim |
22:58:50 | * | kulelu88 joined #nim |
23:06:17 | * | fredrik92 quit (Quit: Shutting down...) |
23:09:04 | * | lee_ joined #nim |
23:11:58 | * | aziz quit (Quit: Ex-Chat) |
23:35:52 | * | rolha quit (Ping timeout: 264 seconds) |
23:50:00 | * | wuehlmaus quit (Ping timeout: 272 seconds) |
23:55:09 | * | arnetheduck_ joined #nim |
23:55:09 | * | arnetheduck quit (Read error: Connection reset by peer) |
23:55:22 | * | brson quit (Quit: leaving) |
23:56:28 | * | lee_ quit (Remote host closed the connection) |
23:56:38 | * | benwbooth joined #nim |
23:58:10 | * | benwboot_ quit (Ping timeout: 252 seconds) |