<< 21-03-2015 >>

00:00:15fowl.eval import macros; macro x(s:stmt):stmt = echo(toStrLit(x)); x(1)
00:00:16Mimbusfowl: eval.nim(4, 37) Error: recursive dependency: 'x'
00:00:21fowl.eval import macros; macro x(s:stmt):stmt = echo(toStrLit(x));x(1)
00:00:22Mimbusfowl: eval.nim(4, 37) Error: recursive dependency: 'x'
00:00:25dom96zipR4ND: great. let me know if you have any other questions.
00:00:54*davidhq joined #nim
00:01:44EXetoCfowl: I just wanted to fix this code https://github.com/Araq/Nim/issues/2373
00:01:54EXetoCok :p
00:05:14*davidhq quit (Ping timeout: 246 seconds)
00:06:56fowlEXetoC, he can fix it by making it take string{lit}
00:08:00EXetoCyeah
00:10:09onionhammerhola
00:10:11onionhammerwhats up
00:11:46*mwbrown joined #nim
00:12:24*TEttinger joined #nim
00:17:51brsonAraq: what are you refering to?
00:20:27*davidhq joined #nim
00:25:06fowlCryptoToad, hey try changing the first if clause in that function to use == 0 intead of "not x > 0"
00:27:25CryptoToadlol just realized how dirty that was, but it's still doing the same thing
00:28:00CryptoToadi'm wondering if ms code is just outdated
00:28:01*brson quit (Ping timeout: 255 seconds)
00:28:03fowlwhat is it doing
00:28:08CryptoToadi added the console output
00:28:11CryptoToadin the hastebin
00:28:20CryptoToadsee "Err!: @["
00:28:36CryptoToadwhere @[ is szProcessName
00:28:47CryptoToadthe getModuleBaseName function
00:28:57CryptoToadshould set szProcessName to the process name
00:29:05CryptoToadbut i'm messing it up somehow
00:29:14CryptoToadcause it's returning false
00:29:20fowlCryptoToad, get rid of cast[bool], cast[dword]
00:29:36CryptoToadwhich ones? i use a lot of em
00:29:38fowluse bool(), dword() type conversions
00:29:41CryptoToadooohhh
00:30:40fowl Error: undeclared identifier: 'closeHandle'
00:30:55CryptoToadyeah i commented that for now
00:31:12CryptoToadoh
00:31:13CryptoToadwow
00:31:14CryptoToadit works
00:31:14CryptoToadnow
00:31:19CryptoToadjust that type conversion issue
00:31:21CryptoToad:O
00:31:47fowli got it working
00:31:48CryptoToadthanks fowl
00:31:52fowloh i see you did too
00:32:03CryptoToad:)
00:32:06fowlCryptoToad, so only use cast[] when ptr is involved
00:32:14CryptoToador if it's a weird type?
00:32:20CryptoToador should all types have
00:32:29fowlweird how?
00:32:29CryptoToadthe type() conversion proc
00:32:46CryptoToadlike imported from c or something
00:33:16fowlah um with c we mainly run into this with the billions of different int types involved
00:33:23CryptoToadlol
00:33:34CryptoToadyeah, seems a bit silly to complicate it
00:33:39CryptoToadjust let me pass an int xD
00:33:47EXetoCyou might accidentally cast a 32-bit value to a 64-bit value for example
00:35:14fowlCryptoToad, should be CloseHandle() btw
00:35:43*rzzz joined #nim
00:36:02fowlCryptoToad, and to convert that array of characters to a string its just $szProcessName
00:38:41*pregressive quit (Remote host closed the connection)
00:39:28CryptoToadyeah lol i know it is, i think i was just trying to do things until something worked
00:39:49CryptoToadprints fine without the $ though
00:40:02CryptoToaddoes echo convert to a string?
00:40:21fowlyea
00:40:34fowlecho(varargs[string, `$`]) means it applies $ to every arg
00:40:35EXetoCecho(varargs[`$`, T])
00:40:39*Matthias247 quit (Read error: Connection reset by peer)
00:40:43CryptoToadahh
00:40:46EXetoCdamn, so close!
00:40:49CryptoToadlol nice try
00:40:50CryptoToad:P
00:40:52EXetoCwait
00:41:05EXetoCdetails
00:41:43fowlbbl food
00:45:49CryptoToadexetoc how long have you been coding nim?
00:48:18EXetoCsince early 2013
00:51:57CryptoToadahh nice
00:52:56*CryptoToad quit (Quit: Leaving)
00:56:46TrustableHi all, does anyone know, if someone tried to make Geany compatible to Nim?
01:07:10*saml_ joined #nim
01:09:24*zipR4ND quit (Ping timeout: 245 seconds)
01:10:56EXetoCTrustable: I only know of that PR from 2013 mentioned on the wiki, which remains open
01:11:41TrustableEXetoC: What was that PR about?
01:15:28EXetoCTrustable: for adding nim support to geany
01:16:27TrustableEXetoC: ok, I guess it is about the filename:line:column format of the compiler output
01:17:14TrustableEXetoC: But I would like to add a lexer for Nim to Scintilla (which is used by Geany)
01:19:23TrustableEXetoC: Sorry, I missread you.
01:20:27TrustableI found something interesting here: https://github.com/geany/geany/pull/193
01:20:45*akiradeveloper quit (Remote host closed the connection)
01:20:58TrustableEXetoC: thanks for the hint
01:23:51EXetoCyes that one
01:26:52*davidhq quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
01:32:29*akiradeveloper joined #nim
01:35:03*davidhq joined #nim
01:36:08*nuew joined #nim
01:36:32nuewHello - I'm trying to use the events module, but can't figure out how to pass arguments.
01:36:58nuewI've sub-classed EventArgs
01:37:29nuewbut taking EventArgs as the argument results in nothing
01:38:12nuewswitching the argument to StringArgs (the name of the subclass) makes the proc say it can't be called
01:39:03nuewand switching the proc to a method says that it expected an expression.
01:39:22nuewThanks in advance for the help.
01:53:36*darkf joined #nim
01:53:58EXetoCcare to upload the code to gist or something?
01:54:29EXetoCnuew: I haven't used that module yet so I don't know what you're referring to
01:54:40nuewsure
01:55:46EXetoCwhat do you intend to use it for?
01:55:49*Trustable quit (Remote host closed the connection)
02:01:03nuewHere are some examples: http://pastebin.com/swtZLvWW
02:01:16nuewUsing it for a basic event/callback system in a game
02:05:25EXetoCEventArgs does not have such a field, and so you must cast it (cast[Type](var))
02:06:02nuewok thanks
02:06:53*davidhq quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
02:10:13EXetoCnuew: and you can't substitute the class type with the type of one of the children
02:10:35nuewi knew that, but I was hoping it would work ;)
02:12:34EXetoCand it takes a proc so a method can't be used there. not that it works. you could implement your own methods on top
02:13:02nuewhuh... gcc is now complaining: error: conversion to non-scalar type requested pushstring_159662((*HEX3Aenvp_176530).Lua176271, ((stringargs172009) ((*e))).X);
02:13:20*gokr quit (Quit: Leaving.)
02:13:39EXetoCyou can extend EventArgs if you want, or you could have your own "base" class with methods
02:13:45nuewok
02:14:00EXetoCthat's a bug. I'll see if there are bug reports that might be relevant
02:14:29nuewi guess i'm just going to reimplement the thing
02:14:51EXetoCnope. please report that.
02:15:45nuewI mean as well
02:24:44nuewreported: https://github.com/Araq/Nim/issues/2375
02:25:26EXetoCthanks
02:26:34EXetoC-d:release rarely needs to be used
02:28:23EXetoCyou can use ```nim\n...``` to highlight nim code
02:28:25*reem quit (Remote host closed the connection)
02:29:18nuewthat's on the compiler
02:29:22nuewnot the build
02:29:59*reem joined #nim
02:31:23EXetoCright
02:38:27fowldont cast
02:38:43fowltype conversion
02:39:01fowlStringArgs(e).x
02:40:50*Varriount quit (Read error: Connection reset by peer)
02:41:30fowlnuew, it works for me with the type conversion ^
02:41:48fowlEXetoC, stop telling people to use cast>_>
02:42:23nuewthansk
02:42:31nuewI swear I tried that.
02:43:01nuewbut it woks
02:43:05fowlmhm :p
02:43:05nuew*works
02:44:16*reem quit (Remote host closed the connection)
02:45:10EXetoCfowl: I recently adviced it needlessly?
02:46:26EXetoCI know I did advice against it today
02:46:35fowlyes you drunk
02:46:39*mwbrown quit (Ping timeout: 252 seconds)
02:46:41fowllol
02:46:42fowl<EXetoC> EventArgs does not have such a field, and so you must cast it (cast[Type](var))
02:47:03EXetoCother than then obviously :p
02:51:18EXetoCI have done it before regardless. I'll write it down
02:53:27*bcinman joined #nim
02:55:21fowlgood write it on the back of your hand D:
02:58:11EXetoCyeah why not. nothing else is written there
03:07:28*reem joined #nim
03:07:29*akiradeveloper quit (Read error: Connection reset by peer)
03:13:31*reem quit (Remote host closed the connection)
03:31:23*akiradeveloper joined #nim
03:44:31*brson joined #nim
03:45:14*reem joined #nim
03:55:32*vendethiel quit (Ping timeout: 246 seconds)
03:58:48*vendethiel joined #nim
04:02:49*xtagon joined #nim
04:04:38*kjo quit (Quit: Leaving.)
04:05:07*kjo joined #nim
04:07:20*kjo quit (Client Quit)
04:10:38*xtagon quit (Quit: Leaving)
04:13:54*xtagon joined #nim
04:17:02*epichero quit (Remote host closed the connection)
04:17:18*epichero joined #nim
04:21:12*vendethiel quit (Ping timeout: 272 seconds)
04:23:55*brson quit (Quit: leaving)
04:25:15*vendethiel joined #nim
04:33:19*johnsoft quit (Ping timeout: 256 seconds)
04:50:55*saml_ quit (Quit: Leaving)
05:11:08*pleiosaur joined #nim
05:18:16*Woflox quit (Ping timeout: 255 seconds)
05:31:17*vendethiel quit (Ping timeout: 252 seconds)
05:39:21*vendethiel joined #nim
05:42:28*filwit quit (Quit: Leaving)
06:19:46*xtagon quit (Read error: Connection reset by peer)
06:25:33*vendethiel quit (Ping timeout: 252 seconds)
06:26:14*vendethiel joined #nim
06:44:23*reem quit (Remote host closed the connection)
06:45:46*reem_ joined #nim
06:47:05*vendethiel quit (Ping timeout: 244 seconds)
06:48:22*brononymous joined #nim
06:50:50*brononymous left #nim (#nim)
06:51:15*vendethiel joined #nim
06:52:02*fluoride joined #nim
07:08:23*fluoride quit (Ping timeout: 246 seconds)
07:49:46*johnsoft joined #nim
07:56:23*akiradeveloper quit (Remote host closed the connection)
07:57:03*akiradeveloper joined #nim
08:13:22*akiradeveloper quit (Remote host closed the connection)
08:13:55*akiradeveloper joined #nim
08:18:01*akiradeveloper quit (Ping timeout: 244 seconds)
08:19:15*rzzz quit (Ping timeout: 250 seconds)
08:23:46*vendethiel quit (Ping timeout: 272 seconds)
08:26:20*reem_ quit (Read error: Connection reset by peer)
08:26:49*vendethiel joined #nim
08:30:06*reem joined #nim
08:35:49*milosn quit (Ping timeout: 264 seconds)
08:37:39*milosn joined #nim
08:38:09*nuew quit (Remote host closed the connection)
08:45:20*rzzz joined #nim
08:49:39*rzzz quit (Ping timeout: 252 seconds)
08:58:26*reem quit (Remote host closed the connection)
08:58:31*dtscode quit (Ping timeout: 256 seconds)
08:59:00*reem joined #nim
09:03:34*reem quit (Ping timeout: 265 seconds)
09:06:00*BlaXpirit joined #nim
09:07:33*gokr joined #nim
09:07:33*gokr quit (Read error: Connection reset by peer)
09:07:57*gokr joined #nim
09:09:26*akiradeveloper joined #nim
09:10:41*akiradeveloper quit (Remote host closed the connection)
09:11:49*vendethiel quit (Ping timeout: 255 seconds)
09:13:49*akiradeveloper joined #nim
09:15:22*rzzz joined #nim
09:16:01*TEttinger quit (Ping timeout: 250 seconds)
09:19:57*Matthias247 joined #nim
09:21:27*rzzz quit (Ping timeout: 265 seconds)
09:23:04*reem joined #nim
09:27:37*vendethiel joined #nim
09:30:33*BlaXpirit-UA joined #nim
09:33:17*BlaXpirit quit (Ping timeout: 246 seconds)
09:39:48*epichero quit (Remote host closed the connection)
09:47:08*epichero joined #nim
09:50:30*vendethiel quit (Ping timeout: 244 seconds)
09:52:26*epichero quit (Ping timeout: 272 seconds)
09:55:18*vendethiel joined #nim
10:12:15*epichero joined #nim
10:13:15*HakanD joined #nim
10:15:22*rzzz joined #nim
10:20:25*rzzz quit (Ping timeout: 265 seconds)
10:21:49*akiradeveloper quit (Remote host closed the connection)
10:22:47*bcinman quit (Quit: My Mac has gone to sleep. ZZZzzz…)
10:24:18*akiradeveloper joined #nim
10:30:36*HakanD quit (Quit: Be back later ...)
10:34:08*HakanD joined #nim
10:36:11*TEttinger joined #nim
10:53:00*johnsoft quit (Ping timeout: 252 seconds)
10:53:52*johnsoft joined #nim
10:55:46flyxmorning folks. I have a macro taking a "params: varargs[expr]". now the compiler complains that it cannot evaluate len(params) at compile time. I don't really see why not.
10:57:25*TEttinger quit (Ping timeout: 264 seconds)
10:58:27flyxah, forget it, I see the problem
11:01:52flyxI wish I could use openarray as non-parameter type
11:10:05*Ven joined #nim
11:15:21*rzzz joined #nim
11:20:08*rzzz quit (Ping timeout: 264 seconds)
11:21:48flyxso, when I have a "param: varargs[…]", how would I construct an array that has a length of len(param) + 1?
11:22:29flyxarray[len(param) + 1, …] doesn't work because len(param) is not static, and I don't see another method to do it
11:40:04*BlaXpirit-UA quit (Remote host closed the connection)
11:41:53*BlaXpirit joined #nim
11:42:40*epichero quit ()
11:43:04*HakanD quit (Quit: Be back later ...)
11:45:01BlaXpiritflyx, exactly, it is not static
11:45:05BlaXpiritso it is impossible
11:45:20BlaXpirithow do you expect to create a type based on a runtime value?
11:45:35flyxwell, it works in Ada
11:45:42flyxso it's possible
11:45:52BlaXpirit-_-
11:45:59BlaXpirityou're definitely confusing something
11:46:05BlaXpirithow about u explain what u want
11:46:57flyxI have a proc taking a varargs[…] param, and inside it, I want to call another proc taking a varargs[…] param, but I want to add one value to the varargs when calling it
11:48:33flyxI would use a seq, but the varargs param doesn't take a seq
11:49:21BlaXpirit.eval proc f(a: varargs[int]) =; var t = @a; t.add(5); f(t)
11:49:24MimbusBlaXpirit: <no output>
12:02:37*Gonzih quit (Quit: WeeChat 1.0.1)
12:12:23*akiradeveloper quit (Remote host closed the connection)
12:12:56*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
12:15:20*rzzz joined #nim
12:20:13*irrequietus joined #nim
12:21:03*rzzz quit (Ping timeout: 250 seconds)
12:21:07*Trustable joined #nim
12:31:22*HakanD joined #nim
12:32:17*HakanD_ joined #nim
12:35:50*HakanD quit (Ping timeout: 244 seconds)
12:44:38*akiradeveloper joined #nim
12:52:35*Ven joined #nim
12:55:58*akiradeveloper quit ()
12:56:03*davidhq joined #nim
12:59:06flyxhmm okay, I misinterpreted the error message
12:59:54*saml_ joined #nim
13:00:47flyxis it possible to pass a parameter by value to a macro? so that if I pass a string, it's still a string and not an strlitnode?
13:11:25*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
13:15:22*rzzz joined #nim
13:17:32*irrequietus quit ()
13:19:48*reem quit (Remote host closed the connection)
13:34:16*Ven joined #nim
14:04:44*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
14:13:17*irrequietus joined #nim
14:14:42*Ven joined #nim
14:26:05*fluoride joined #nim
14:27:25*fluoride quit (Client Quit)
14:29:11*Jehan_ joined #nim
14:34:07*Woflox joined #nim
14:35:24*mwbrown joined #nim
14:37:06*untitaker joined #nim
15:09:40*darkf quit (Quit: Leaving)
15:23:25*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
15:28:11*Matthias247 quit (Read error: Connection reset by peer)
15:33:43tmkuhttp://pastebin.com/k5Zp9ge0 is there a way to make s_w and s_h recognized by the rest of object attributes in the scope?
15:33:51tmkusomething akin to python's __init__ I guess
15:34:32*Jehan_ quit (Ping timeout: 246 seconds)
15:36:29flaviutmku: array length is a compile-time value, not a runtime value.
15:37:21tmkuah. so I should use open arrays instead?
15:38:01flaviuI don't think openarray works in that context, but I never figured out what it was.
15:38:21flaviuWhat I'd do is create a type that maps a 2d index to a sequence.
15:40:34tmkuhm, I see. kind of like pointer arithmetic?
15:41:46flaviuWell, it's not pointer arithmetic, this sort of thing is done is languages like javascript.
15:42:14flaviureally just (x, y) -> (y * width) + x
15:45:20tmkuaha, got it. How would I go about overloading the [] operator?
15:47:03*Jehan_ joined #nim
15:47:56flaviu.eval type Test = object; proc `[]`(self: Test, x, y: int) = echo((y * 10) + x); Test()[1,2]
15:47:57Mimbusflaviu: 21
15:49:14*Jehan_ quit (Client Quit)
15:49:42*Jehan_ joined #nim
15:49:45*Ven joined #nim
15:54:14tmkuthanks, flaviu.
15:57:14*Jehan_ quit (Ping timeout: 272 seconds)
15:58:16*Jehan_ joined #nim
16:02:18*rzzz quit (Ping timeout: 272 seconds)
16:06:46*dhasenan joined #nim
16:09:00*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
16:12:57*kjo joined #nim
16:20:48*devzerp quit (Remote host closed the connection)
16:20:48*no_name quit (Remote host closed the connection)
16:22:37*devzerp joined #nim
16:22:37*no_name joined #nim
16:26:10*Demos joined #nim
16:26:23*Senketsu quit (Quit: Leaving)
16:28:05*no_name quit (Remote host closed the connection)
16:28:05*devzerp quit (Remote host closed the connection)
16:28:27*Senketsu joined #nim
16:29:18*no_name joined #nim
16:29:18*devzerp joined #nim
16:30:47*bcinman joined #nim
16:32:12*bcinman quit (Read error: Connection reset by peer)
16:33:41dhasenanThis seems like a dumb question, but: how do I cast BiggestInt to float?
16:34:00dhasenanIf I do cast[float](someBiggestInt), that does a reinterpret cast using a union.
16:34:09dhasenanI want the same numeric value instead.
16:38:40dhasenanAh, toFloat() in system. Though I have to cast to an int for that to work, which means losing a large chunk of the allowable range.
16:38:54def-dhasenan: float(someBiggestInt)
16:39:12def-cast is just reinterpretation of the bits, usually you want a type conversion
16:39:30dhasenanThanks, def- .
17:05:26*NimBot joined #nim
17:06:33tmkuaha, I see
17:07:53*gsingh93 joined #nim
17:12:11*banister joined #nim
17:12:15*banister quit (Max SendQ exceeded)
17:12:58*banister joined #nim
17:13:06*wink-s joined #nim
17:47:10*JehanII joined #nim
17:49:20*Jehan_ quit (Ping timeout: 272 seconds)
17:53:22*elbow_jason left #nim ("Leaving")
18:01:28*matkuki joined #nim
18:09:58*Jehan_ joined #nim
18:11:32*JehanII quit (Ping timeout: 252 seconds)
18:12:46*dhasenan_ quit (Ping timeout: 272 seconds)
18:13:35*Matthias247 joined #nim
18:14:45*HakanD_ quit (Quit: Be back later ...)
18:14:48matkukiIs there something builtin for removing duplicates from a sequence?
18:15:32Jehan_sequtils.deduplicate
18:15:44matkukiJehan_: Thanks.
18:16:22Jehan_Note however that it has worst case O(n^2) performance, since it doesn't assume anything about the type except that elements can be compared for equality.
18:16:45matkukiGot it.
18:16:50Jehan_You can write faster implementations for types that support hashing or ordered comparison.
18:17:35matkukiFor now I need convenience, so deduplicate will do.
18:32:49*JehanII joined #nim
18:36:28*Jehan_ quit (Ping timeout: 252 seconds)
18:37:28*Woflox quit (Ping timeout: 272 seconds)
18:50:57*brononymous joined #nim
18:54:30*Ven joined #nim
18:55:23*Jehan_ joined #nim
18:58:18*JehanII quit (Ping timeout: 276 seconds)
18:59:31*mwbrown quit (Read error: Connection reset by peer)
19:03:08*MagusOTB quit (Remote host closed the connection)
19:03:29*wink-s_ joined #nim
19:03:53*wink-s_ quit (Client Quit)
19:07:00*wink-s quit (Quit: Bye)
19:10:33*mwbrown joined #nim
19:19:12*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
19:25:35*brononymous quit (Quit: Page closed)
19:30:31*Matthias247 quit (Quit: Matthias247)
19:31:40*Ven joined #nim
19:37:16*wink-s joined #nim
19:48:40*banister quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
19:52:53*Matthias247 joined #nim
19:57:32*TEttinger joined #nim
20:03:24*JehanII joined #nim
20:07:50*Jehan_ quit (Ping timeout: 276 seconds)
20:22:39*matkuki quit (Quit: ChatZilla 0.9.91.1 [Firefox 36.0.3/20150319201009])
20:26:04*Jehan_ joined #nim
20:29:17*JehanII quit (Ping timeout: 276 seconds)
20:34:10*reem joined #nim
20:34:19BlaXpiritcan i prevent copying of my object?
20:34:34def-BlaXpirit: ref or ptr
20:34:50BlaXpiritobject
20:35:01def-I mean: use refs or ptrs
20:35:02BlaXpiritthere is probably some pragma
20:35:07BlaXpiritbut no, that is not worth it
20:36:07def-what would happen when the original object gets removed from the stack?
20:37:17BlaXpiriti want to prevent var b = a
20:38:17def-ah, I misunderstood. I guess with the planned overloading of `=` you could do that
20:42:56*filwit joined #nim
20:45:56*dhasenan_ joined #nim
20:59:27*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
21:10:12*reem quit (Remote host closed the connection)
21:12:40*reem joined #nim
21:13:10*reem quit (Remote host closed the connection)
21:14:26*reem joined #nim
21:15:26*HakanD_ joined #nim
21:19:44*HakanD_ quit (Ping timeout: 244 seconds)
21:35:09*dhasenan_ quit (Ping timeout: 265 seconds)
22:07:42*rzzz joined #nim
22:08:48*Jesin quit (Quit: Leaving)
22:13:43*dhasenan_ joined #nim
22:21:03BlaXpiritwhy is intset not sorted?
22:21:14*CryptoToad joined #nim
22:23:10BlaXpiritIntSet with numbers 1..2000 .items gives 1536..2000 & 1024..1535 & 512..1023 & 1..511
22:24:38BlaXpirithttps://github.com/Araq/Nim/blob/master/lib/pure/collections/intsets.nim#L199
22:25:02def-BlaXpirit: where does it say that they should be sorted?
22:25:10BlaXpiritthis gives 1056 1 2 7 1 2 7 1056
22:25:12BlaXpiritit doesn't say
22:25:18BlaXpiritbut why wouldn't it be sorted?
22:25:54def-Haven't looked at the implementation, maybe it's just more efficient this way
22:26:03EXetoCis that more important than what you get if it isn't? but maybe there should be two different types then
22:26:19BlaXpiritwell of course it is important
22:29:48def-In this case I guess you could traverse r.bits in reverse in items
22:32:14EXetoCis it a more common requirement? sometimes you need ordering and other times not
22:32:52*bcinman joined #nim
22:35:05BlaXpiritgeez
22:35:29BlaXpiritso my lib HAS been horribly broken the whole time
22:36:19EXetoCyeah?
22:36:23BlaXpiriti don't know what to do
22:37:32BlaXpirithttps://github.com/BlaXpirit/nim-random/blob/7c434e3cf698f0e9a979c503cdc742ac66403065/src/random/common.nim#L158
22:37:32*gsingh93 quit (Ping timeout: 264 seconds)
22:38:24BlaXpiritif someone wants 900 randomly chosen numbers from 1..1000 i actually only choose 100
22:38:44def-it's broken because of the intsets?
22:38:46BlaXpiritand yield numbers that are not in the intset
22:39:00BlaXpiritit's broken because i rely on intset to be sorted
22:39:23def-I guess you can try to make intset sorted, document it, and make sur performance is still about the same
22:39:29def-or change your code
22:39:30BlaXpiritlol i have no idea
22:39:38BlaXpiritand there is no good way to change the code
22:39:46def-let me check
22:39:52def-i think it should be easy to make the intset sorted
22:40:04BlaXpiritthe only way to change the code is
22:40:14*johnsoft quit (Ping timeout: 245 seconds)
22:40:23BlaXpiritdrop any optimization and just generate 900 numbers and return intset
22:40:29*johnsoft joined #nim
22:41:14flaviucorrectness is better than performance.
22:43:28BlaXpiritdef-, check out intsets.nim line 199 that i linked to
22:43:53BlaXpiritwhoever wrote that (that reminds me of git blame) knew that it is not sorted
22:44:38def-well, it's a set, why would it be sorted?
22:45:08BlaXpiritC++'s sets are sorted :|
22:45:10EXetoCdef-: don't you think there should be two types? or maybe the current type could be made more flexible
22:45:13BlaXpiritagain, why wouldn't it be sorted?
22:45:39EXetoCand there's also unordered_set for a reason
22:45:51CryptoToaddoes nim have a command to get the last X characters of a string?
22:47:42BlaXpirits[0 .. s.high-2] is a safe bet
22:47:58BlaXpiritthere is a neater way but it's subject to change
22:48:32flaviudon't you mean s[s.high-n .. s.high]?
22:48:44BlaXpiritwhat a dummy :|
22:49:25BlaXpiritit's actually s[s.len-2 .. s.high]
22:49:40BlaXpiritand by 2 I mean n
22:50:07BlaXpirits.substr(s.len - n)
22:50:51def-EXetoC: I haven't needed sorted sets yet, don't know
22:52:29*brson joined #nim
22:56:28*MagusOTB joined #nim
22:59:06MagusOTBHow do I read an int32 from a file?
23:01:23def-BlaXpirit: i don't see a simple way to make Nim's intsets sorted
23:02:03def-MagusOTB: as raw data or as a text?
23:03:08MagusOTBraw data.
23:03:14BlaXpiritwhat should i do then?
23:03:22MagusOTB(I'm trying to write a program that loads MD3 model files)
23:04:40flaviuMagusOTB: That's a little harder, is it stored as big or little endian?
23:04:43def-MagusOTB: http://nim-lang.org/streams.html#readInt32,Stream
23:05:59MagusOTBflaviu: native (in my case, small)
23:06:05MagusOTBdef-: oh hey perfect
23:06:08MagusOTBthanks
23:08:21def-MagusOTB: You can always search through http://nim-lang.org/theindex.html if you don't know where to look
23:09:06flaviuFrom what I can tell, the streams module uses pointer punning to read bytes into an int, so it should work here.
23:09:08MagusOTBdef-: Yeeeaaaah, the problem with that is knowing what to look for. I've been writin this language for like, 2 days :)
23:10:12MagusOTBalso streams don't seem to support seeking, which sort of makes sense, but also sort of isn't what I need.
23:10:24MagusOTBFiles appear to
23:12:01def-they have getPosition and setPosition at least
23:12:06MagusOTBoh
23:12:29MagusOTBthat'll do
23:13:24*MagusOTB was looking for the wrong thing
23:14:24MagusOTBWhat's the difference between 'pointer' and 'ptr <thing>'?
23:14:40MagusOTBit seems like in theory I should be able to convert between them, but for some reason I can't.
23:14:40BlaXpirituntyped pointer, maybe you're familiar with void*\
23:14:45MagusOTByea
23:14:55MagusOTBI know C/Python pretty well
23:15:02BlaXpiritcast should convert between them
23:15:15MagusOTBbut in C you can go from void* to basically anything really easy (and hilariously unsafely)
23:15:23MagusOTBhmm... lemme try again
23:15:24BlaXpiritthat's cast
23:15:40MagusOTBok wait
23:15:40BlaXpiritand by cast i mean cast[Type](thing)
23:15:47MagusOTBah
23:16:08MagusOTBI was sing thing.Type
23:16:11MagusOTB*using
23:18:54*gokr quit (Quit: Leaving.)
23:19:05EXetoCthe source has no type information so that's why it's not possible to perform a conversion
23:20:24BlaXpiritcast is indeed "hilariously unsafe"
23:20:52MagusOTBis it literally like a C cast?
23:21:06MagusOTBi.e. "I know what's at this memory, pretend I'm correct"
23:21:50BlaXpiritpretty sure
23:22:11BlaXpiriti am sure that it's at least somewhat like it
23:22:45cazovso a nim cast clobbers type information while a nim conversion is more like a function that takes something of type A and return something of type B?
23:23:13flaviuAlmost, but it uses memcpy so that it doesn't trigger UB. (IIRC, it's been a while since I've looked into the c output)
23:23:26flaviucazov: Yep, exactly.
23:24:41cazovso not quite like C casts then, since those might perform conversions (like from float to int or vice versa) where cast[float](someInt) in nim would do like a *(float*)(&someInt) (if that was actually legal)?
23:25:14BlaXpiritye
23:25:27cazovnifty, thanks :]
23:25:28EXetoCthat's true. the range is not validated in C though
23:26:05EXetoCin Nim it is unless that behavior is disabled
23:26:06MagusOTBcazov: FWIW, that's totally legal in C.
23:27:04MagusOTBcan you use cast[] to get the pointer value of a ref?
23:27:26EXetoChe might have meant in nim, but all these things have equivalents
23:27:55flaviuMagusOTB: You don't need cast, just do addr(foo)
23:28:13BlaXpiritmaybe addr(foo[]) ?
23:28:25MagusOTBflaviu: oh neat, didn't know about that.
23:28:31BlaXpiritdefinitely need []
23:28:37MagusOTBwhat does the [] do?
23:28:40flaviuBlaXpirit: yes, I forgot about that.
23:28:54BlaXpiritaddr(foo[]) would be &(*foo)
23:29:05MagusOTBoh, so [] in this case means exactly the same thing as C
23:29:08MagusOTBneat
23:29:31EXetoCunless the data happens to be layed out in a certain way?
23:29:48MagusOTBwell, same as foo[0] in C
23:30:20EXetoCno, [] dereferences
23:31:03EXetoCsoo foo[] is like *foo. foo[i] is indexing like in C
23:31:17MagusOTBindexing in C is semantic sugar for dereferencing :)
23:31:22MagusOTB*syntactic?
23:32:11MagusOTBso if I wanted to assign to the value pointed to by a ref type I'd need to do that too
23:32:14MagusOTBlike
23:32:19MagusOTB?
23:32:22BlaXpiritfoo[i] is definitely not like indexing in C :|
23:33:00BlaXpirityes, you need dereference when working with ref, just like with pointers. but often it can be implied so u dont need to write it
23:33:05MagusOTBI know. That's what I'm saying, what I'm confused about is what the empty [] means
23:33:13BlaXpiritdereference
23:33:26MagusOTB"it can be implied" ?
23:33:42BlaXpiritmyref.x works like myref[] . x
23:33:48BlaXpiritetc
23:34:05MagusOTBso like if I have a: int32 and b: ref int32, if I said a = b it would work?
23:34:18BlaXpiritprobably not, dunno
23:34:37EXetoCa = b[]
23:35:20flaviu.eval var a: int32 = 1; var b: ref int32 = new(int32); b = 2; a = b; echo a, b
23:35:21Mimbusflaviu: eval.nim(5, 4) Error: type mismatch: got (int literal(2)) but expected 'ref int32'
23:35:38flaviu.eval var a: int32 = 1; var b: ref int32 = new(int32); b[] = 2; a = b; echo a, b
23:35:39Mimbusflaviu: eval.nim(6, 4) Error: type mismatch: got (ref int32) but expected 'int32'
23:37:12MagusOTBbut that does work for overloading purposes?
23:37:24EXetoC.eval var a: int32 = 1; var b: ref int32 = new(int32); b[] = 2; a = b[]; echo a, b
23:37:25MimbusEXetoC: eval.nim(7, 8) Error: type mismatch: got (ref int32)
23:37:50EXetoCcrap
23:37:56*MagusOTB is confused
23:37:57BlaXpiritMagusOTB, Nim doesn't like when you use a type as both normal and ref
23:38:11EXetoC.eval var a: int32 = 1; var b: ref int32 = new(int32); b[] = 2; a = b[]; echo a, b[]
23:38:12MimbusEXetoC: 22
23:38:18BlaXpiritwhen you create a type, you decide if you want a normal type or a ref type
23:38:29BlaXpiritand then you just use it, without needing to write ref
23:38:36MagusOTBah, so ref is more a property of the type than of an instance
23:38:45MagusOTBso really you would never use 'ref int32' in practice
23:38:54MagusOTB?
23:38:57BlaXpiritref int32 is pointless
23:39:06MagusOTBok cool, that makes more sense.
23:39:30BlaXpiritbut if it was some other complex type, then it's not so pointless
23:39:54MagusOTByeah. But you'd put ref on that types type declaration, not every time you used one, right?
23:39:55flaviuI wouldn't say it's pointless, although its use is limited.
23:40:12BlaXpiritMagusOTB, yes, that's what people usually do, but it's not enforced
23:40:22Jehan_ref int32 has its uses when you explicitly want to share the value between multiple places.
23:40:50Jehan_It's relatively rare to not have it as part of a bigger object, of course.
23:40:55flaviuMagusOTB: Sort of like typedef *foo_s foo; vs using *foo_s directly.
23:46:08*wb quit (Ping timeout: 265 seconds)
23:46:56*bjz joined #nim
23:47:52BlaXpiritdef-, flaviu, so what should I do about https://github.com/BlaXpirit/nim-random/blob/d38e06e81e9e64910ff8bf77344d96e8ae66249f/src/random/common.nim#L158 ?
23:48:20BlaXpiritintset is exactly what I need, and even without that optimization it would be advantageous to return the results in order
23:52:14flaviuWell, you could require that the range == (0..(2^64 - 1)), in which case pcg32_c64 would work.
23:52:29flaviuYou wouldn't even need temporary space!
23:53:53Jehan_BlaXpirit: What's the problem with the code?
23:54:25BlaXpiritJehan_, it's relying on intset.items being sorted, but it's not
23:54:42BlaXpirit[:23:09] <BlaXpirit> IntSet with numbers 1..2000 .items gives 1536..2000 & 1024..1535 & 512..1023 & 1..511
23:55:59Jehan_In order for the return values to be in the same order as before?
23:56:19BlaXpiritthat, and the optimization "not direct", "missingItems"
23:57:56Jehan_Hmm, I seem to remember something about a better algorithm for choosing M elements from a set of N (in order). Let me check, I think I may have some old code lying around.