00:00:24 | * | Jesin quit (Ping timeout: 264 seconds) |
00:05:55 | * | Jesin joined #nim |
00:06:47 | * | dalarmmst joined #nim |
00:07:06 | * | irqpal quit (Quit: Konversation terminated!) |
00:09:23 | * | drewsrem quit (Quit: Leaving) |
00:12:42 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
00:13:48 | * | bendiken joined #nim |
00:15:06 | * | Moix joined #nim |
00:16:01 | * | Moix quit (Remote host closed the connection) |
00:24:16 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
00:25:22 | * | bendiken joined #nim |
00:33:17 | * | saml_ quit (Remote host closed the connection) |
00:35:49 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
00:36:41 | * | bendiken joined #nim |
00:44:44 | * | johnsoft joined #nim |
00:47:12 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
00:47:59 | * | bendiken joined #nim |
00:58:36 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
00:59:27 | * | bendiken joined #nim |
01:10:01 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
01:10:50 | * | bendiken joined #nim |
01:21:25 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
01:22:19 | * | bendiken joined #nim |
01:30:11 | * | leru quit (Quit: Nettalk6 - www.ntalk.de) |
01:30:40 | * | CryptoToad quit (Quit: Leaving) |
01:32:50 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
01:33:52 | * | bendiken joined #nim |
01:44:14 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
01:45:01 | * | bendiken joined #nim |
01:55:38 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
01:56:27 | * | bendiken joined #nim |
01:56:58 | * | yglukhov joined #nim |
02:01:05 | * | yglukhov quit (Ping timeout: 240 seconds) |
02:07:02 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
02:07:55 | * | bendiken joined #nim |
02:29:06 | * | bendiken quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
02:30:07 | * | bendiken joined #nim |
02:42:29 | * | darkf joined #nim |
02:42:46 | * | bendiken quit () |
03:27:24 | * | pregressive joined #nim |
03:51:31 | * | Demon_Fox joined #nim |
04:23:10 | * | porglezomp quit (Quit: Lost terminal) |
04:24:04 | * | pregressive quit (Ping timeout: 265 seconds) |
04:45:45 | * | yglukhov joined #nim |
04:50:05 | * | yglukhov quit (Ping timeout: 240 seconds) |
05:07:47 | * | Jesin quit (Quit: Leaving) |
05:43:17 | * | Demon_Fox quit (Quit: Leaving) |
06:12:56 | * | xcombelle joined #nim |
06:21:55 | * | shodan45 quit (Quit: Konversation terminated!) |
06:31:06 | * | yglukhov joined #nim |
06:35:34 | * | yglukhov quit (Ping timeout: 260 seconds) |
06:38:28 | * | yglukhov joined #nim |
06:44:30 | * | EXetoC joined #nim |
06:47:58 | * | strcmp1 quit (Quit: Leaving) |
06:54:55 | * | yglukhov_ joined #nim |
06:55:03 | federico3 | any way to perform readline from stdin with a timeout? |
06:56:33 | Varriount | federico3: Not cross-platform, built-in |
06:57:18 | federico3 | Linux-only? |
06:57:21 | Varriount | Windows has console functions for polling for keyboard input, *nix systems have select. |
06:57:46 | * | yglukhov quit (Ping timeout: 250 seconds) |
06:58:10 | Varriount | federico3: http://stackoverflow.com/questions/3711830/set-a-timeout-for-reading-stdin |
06:59:44 | Varriount | Araq: How would I create a TR expression that matches against all expressions consisting of procedure calls that take a single string argument and return a single string arguement? |
07:00:50 | Varriount | `{(procIdent1|procIdent2)** a` works, but only matches against procIdent1 and procIdent2 (which is to be expected) |
07:02:40 | * | jszymanski joined #nim |
07:06:10 | * | kilon joined #nim |
07:09:43 | * | Moix joined #nim |
07:19:02 | * | yglukhov_ quit (Remote host closed the connection) |
07:19:39 | * | yglukhov joined #nim |
07:29:18 | * | thekilon joined #nim |
07:36:26 | * | dalarmmst quit (Ping timeout: 240 seconds) |
07:39:09 | * | Trustable joined #nim |
07:40:16 | * | thekilon quit (Remote host closed the connection) |
07:49:29 | * | dalarmmst joined #nim |
07:54:12 | baabelfish | has anyone tried making immutable datastructures with nim yet? |
07:54:33 | baabelfish | ones that can be used in parallel environment |
07:55:52 | * | dalarmmst quit (Ping timeout: 244 seconds) |
07:57:50 | * | kilon quit () |
08:04:33 | * | coffeepot joined #nim |
08:15:40 | * | bjz joined #nim |
08:25:04 | Varriount | baabelfish: You there? |
08:25:54 | Varriount | baabelfish: I have a semi-working immutable string implementation on my laptop. |
08:27:24 | * | dalarmmst joined #nim |
08:28:18 | r-ku | isnt string immutable by default? |
08:28:26 | Varriount | r-ku: Uh, no. |
08:28:40 | Varriount | r-ku: A string is virtually the same as seq[char] |
08:29:29 | r-ku | i probably mixed it up with value vs reference semantics |
08:29:48 | Varriount | r-ku: Strings and sequences have copy-on-assignment behavior though, and many string procedures return copies. |
08:31:03 | * | xificurC joined #nim |
08:34:48 | * | Arrrr joined #nim |
08:38:10 | * | dalarmmst quit (Ping timeout: 240 seconds) |
08:45:26 | * | Gonzih joined #nim |
08:46:26 | * | bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
08:59:25 | * | xcombelle quit (Ping timeout: 240 seconds) |
09:05:36 | * | tmku quit (Ping timeout: 246 seconds) |
09:06:27 | Araq | Varriount: good question, not sure if that's supported |
09:06:53 | baabelfish | Varriount: here now |
09:07:39 | baabelfish | Varriount: nice |
09:08:10 | * | Gonzih quit (Ping timeout: 260 seconds) |
09:17:36 | * | MBot joined #nim |
09:21:02 | * | Moix quit (Ping timeout: 260 seconds) |
09:38:57 | * | Matthias247 joined #nim |
09:40:05 | * | jszymanski quit (Quit: computer sleeps...) |
09:55:52 | * | BitPuffin|osx quit (Ping timeout: 250 seconds) |
09:58:25 | gokr | There are few things I hate more than SSL certs |
10:03:23 | coffeepot | when you want to inline code very simple code, is there any functional difference between proc with {.inline.} and just replacing 'proc' with 'template'? |
10:03:53 | coffeepot | i guess scoping rules are different, right? |
10:04:30 | coffeepot | is it bad practice to template when you should be inlining? |
10:06:37 | coffeepot | i mean, is there anything I should know about the difference between these two routines? https://gist.github.com/coffeepots/8aa84ba8120d55730d46 |
10:08:49 | Arrrr | compiler may not inline the code with .inline., if im not mistaken |
10:09:45 | coffeepot | okay, is this because it knows when it's not advantageous to inline? |
10:10:35 | Arrrr | That's in theory the reason. But maybe you know better. |
10:10:54 | Arrrr | Anyway, for setups i would not care (unless it was just an example) |
10:13:03 | coffeepot | yes this is hardly a performance concern, although I only put it into a separate proc for readability as it's only called once. I like to know what's what with inlining though, because when I'm doing gamedev it may matter |
10:13:43 | coffeepot | i guess I can check the C source anyway to see what's happening |
10:14:33 | Arrrr | i think inline is passed to c compiler, so you will hardly see a thing. Like .noReturn. |
10:14:48 | coffeepot | ah ok, that makes sense |
10:17:00 | * | UberLambda joined #nim |
10:36:11 | * | xcombelle joined #nim |
10:37:34 | Araq | coffeepot: don't bother with it, compilers are good at inlining and we got whole-program-optimizations these days |
10:38:02 | coffeepot | dont bother with {.inline.}? |
10:40:23 | coffeepot | I have been looking at the C sources recently for my octrees and it's impressive how lean the code nim creates is - even in debug mode :) |
10:44:37 | * | irqpal joined #nim |
10:47:31 | baabelfish | Araq: does {.inline.} just add the inline keyword to C/C++ code? |
10:48:18 | Araq | well it also ensures that the C compiler *can* actually inline it |
10:49:46 | * | bjz joined #nim |
10:50:11 | * | dalarmmst joined #nim |
10:51:26 | baabelfish | One case where you need to inline is to get a function that returns a reference to a static variable inside it's own scope to work across translation units |
10:53:36 | * | johnsoft quit (Ping timeout: 244 seconds) |
10:54:13 | * | johnsoft joined #nim |
10:55:52 | * | Gonzih joined #nim |
10:57:24 | * | dalarmmst quit (Ping timeout: 264 seconds) |
10:59:26 | Arrrr | Man, deep copies in strings/seqs using just '=' is so dangerous. |
11:01:01 | EXetoC | yeah? |
11:02:21 | Arrrr | yeah |
11:05:15 | * | irqpal quit (Quit: Konversation terminated!) |
11:07:05 | * | bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
11:08:39 | Araq | Arrrr: why? |
11:10:23 | Arrrr | Because you start using nim thinking without a reason to think that seqs or strings will work different that in any other pl |
11:10:42 | Arrrr | and then this happens. |
11:11:57 | * | Gonzih quit (Ping timeout: 255 seconds) |
11:12:53 | Araq | where "any other pl" means "except C++"? |
11:14:04 | Araq | you can also program in Nim thinking that's actually consistent so '=' always copies, arrays and objects are copied on assignment too |
11:14:41 | Araq | which is btw why we copy strings and seqs. for consistency. |
11:17:27 | Arrrr | Is not a problem one you get used to it, but in the meantime you will forget it and do stupid things as i did, which means spending an hour finxing a thing i knew but did not recall when i wrote that line of code |
11:17:54 | coffeepot | Arrrr: what happened? |
11:18:25 | Arrrr | in C# for example, a list (which is the closer thing it has to nim's seq) this deep copy does not happen |
11:18:35 | Arrrr | Nothing, i forgot to shallow a thing |
11:18:51 | Arrrr | *closest |
11:18:56 | coffeepot | is ref seq[X] the same as C#? |
11:19:17 | Araq | C# has its own horror stories with structs not working properly as hash table values |
11:19:18 | coffeepot | or do you have to use that pragma to say it's shallow copy |
11:20:18 | * | Gonzih joined #nim |
11:20:26 | Arrrr | i suppose with ref seq you wouldn't have that problem. |
11:20:31 | Araq | btw I plan to map Nim's seqs and strings to std::vector and std::string |
11:23:24 | coffeepot | Araq: would this mean a change in the copy semantics of string and seq? |
11:23:47 | * | nevercast joined #nim |
11:23:50 | Araq | no, because Nim follows C++ in this aspect |
11:24:00 | coffeepot | :) |
11:24:09 | Araq | shallowCopy() and 'nil' will cause problems though |
11:24:14 | nevercast | What is the correct async networking API to be using at this point? |
11:24:28 | Araq | asyncdispatch |
11:24:39 | nevercast | How experimental is experimental ? |
11:24:43 | nevercast | fa |
11:24:53 | nevercast | s/fa// |
11:24:58 | Araq | the API is stable, dom96 is fleshing out more bugs though |
11:25:08 | Arrrr | why? i thought you had to use nil with shallowCopy |
11:25:25 | coffeepot | when you say "nil will cause problems" what do you mean? Is var: s going to default to "" instead of nil? |
11:25:44 | Araq | coffeepot: yes, something like that |
11:25:52 | coffeepot | ok |
11:26:53 | coffeepot | won't that break code that uses a nil string to assume 'no result' as opposed to 'empty result'? |
11:27:33 | coffeepot | not that I've ever done that myself |
11:27:36 | nevercast | What is the correct library to use to write out the binary representation of system types. Integers, Floating point. |
11:28:11 | coffeepot | nevercast: is the marshal module what you need maybe? |
11:28:41 | nevercast | coffeepot, that does sound like a good start, thank you. Can the endian be changed? |
11:28:55 | coffeepot | http://nim-lang.org/docs/marshal.html or if you just need to display the results use repr(X) |
11:29:11 | coffeepot | nevercast, sorry I don't know |
11:29:24 | nevercast | It uses JSON. Unfortunately not what I'm looking for. |
11:29:56 | EXetoC | there's this too http://nim-lang.org/docs/streams.html |
11:29:59 | Arrrr | streams maybe |
11:30:26 | Araq | coffeepot: yes, this idea needs more refinements :P |
11:31:00 | EXetoC | but nothing for controlling the endian yet |
11:31:11 | Araq | endians.nim? |
11:31:13 | nevercast | There is the endian lib which I can wrap it up |
11:32:56 | coffeepot | Araq: well if a string defaults to "", and a seq to @[], but people can still set them = nil or use {.noinit.} then it'll probably avoid a lot of segfaults for new nimsters but still allow you to use the nil pattern if you want |
11:33:07 | nevercast | I think endians and streams should do it. Using typed or "generic" procedures, are the invoked the way they look in the docs, write[float64](stream, 0)? |
11:33:13 | EXetoC | for streams |
11:33:26 | coffeepot | I guess though that it's more about the internal funcs handling nil (or not handling them) |
11:35:00 | EXetoC | nevercast: or use one of the concrete implementations |
11:35:12 | EXetoC | and the type parameter for 'write' will be inferred |
11:35:40 | Arrrr | Why doesn't nim intern strings? |
11:36:06 | nevercast | inferred is good, I don't see a concrete implementation if writeFloat64 is what you mean. |
11:37:02 | EXetoC | apparently not. it might be because of this whole float portability thing |
11:37:16 | * | Pisuke quit (Ping timeout: 246 seconds) |
11:37:26 | * | bogen left #nim (#nim) |
11:37:41 | nevercast | I also don't see wrappers for sockets -> stream. |
11:38:02 | nevercast | Perhaps it's not common to do that at a lower level. But I'm familiar with that kind of abstraction. |
11:38:44 | Arrrr | Use StringStream and get its internal buffer |
11:39:23 | Arrrr | net module uses string to send/receive stuff |
11:39:44 | EXetoC | well, it does abstract over byte buffers |
11:39:52 | Araq | Arrrr: what is the advantage of interning strings? |
11:40:21 | nevercast | Is strings the expected approach? It's a binary network stream. Network byte order. |
11:40:41 | EXetoC | yes that seems to be the convention |
11:41:06 | Arrrr | less memory used by strings. Not that i need it |
11:41:12 | EXetoC | it's just a little annoying when printing (compared to when using seq[int8]) |
11:41:38 | * | Rishavs joined #nim |
11:42:07 | nevercast | Feels unnatural to not use an array/sequence of int8 |
11:42:13 | nevercast | But if that's the expected impl. |
11:43:10 | Arrrr | I think it is safe to cast string to seq[int8] |
11:43:43 | * | dalarmmst joined #nim |
11:44:08 | * | bjz joined #nim |
11:47:57 | Arrrr | wut, try to execute this: |
11:48:02 | Arrrr | let a = cast[seq[int8]]("ABCDEF") |
11:48:17 | Arrrr | the compiler never finish |
11:48:31 | EXetoC | nevercast: I think so too when it involves things other than text |
11:49:10 | nevercast | EXetoC, It's great and all for Javascript as a backend. But not having a blob of bytes feels odd. |
11:49:17 | nevercast | Since Strings typically have encoding. |
11:49:21 | coffeepot | let a = cast[ptr array[0..len, int8]]("ABCDEF") probably |
11:49:52 | coffeepot | i guess seq has header info so casting directly might mean "A" gets taken as part of header? |
11:50:06 | EXetoC | but the length of an array is determined at compile time |
11:50:24 | coffeepot | yeah you got to use unchecked arrays if you actually need this |
11:50:29 | EXetoC | coffeepot: a string has a header too, but I don't know if there are any guarantees |
11:50:52 | nevercast | type missmatch there coffeepot. |
11:50:55 | coffeepot | yeah from what i recall, casting using string can get a bit funky too, which is why we have cstring |
11:51:00 | Araq | nevercast: 'string' is Nim's blob as far as I'm concerned |
11:51:25 | EXetoC | nevercast: "out of memory" for me |
11:51:28 | nevercast | Araq, no 'UTF-16' implementation in 'string', just blob? |
11:51:44 | EXetoC | coffeepot: I do prefer to use a reasonably high upper bound |
11:51:50 | Araq | lol UTF-16 |
11:51:56 | Araq | never gonna happen |
11:52:02 | Araq | it's stupid |
11:52:03 | nevercast | ^ I am okay with that. |
11:52:06 | r-ku | Araq you can lol at it as much as you want but for windows its mandatory |
11:52:24 | coffeepot | and sql server too, uses widestring |
11:52:27 | EXetoC | so as to catch mistakes |
11:52:46 | nevercast | widestring on SQL Server feels my network captures with horrible nulls. |
11:52:50 | nevercast | *fills. |
11:53:02 | coffeepot | nevercast, EXetoC how to cast to array with no compile time len https://gist.github.com/coffeepots/999a655ac1047b21fbe4 |
11:53:10 | r-ku | truth is there is no perfect encoding. therefore we need lots of encodings.. |
11:53:35 | * | dalarmmst quit (Ping timeout: 256 seconds) |
11:54:07 | nevercast | coffeepot, that looks good to me. But that is not going to play with sockets is it? |
11:54:34 | coffeepot | probably not, no, and it's more for buffers than working with strings really |
11:54:40 | Arrrr | Araq: this line of code never returns: 'let a = cast[seq[int8]]("ABCDEF")' |
11:54:43 | EXetoC | ranges like Natural go from 0 to int.high, but I often use more conservative ranges |
11:55:49 | * | dalarmmst joined #nim |
11:57:07 | Arrrr | It has something to do with the garbage collector |
11:58:40 | coffeepot | why do you need to cast to int8 anyway, can't you just go through the string and take each char, which is utf8 anyway? |
11:58:41 | nevercast | I guess I can asyncnet.recv -> Future[string] -> StringStream.write -> StringStream.read, though I suspect it'll use one pointer for both read and write so I might need to overload that. |
11:59:03 | nevercast | I don't want characters, I want integers. |
11:59:09 | nevercast | floats, int16, etc. |
11:59:57 | coffeepot | var |
11:59:58 | coffeepot | s = "ABCDEF" |
11:59:58 | coffeepot | for c in s: |
11:59:58 | coffeepot | echo c.int8 |
12:00:13 | coffeepot | for int16 you might need to cast tho :) |
12:00:21 | EXetoC | it's mostly necessary when printing aggregates though, which you sometimes do |
12:00:48 | nevercast | I'm unlikely to print binary (and likely gzip compressed) stream. But I do need to buffer without blocking. |
12:01:11 | nevercast | Not sure of the best way to go asyncnet -> streams. But streams does seem to provide all the read/write I'll need. |
12:01:15 | * | Gonzih quit (Ping timeout: 245 seconds) |
12:01:19 | EXetoC | then there's the case of inspecting the values at run-time, but then again it could just show you all the different representations |
12:01:31 | EXetoC | in the form of a table |
12:03:42 | coffeepot | https://gist.github.com/coffeepots/c88cdea439993710596e |
12:03:49 | EXetoC | nevercast: just pass the string to newStringStream; shallowly if needed |
12:04:26 | coffeepot | ^ for int16 chars |
12:04:29 | nevercast | if the string contains insufficient data ? (Since networking is just that reliable) |
12:04:51 | nevercast | It's not for int16 chars. Sorry. I don't mean characters. I mean numbers. binary encoding. |
12:05:01 | nevercast | Unless they are the same thing to nim. |
12:05:32 | Arrrr | then make sure string is big enought. Are you going to use tcp or udp ? |
12:05:38 | nevercast | tcp |
12:05:43 | coffeepot | the gist above will let you access them as int16 numbers, but you could cast them to int8 or byte |
12:05:48 | EXetoC | it's not only a question of reliability |
12:06:08 | Arrrr | Usually, if string is not big enough, you will need to make more reads, that's all |
12:06:13 | coffeepot | but nim doesn't care about encoding anyway, strings are basically seq[byte] |
12:06:38 | nevercast | any edge cases I should be aware of where they are not 'basically' seq[byte] ? |
12:06:38 | coffeepot | you can cast a char to byte IIRC |
12:06:41 | nevercast | If not I'll carry on. |
12:07:02 | coffeepot | nim char is utf8, but indexing is done by byte |
12:07:28 | coffeepot | so if you have a multi byte char, you can access it's bytes by index |
12:07:39 | EXetoC | but I don't see a problem. if you expect a header then you just need to attempt to read it after accumulating enough data |
12:07:50 | coffeepot | this means if you want to process multibyte utf8 chars, use the unicode module and the runes iterator |
12:08:11 | nevercast | There wont be any issues with strings. As strings will be length prefixed in the protocol |
12:08:13 | EXetoC | char? utf8? |
12:08:27 | coffeepot | char == utf8 IIRC |
12:08:43 | coffeepot | well char == byte really |
12:08:52 | nevercast | common cases are packets with structure: int, short, short, byte, long, long. |
12:09:02 | EXetoC | it's not utf8 at all |
12:09:17 | coffeepot | no, it's byte sorry |
12:09:19 | nevercast | utf8 is encoding. It has special 'values'. |
12:09:53 | nevercast | So long as string is basically byte[]. Then I see no issues using it as a binary blob object. |
12:10:08 | coffeepot | yes I believe it is just byte |
12:10:10 | nevercast | I can recv -> StringReader -> int64, without issues. |
12:10:42 | nevercast | It was an unexpected design decision to have strings represent what is effectively a byte array. |
12:10:50 | nevercast | (char is not equal to byte in many other languages either) |
12:10:56 | EXetoC | yep, random access and no encoding enforcement |
12:11:21 | Arrrr | But i think it was a good decission to make char 8 bits |
12:11:30 | coffeepot | i agree, char should == byte |
12:11:39 | nevercast | unlike other languages |
12:11:45 | * | nevercast looks at 16bit char in java |
12:11:49 | coffeepot | you can put unicode into strings though, you just process it differently |
12:11:53 | EXetoC | 16? -.- |
12:11:55 | Arrrr | haha, so true nevercast |
12:11:58 | nevercast | Yes. |
12:12:30 | EXetoC | now I'm even more eager to try java |
12:12:36 | Arrrr | But java is from the 90's, i think utf16 was hot in that time |
12:12:40 | nevercast | char should be implemented two ways, imho. encoding-less wrapper around byte/int8. |
12:12:46 | nevercast | Or a type that is full encoding supportive. |
12:13:01 | coffeepot | char is encodingless wrapper around byte/int8 in nim |
12:13:10 | nevercast | utf32 is a thing, a thing that a 16bit char wont handle. |
12:13:42 | nevercast | nim: char == int8 == byte |
12:13:45 | nevercast | acknowledged. |
12:13:51 | coffeepot | you stuff your utfX into a string and all is well, then you can access each byte by index, and to see the unicode you use the rune iterator |
12:14:10 | nevercast | disclaimer: there is no utfAnything in my project. |
12:14:21 | nevercast | It's encoding that I'm avoiding. |
12:15:08 | coffeepot | runes takes a string and returns Rune which is effectively utf32, and only moves forward by the number of bytes the unicode represents. So for a two byte char runes will move it's index along by two, if that makes sense |
12:15:31 | coffeepot | http://nim-lang.org/docs/unicode.html |
12:15:51 | nevercast | Thank you |
12:15:54 | nevercast | Though I do not need it :) |
12:16:01 | coffeepot | np :) |
12:16:20 | nevercast | I only need to be sure I can hold an array of encoded system types. integers of various bit length. |
12:17:33 | nevercast | sequence vs array, array is static length? sequences is dynamic expanding? |
12:17:41 | def- | nevercast: right |
12:17:42 | coffeepot | yep |
12:18:04 | nevercast | If so, is this implemented by reallocating new memory for the entire new size and copying the values over by pointer? |
12:18:16 | def- | right |
12:18:31 | def- | the values are copied over, but what do you mean with "by pointer"? |
12:18:33 | EXetoC | if there isn't enough capacity |
12:18:37 | nevercast | Is it best to over-allocate the sequence size if I expect it to grow in the near future |
12:19:01 | nevercast | def-, shallow copy perhaps you would call it, I would assume a sequence holds pointers. |
12:19:12 | nevercast | That is probably abstracted by nim's type system. |
12:19:34 | def- | nevercast: well, it's a trade-off between speed and size. if you know the size beforehand, it's of course much more efficient to set the length at the start instead of adding value by value |
12:19:37 | EXetoC | yes, but you still can't set the actual capacity |
12:19:42 | coffeepot | http://nim-lang.org/docs/system.html#newSeq,seq[T],Natural |
12:19:54 | Arrrr | nevercast: strings in nim have nothing to do with strings in java |
12:19:56 | EXetoC | will pre-allocating and then setting the length to 0 work? |
12:20:25 | def- | EXetoC: in my experience, yes |
12:20:34 | * | Pisuke joined #nim |
12:20:44 | nevercast | Arrrr, or any other language I assume. My understanding is that string is effectively a typedef of seq[int8] with helper procedures strapped to it. |
12:20:49 | EXetoC | that makes sense |
12:21:19 | Arrrr | they arent immutable, and when you assign strA to strB, you are actually making a deep copy |
12:21:21 | def- | nevercast: a sequence can hold pointers, but it can also hold actual objects |
12:21:47 | nevercast | def-, holding pointers sound less intensive during resize. |
12:21:54 | EXetoC | since the memory can be freed simply by getting rid of all references |
12:21:58 | nevercast | I'm assuming nim does not have virtual memory and has to alloc |
12:22:37 | def- | nevercast: maybe, but you have another level of indirection |
12:23:19 | nevercast | nim leaves me with an uneasy feeling of not fully managed and not fully unmanaged. I'll get used to it with experience. |
12:23:49 | coffeepot | tbh it's fully managed, the only time it's not is when you're fiddling with cast |
12:24:06 | nevercast | or using global memory for cross-thread data. |
12:24:11 | EXetoC | it's more flexible than in other languages, which can only be a good thing imo |
12:24:21 | coffeepot | yes or working across threads :) |
12:24:50 | EXetoC | and the ability to pre-allocate and control the GC at run-time further reduces the need to consider manual memory management |
12:25:01 | nevercast | If I want a background loader to pull in 200mb, I don't want to copy that across a channel, I'd like to leave that in the same place and pass a pointer to another thread. I assume the way to do that is to avoid the GC |
12:25:02 | coffeepot | var s: seq[MyObject] = @[]; s.add(ob1); s.add(ob2); s = nil # <- frees s |
12:25:12 | EXetoC | why did I join IRC again? >.< |
12:25:14 | coffeepot | and frees ob1 and ob2 if no other references |
12:26:34 | coffeepot | nevercast: I'd say you're right for cross threadding |
12:26:59 | nevercast | I am making the assumption that I should do it as described and there isn't a better practice |
12:28:30 | coffeepot | there is a lot of work going on to make cross threading stuff. We have channels and locks etc, but the GC isn't safe over threads. Someone more knowledgable can probably tell you more, but AFAIK if you don't want to copy, you'll need to alloc0 and pass pointers |
12:28:55 | coffeepot | and use locks for multi access |
12:29:06 | coffeepot | i don't know if anyone's ported a lock free seq yet? |
12:29:11 | nevercast | I don't mind managing my own memory for large blobs of data. It's often not runtime objects but external data that needs manual alloc |
12:30:02 | nevercast | The way I'll implement it is likely one thread has control of the data, but i'll have loaders/savers. Shouldn't need locks if done right. |
12:30:17 | nevercast | As when the loader has completed, it surrenders the pointer to another thread and forgets it. |
12:30:37 | coffeepot | yeah, and there's always interlockedExchange too if it comes to it |
12:31:39 | coffeepot | and you need a fast lock |
12:33:18 | nevercast | Not sure of the lock system yet so can't provide feedback. I would like to have a dispatch loop as my main thread. With threads equal to the other cores doing IO. |
12:33:50 | coffeepot | maybe you'd be interested in coroutines? I don't know if they're in devel yet |
12:34:16 | nevercast | async/await have a similar implementation to yield/resume |
12:34:24 | nevercast | At least by pattern, not sure about nim. |
12:35:11 | nevercast | async and await use a Task list and ThreadPool in .NET, coroutines in Lua work on one thread, events work on one thread in Node.JS |
12:35:17 | * | UberLambda quit (Ping timeout: 252 seconds) |
12:35:34 | coffeepot | yes, last time i asked the main difference is that coroutines allow complex nesting, but it's r-ku 's baby so if you're interested, he's the guy to ask |
12:35:38 | nevercast | It's likely any of those would work for my main thread. |
12:35:50 | nevercast | I'll investigate it :) |
12:35:58 | EXetoC | are iterators actually required to be implemented in the language now with the addition of coroutines? |
12:36:15 | nevercast | They would be implemented by effect. |
12:36:33 | nevercast | Since that's what coroutines do in effect. |
12:36:54 | EXetoC | what prevented a library implementation before was the absence of working traits (still broken) |
12:37:23 | nevercast | Was it intended to be cross-thread? |
12:37:39 | nevercast | As coroutines typically are not. They are single threads with an unwinding stack (Not recursive) |
12:38:04 | coffeepot | coroutines as single threaded I think |
12:39:22 | nevercast | Not overly difficult to implement. |
12:40:14 | nevercast | Though I'm not sure entirely how control switching is done |
12:40:24 | r-ku | setjmp/longjmp |
12:40:27 | nevercast | I would personally go look at Lua. I might do that. |
12:40:32 | nevercast | Oh.. |
12:40:40 | r-ku | check it out https://github.com/nim-lang/Nim/compare/devel...r-ku:coroutines |
12:40:42 | nevercast | Yeah.. you have a lovely time. |
12:41:15 | nevercast | That's quite the core change. |
12:41:25 | r-ku | not really... |
12:41:40 | r-ku | some gc code got moved around |
12:41:41 | EXetoC | is it actually regarded as iteration? |
12:41:48 | r-ku | only few gc functions needed change |
12:41:59 | nevercast | EXetoC, it would work as an enumerator if that is what you mean. |
12:42:25 | r-ku | this is what we basically needed to get coroutines to work https://github.com/nim-lang/Nim/compare/devel...r-ku:coroutines#diff-99d47b8f45928bcbfd50e23d140ac969R190 |
12:42:35 | r-ku | gc scanning stacks of each coroutine |
12:44:13 | nevercast | From the source I can read with accuracy it looks good |
12:44:26 | nevercast | I'm new to nim, but I can infer most of it. |
12:45:52 | r-ku | i bet Araq would love if someone else was testing it before PR is merged |
12:48:24 | EXetoC | nevercast: it does already |
12:48:47 | EXetoC | it's just a logical extension then |
12:49:09 | nevercast | EXetoC, as far as I understand it, yes. |
12:49:33 | nevercast | r-ku, Not sure what help I can be but if you need some test code I can probably do that. |
12:49:55 | * | saml_ joined #nim |
12:49:58 | nevercast | I started on nim 3 days ago though. I'm familiar with many other languages but there is the initial language barrier |
12:50:34 | * | infinity0 quit (Ping timeout: 260 seconds) |
12:51:19 | EXetoC | I wonder if a language implementation will still be possible |
12:51:24 | EXetoC | *library |
12:52:25 | r-ku | nevercast i got an impression you are looking for something like coroutines for whatever you are doing. so i just hoped you could pick that code up and use for whatever you need |
12:53:48 | EXetoC | it would only serve as a good example of the language capabilities |
12:54:01 | * | dddddd joined #nim |
12:54:27 | nevercast | r-ku, I want a main loop that takes events from IO works. Spreading the load over cores. I intend to be running this from my UDOO (armv7), which is a quad core, and save/load to the Flash/Sata should be on one core, networking on another |
12:54:35 | nevercast | s/works/workers/ |
12:55:24 | * | infinity0 joined #nim |
12:56:04 | r-ku | you can run coroutine loop on each core but coroutines themselves would have to be manually balanced between those main loops. its not a ready solution though. as you can see would require some manual implementing of things |
12:56:15 | r-ku | some higher level scheduler.. |
12:56:27 | nevercast | That's not an issue |
12:56:33 | nevercast | If the yield and resume work. |
12:56:36 | nevercast | A scheduler is fine. |
12:57:10 | nevercast | coroutines could actually be used for things such as alternative future/promises implementations. |
12:57:14 | nevercast | I'll find something. |
12:57:28 | r-ku | sure that works. sleep works. scheduler uses os.sleep() to skip some time until next closest coroutine run in that particular scheduler. so it doesnt eat 100% of cpu either |
12:57:49 | r-ku | yeah Araq expressed desire to rebase async on new coroutines |
12:57:57 | nevercast | It uses round-robin at the moment I guess. |
12:57:59 | r-ku | but thats probably not a close future |
12:58:21 | r-ku | something like it. it takes into account coroutine sleep time too |
12:58:47 | r-ku | so they can get bit "reordered |
12:58:48 | r-ku | " |
12:59:18 | nevercast | does sleep actually call os.sleep, or does sleep yield ? |
12:59:30 | nevercast | if sleep yields, you can run another coroutine w |
12:59:55 | * | nevercast quit (Read error: Connection reset by peer) |
13:01:19 | * | nevercast-mobile joined #nim |
13:01:27 | r-ku | you basically do coroYield(<sleep_time>). that coroutine is guaranteed not to resume before <sleep_time> seconds pass. scheduler checks sleep times of all coroutines and if there is no coroutine to run at that time it does os.sleep() |
13:01:54 | nevercast-mobile | Did I miss a thing since my last message? Computer abruptly quit for forced updates. |
13:02:01 | r-ku | nop |
13:02:22 | nevercast-mobile | Schedule sounds like the expected implementation. |
13:02:38 | nevercast-mobile | os.sleep for min time till next coroutine? |
13:02:52 | * | yglukhov_ joined #nim |
13:03:08 | r-ku | exactly |
13:03:23 | r-ku | you are better at putting it to words than i am hehe |
13:03:59 | nevercast-mobile | Coroutines sound good. Can probably build event system on this. |
13:04:23 | nevercast-mobile | yield can pass parameters and resume can pass result to yield? |
13:04:54 | r-ku | that i did not implement but it should not be too hard |
13:05:07 | r-ku | after all yield is already passing one value to scheduler - sleep time. |
13:05:27 | nevercast-mobile | Yes. Good. Best way to implement I think |
13:05:39 | nevercast-mobile | Makes sleeping and yielding use the same "pipeline" |
13:05:46 | * | yglukhov quit (Ping timeout: 240 seconds) |
13:06:26 | EXetoC | r-ku: do you think a library implementation of coroutines would be possible? |
13:06:48 | r-ku | EXetoC nope. they require gc patch |
13:07:07 | * | dddddd quit (Ping timeout: 260 seconds) |
13:07:43 | r-ku | well.. actually we could get away only by merging required gc bits to compiler and exposing required api for coroutines. then they could be separate lib |
13:07:52 | r-ku | but it still requires compiler modification |
13:10:00 | nevercast-mobile | Work in 5 hours. Should sleep now. I'll look at coro later tonight r-ku. Thanks for help @#nim. |
13:10:14 | EXetoC | please come again! |
13:10:30 | nevercast-mobile | Thank you. I shall. |
13:10:37 | r-ku | thanks for having an interest. good night ;) |
13:10:47 | coffeepot | you're project sounds interesting nevercast - may ye fair well :) |
13:11:17 | Arrrr | What is he trying to do? |
13:11:43 | r-ku | [15:54:28] <nevercast> r-ku, I want a main loop that takes events from IO works. Spreading the load over cores. I intend to be running this from my UDOO (armv7), which is a quad core, and save/load to the Flash/Sata should be on one core, networking on another |
13:11:43 | r-ku | [15:54:35] <nevercast> s/works/workers/ |
13:12:26 | Arrrr | thank you based r-ku |
13:12:30 | * | jszymanski joined #nim |
13:14:31 | * | xcombelle quit (Ping timeout: 252 seconds) |
13:15:19 | Varriount | Araq: Well, it would be a nice feature. That way this string optimization could be available to procedures other than the ones in strutils |
13:22:15 | * | saml_ quit (Ping timeout: 250 seconds) |
13:24:57 | * | UberLambda joined #nim |
13:29:27 | * | Rishavs quit (Ping timeout: 246 seconds) |
13:51:40 | * | yglukhov_ quit (Remote host closed the connection) |
13:52:10 | * | BitPuffin joined #nim |
13:52:14 | * | yglukhov joined #nim |
14:03:19 | * | Demos joined #nim |
14:21:12 | * | darkf_ joined #nim |
14:24:06 | * | darkf quit (Ping timeout: 246 seconds) |
14:25:14 | * | NimBot joined #nim |
14:25:59 | * | gunn quit (Ping timeout: 260 seconds) |
14:30:52 | * | pregressive joined #nim |
14:39:05 | * | kilon joined #nim |
14:39:05 | * | kilon quit (Changing host) |
14:39:05 | * | kilon joined #nim |
14:39:18 | * | Demos quit (Remote host closed the connection) |
14:43:27 | * | Demos joined #nim |
14:50:39 | Araq | Varriount: you could also simply add an optimization pass to the compiler |
14:54:49 | * | Demos quit (Remote host closed the connection) |
14:56:04 | * | Demos joined #nim |
14:58:03 | * | BitPuffin quit (Ping timeout: 246 seconds) |
14:59:12 | * | Gonzih joined #nim |
15:01:03 | * | NimBot joined #nim |
15:02:17 | * | Demos quit (Remote host closed the connection) |
15:04:04 | * | pregressive quit (Remote host closed the connection) |
15:04:16 | * | pregressive joined #nim |
15:11:33 | * | Demos joined #nim |
15:16:15 | * | NimBot joined #nim |
15:16:34 | * | Gonzih quit (Ping timeout: 265 seconds) |
15:27:16 | * | BitPuffin joined #nim |
15:36:55 | * | Demos quit (Remote host closed the connection) |
15:39:55 | * | MBot quit (Quit: Saliendo) |
15:39:55 | * | Demos joined #nim |
15:42:26 | * | thekilon joined #nim |
15:43:25 | * | Demos quit (Remote host closed the connection) |
15:44:11 | * | thekilon quit (Remote host closed the connection) |
15:44:42 | * | yglukhov quit (Remote host closed the connection) |
15:45:08 | * | Demos joined #nim |
15:57:23 | * | Matthias247 quit (Read error: Connection reset by peer) |
16:01:41 | * | darkf_ quit (Quit: Leaving) |
16:05:12 | * | jszymanski quit (Quit: computer sleeps...) |
16:07:28 | * | yglukhov joined #nim |
16:09:08 | * | coffeepot quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
16:11:41 | * | yglukhov quit (Ping timeout: 250 seconds) |
16:15:10 | * | Gonzih joined #nim |
16:21:07 | * | NimBot joined #nim |
16:26:15 | * | Gonzih quit (Ping timeout: 246 seconds) |
16:27:15 | Araq | r-ku: what testing did you do for your PR? |
16:40:45 | * | FedeOmoto joined #nim |
16:41:10 | * | Arrrr quit (Quit: WeeChat 1.2) |
16:44:42 | dom96 | Araq: please let me test it first |
16:48:02 | * | yglukhov joined #nim |
16:49:57 | * | yglukhov quit (Remote host closed the connection) |
16:52:44 | * | Demos quit (Remote host closed the connection) |
16:54:09 | * | Demos joined #nim |
17:03:44 | * | yglukhov joined #nim |
17:05:18 | * | NimBot joined #nim |
17:07:02 | * | Demos quit (Remote host closed the connection) |
17:07:27 | * | johnsoft quit (Ping timeout: 255 seconds) |
17:08:19 | * | NimBot joined #nim |
17:09:57 | * | Demos quit (Remote host closed the connection) |
17:12:02 | * | Demos joined #nim |
17:13:51 | * | Demos quit (Remote host closed the connection) |
17:15:01 | * | Gonzih joined #nim |
17:15:17 | * | Demos joined #nim |
17:21:11 | * | Demos quit (Remote host closed the connection) |
17:21:37 | * | Demos joined #nim |
17:23:57 | * | Demos quit (Remote host closed the connection) |
17:25:34 | * | Demos joined #nim |
17:29:16 | * | pregressive quit (Remote host closed the connection) |
17:31:30 | * | Demos quit (Remote host closed the connection) |
17:31:49 | * | Demos joined #nim |
17:37:33 | * | X67r joined #nim |
17:38:12 | * | brson joined #nim |
17:39:04 | * | NimBot joined #nim |
17:39:54 | * | CryptoToad joined #nim |
17:40:33 | * | Demos quit (Remote host closed the connection) |
17:40:59 | * | NimBot joined #nim |
17:41:16 | * | Demos joined #nim |
17:45:32 | * | Moix joined #nim |
17:46:01 | * | Moix left #nim (#nim) |
17:48:04 | * | Demos quit (Remote host closed the connection) |
17:50:12 | * | Demos joined #nim |
17:55:12 | * | strcmp1 joined #nim |
17:56:54 | * | Demos quit (Remote host closed the connection) |
17:57:16 | * | Demos joined #nim |
17:58:05 | * | jszymanski joined #nim |
17:59:31 | * | Demos quit (Remote host closed the connection) |
18:02:13 | * | Demos joined #nim |
18:04:36 | * | silven quit (Ping timeout: 264 seconds) |
18:04:55 | * | silven joined #nim |
18:07:10 | * | Gonzih quit (Ping timeout: 240 seconds) |
18:09:15 | * | elbow_jason joined #nim |
18:12:49 | * | xcombelle joined #nim |
18:16:04 | * | rollo joined #nim |
18:22:19 | * | Demos quit (Remote host closed the connection) |
18:31:45 | * | NimBot joined #nim |
18:32:50 | * | UberLambda quit (Ping timeout: 250 seconds) |
18:33:57 | * | pregressive joined #nim |
18:37:36 | * | Sahnvour joined #nim |
18:42:26 | * | BitPuffin quit (Ping timeout: 260 seconds) |
18:45:35 | * | xcombelle quit (Remote host closed the connection) |
18:51:48 | * | yglukhov quit (Remote host closed the connection) |
18:53:14 | * | yglukhov joined #nim |
18:56:20 | * | NimBot joined #nim |
18:57:50 | * | nevercast-mobile quit (Ping timeout: 240 seconds) |
18:58:01 | * | nevercast-mobile joined #nim |
18:59:11 | * | NimBot joined #nim |
19:03:24 | * | nevercast-mobile quit (Ping timeout: 244 seconds) |
19:03:52 | * | Demos joined #nim |
19:04:42 | * | X67r quit (Ping timeout: 265 seconds) |
19:07:49 | * | rollo quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
19:11:44 | * | X67r joined #nim |
19:19:01 | * | NimBot joined #nim |
19:28:00 | * | yglukhov quit (Remote host closed the connection) |
19:28:19 | * | yglukhov joined #nim |
19:34:01 | * | yglukhov quit (Remote host closed the connection) |
19:34:15 | * | yglukhov joined #nim |
19:36:32 | * | yglukhov quit (Remote host closed the connection) |
19:44:29 | * | yglukhov joined #nim |
19:54:01 | * | Demos quit (Remote host closed the connection) |
19:57:07 | * | Demos joined #nim |
19:58:58 | * | Kingsquee quit (Ping timeout: 260 seconds) |
20:15:29 | * | Matthias247 joined #nim |
20:20:32 | * | Demos quit (Remote host closed the connection) |
20:26:31 | * | Demos joined #nim |
20:28:15 | * | Demos quit (Remote host closed the connection) |
20:28:39 | * | Demos joined #nim |
20:33:35 | * | key_ quit (Quit: Konversation terminated!) |
20:38:19 | * | kilon quit () |
20:41:34 | * | Demos quit (Remote host closed the connection) |
20:47:00 | * | Demos joined #nim |
20:49:23 | * | Demos quit (Remote host closed the connection) |
20:49:38 | * | Demos joined #nim |
20:52:59 | * | Demos quit (Remote host closed the connection) |
20:53:12 | * | CryptoToad quit (Ping timeout: 264 seconds) |
20:53:49 | * | CryptoToad joined #nim |
20:54:02 | * | jszymanski quit (Quit: computer sleeps...) |
20:56:00 | * | Demos joined #nim |
20:58:43 | * | Demos quit (Remote host closed the connection) |
21:06:01 | * | xificurC quit (Ping timeout: 246 seconds) |
21:15:36 | * | Trustable quit (Quit: Leaving) |
21:17:47 | * | Demos joined #nim |
21:19:44 | * | NimBot joined #nim |
21:23:30 | * | Demos quit (Remote host closed the connection) |
21:24:05 | * | johnsoft joined #nim |
21:26:50 | * | NimBot joined #nim |
21:29:33 | * | Demos joined #nim |
21:31:26 | * | wuehlmaus joined #nim |
21:33:34 | * | Demos quit (Remote host closed the connection) |
21:34:25 | * | gokr quit (Ping timeout: 256 seconds) |
21:37:26 | * | NimBot joined #nim |
21:38:00 | * | gokr joined #nim |
21:39:07 | * | Jehan_ joined #nim |
21:43:35 | * | xet7 quit (Quit: AndroIRC - Android IRC Client ( http://www.androirc.com )) |
21:44:58 | * | pregressive quit (Remote host closed the connection) |
21:51:18 | * | Demos joined #nim |
21:55:23 | * | yglukhov quit (Remote host closed the connection) |
21:56:26 | * | Demos_ joined #nim |
22:00:58 | * | yglukhov joined #nim |
22:05:44 | * | yglukhov quit (Ping timeout: 272 seconds) |
22:05:45 | * | EXetoC quit (Ping timeout: 246 seconds) |
22:07:04 | * | NimBot joined #nim |
22:20:22 | * | MyMind joined #nim |
22:20:36 | * | BitPuffin|osx joined #nim |
22:20:59 | * | Sahnvour quit (Read error: Connection reset by peer) |
22:21:16 | * | X67r quit (Quit: leaving) |
22:22:55 | * | Pisuke quit (Ping timeout: 245 seconds) |
22:27:48 | * | NimBot joined #nim |
22:36:37 | * | NimBot joined #nim |
22:38:29 | * | Demos_ quit (Remote host closed the connection) |
22:38:45 | Demos | is oldwinapi depricated? |
22:39:16 | * | Demos_ joined #nim |
22:39:51 | * | Demos_ quit (Remote host closed the connection) |
22:41:26 | * | bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
22:45:21 | Araq | Demos: no, just old |
22:45:36 | Araq | since the new wrapper doesn't exist yet |
22:45:42 | Demos | OK |
22:45:43 | Araq | Varriount? |
22:45:51 | Demos | nobody likes windows.h |
22:45:52 | * | Kingsquee joined #nim |
22:45:54 | Demos | it's a blight |
22:59:34 | * | Kingsquee quit (Read error: Connection reset by peer) |
22:59:39 | * | CryptoToad quit (Read error: No route to host) |
22:59:42 | * | Kingsquee joined #nim |
23:08:49 | * | Demos_ joined #nim |
23:09:35 | * | silven quit (Ping timeout: 260 seconds) |
23:09:50 | * | NimBot joined #nim |
23:09:54 | * | silven joined #nim |
23:12:44 | * | Raimondi quit (Quit: The road to wisdom?—Well, it's plain and simple to express: Err and err and err again, but less and less and less. — Piet Hein) |
23:13:07 | * | Raimondi joined #nim |
23:18:44 | * | Demos_ quit (Remote host closed the connection) |
23:38:43 | * | Pisuke joined #nim |
23:38:48 | * | MyMind quit (Ping timeout: 264 seconds) |
23:43:05 | * | Jehan_ quit (Quit: Leaving) |
23:54:51 | Demos | hm that bug where types in type sections can't depend on each other if the type section is over 500ish lines is still around |