00:00:15 | fowl | .eval import macros; macro x(s:stmt):stmt = echo(toStrLit(x)); x(1) |
00:00:16 | Mimbus | fowl: eval.nim(4, 37) Error: recursive dependency: 'x' |
00:00:21 | fowl | .eval import macros; macro x(s:stmt):stmt = echo(toStrLit(x));x(1) |
00:00:22 | Mimbus | fowl: eval.nim(4, 37) Error: recursive dependency: 'x' |
00:00:25 | dom96 | zipR4ND: great. let me know if you have any other questions. |
00:00:54 | * | davidhq joined #nim |
00:01:44 | EXetoC | fowl: I just wanted to fix this code https://github.com/Araq/Nim/issues/2373 |
00:01:54 | EXetoC | ok :p |
00:05:14 | * | davidhq quit (Ping timeout: 246 seconds) |
00:06:56 | fowl | EXetoC, he can fix it by making it take string{lit} |
00:08:00 | EXetoC | yeah |
00:10:09 | onionhammer | hola |
00:10:11 | onionhammer | whats up |
00:11:46 | * | mwbrown joined #nim |
00:12:24 | * | TEttinger joined #nim |
00:17:51 | brson | Araq: what are you refering to? |
00:20:27 | * | davidhq joined #nim |
00:25:06 | fowl | CryptoToad, hey try changing the first if clause in that function to use == 0 intead of "not x > 0" |
00:27:25 | CryptoToad | lol just realized how dirty that was, but it's still doing the same thing |
00:28:00 | CryptoToad | i'm wondering if ms code is just outdated |
00:28:01 | * | brson quit (Ping timeout: 255 seconds) |
00:28:03 | fowl | what is it doing |
00:28:08 | CryptoToad | i added the console output |
00:28:11 | CryptoToad | in the hastebin |
00:28:20 | CryptoToad | see "Err!: @[" |
00:28:36 | CryptoToad | where @[ is szProcessName |
00:28:47 | CryptoToad | the getModuleBaseName function |
00:28:57 | CryptoToad | should set szProcessName to the process name |
00:29:05 | CryptoToad | but i'm messing it up somehow |
00:29:14 | CryptoToad | cause it's returning false |
00:29:20 | fowl | CryptoToad, get rid of cast[bool], cast[dword] |
00:29:36 | CryptoToad | which ones? i use a lot of em |
00:29:38 | fowl | use bool(), dword() type conversions |
00:29:41 | CryptoToad | ooohhh |
00:30:40 | fowl | Error: undeclared identifier: 'closeHandle' |
00:30:55 | CryptoToad | yeah i commented that for now |
00:31:12 | CryptoToad | oh |
00:31:13 | CryptoToad | wow |
00:31:14 | CryptoToad | it works |
00:31:14 | CryptoToad | now |
00:31:19 | CryptoToad | just that type conversion issue |
00:31:21 | CryptoToad | :O |
00:31:47 | fowl | i got it working |
00:31:48 | CryptoToad | thanks fowl |
00:31:52 | fowl | oh i see you did too |
00:32:03 | CryptoToad | :) |
00:32:06 | fowl | CryptoToad, so only use cast[] when ptr is involved |
00:32:14 | CryptoToad | or if it's a weird type? |
00:32:20 | CryptoToad | or should all types have |
00:32:29 | fowl | weird how? |
00:32:29 | CryptoToad | the type() conversion proc |
00:32:46 | CryptoToad | like imported from c or something |
00:33:16 | fowl | ah um with c we mainly run into this with the billions of different int types involved |
00:33:23 | CryptoToad | lol |
00:33:34 | CryptoToad | yeah, seems a bit silly to complicate it |
00:33:39 | CryptoToad | just let me pass an int xD |
00:33:47 | EXetoC | you might accidentally cast a 32-bit value to a 64-bit value for example |
00:35:14 | fowl | CryptoToad, should be CloseHandle() btw |
00:35:43 | * | rzzz joined #nim |
00:36:02 | fowl | CryptoToad, 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:28 | CryptoToad | yeah lol i know it is, i think i was just trying to do things until something worked |
00:39:49 | CryptoToad | prints fine without the $ though |
00:40:02 | CryptoToad | does echo convert to a string? |
00:40:21 | fowl | yea |
00:40:34 | fowl | echo(varargs[string, `$`]) means it applies $ to every arg |
00:40:35 | EXetoC | echo(varargs[`$`, T]) |
00:40:39 | * | Matthias247 quit (Read error: Connection reset by peer) |
00:40:43 | CryptoToad | ahh |
00:40:46 | EXetoC | damn, so close! |
00:40:49 | CryptoToad | lol nice try |
00:40:50 | CryptoToad | :P |
00:40:52 | EXetoC | wait |
00:41:05 | EXetoC | details |
00:41:43 | fowl | bbl food |
00:45:49 | CryptoToad | exetoc how long have you been coding nim? |
00:48:18 | EXetoC | since early 2013 |
00:51:57 | CryptoToad | ahh nice |
00:52:56 | * | CryptoToad quit (Quit: Leaving) |
00:56:46 | Trustable | Hi 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:56 | EXetoC | Trustable: I only know of that PR from 2013 mentioned on the wiki, which remains open |
01:11:41 | Trustable | EXetoC: What was that PR about? |
01:15:28 | EXetoC | Trustable: for adding nim support to geany |
01:16:27 | Trustable | EXetoC: ok, I guess it is about the filename:line:column format of the compiler output |
01:17:14 | Trustable | EXetoC: But I would like to add a lexer for Nim to Scintilla (which is used by Geany) |
01:19:23 | Trustable | EXetoC: Sorry, I missread you. |
01:20:27 | Trustable | I found something interesting here: https://github.com/geany/geany/pull/193 |
01:20:45 | * | akiradeveloper quit (Remote host closed the connection) |
01:20:58 | Trustable | EXetoC: thanks for the hint |
01:23:51 | EXetoC | yes 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:32 | nuew | Hello - I'm trying to use the events module, but can't figure out how to pass arguments. |
01:36:58 | nuew | I've sub-classed EventArgs |
01:37:29 | nuew | but taking EventArgs as the argument results in nothing |
01:38:12 | nuew | switching the argument to StringArgs (the name of the subclass) makes the proc say it can't be called |
01:39:03 | nuew | and switching the proc to a method says that it expected an expression. |
01:39:22 | nuew | Thanks in advance for the help. |
01:53:36 | * | darkf joined #nim |
01:53:58 | EXetoC | care to upload the code to gist or something? |
01:54:29 | EXetoC | nuew: I haven't used that module yet so I don't know what you're referring to |
01:54:40 | nuew | sure |
01:55:46 | EXetoC | what do you intend to use it for? |
01:55:49 | * | Trustable quit (Remote host closed the connection) |
02:01:03 | nuew | Here are some examples: http://pastebin.com/swtZLvWW |
02:01:16 | nuew | Using it for a basic event/callback system in a game |
02:05:25 | EXetoC | EventArgs does not have such a field, and so you must cast it (cast[Type](var)) |
02:06:02 | nuew | ok thanks |
02:06:53 | * | davidhq quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
02:10:13 | EXetoC | nuew: and you can't substitute the class type with the type of one of the children |
02:10:35 | nuew | i knew that, but I was hoping it would work ;) |
02:12:34 | EXetoC | and 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:02 | nuew | huh... 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:39 | EXetoC | you can extend EventArgs if you want, or you could have your own "base" class with methods |
02:13:45 | nuew | ok |
02:14:00 | EXetoC | that's a bug. I'll see if there are bug reports that might be relevant |
02:14:29 | nuew | i guess i'm just going to reimplement the thing |
02:14:51 | EXetoC | nope. please report that. |
02:15:45 | nuew | I mean as well |
02:24:44 | nuew | reported: https://github.com/Araq/Nim/issues/2375 |
02:25:26 | EXetoC | thanks |
02:26:34 | EXetoC | -d:release rarely needs to be used |
02:28:23 | EXetoC | you can use ```nim\n...``` to highlight nim code |
02:28:25 | * | reem quit (Remote host closed the connection) |
02:29:18 | nuew | that's on the compiler |
02:29:22 | nuew | not the build |
02:29:59 | * | reem joined #nim |
02:31:23 | EXetoC | right |
02:38:27 | fowl | dont cast |
02:38:43 | fowl | type conversion |
02:39:01 | fowl | StringArgs(e).x |
02:40:50 | * | Varriount quit (Read error: Connection reset by peer) |
02:41:30 | fowl | nuew, it works for me with the type conversion ^ |
02:41:48 | fowl | EXetoC, stop telling people to use cast>_> |
02:42:23 | nuew | thansk |
02:42:31 | nuew | I swear I tried that. |
02:43:01 | nuew | but it woks |
02:43:05 | fowl | mhm :p |
02:43:05 | nuew | *works |
02:44:16 | * | reem quit (Remote host closed the connection) |
02:45:10 | EXetoC | fowl: I recently adviced it needlessly? |
02:46:26 | EXetoC | I know I did advice against it today |
02:46:35 | fowl | yes you drunk |
02:46:39 | * | mwbrown quit (Ping timeout: 252 seconds) |
02:46:41 | fowl | lol |
02:46:42 | fowl | <EXetoC> EventArgs does not have such a field, and so you must cast it (cast[Type](var)) |
02:47:03 | EXetoC | other than then obviously :p |
02:51:18 | EXetoC | I have done it before regardless. I'll write it down |
02:53:27 | * | bcinman joined #nim |
02:55:21 | fowl | good write it on the back of your hand D: |
02:58:11 | EXetoC | yeah 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:46 | flyx | morning 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:27 | flyx | ah, forget it, I see the problem |
11:01:52 | flyx | I 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:48 | flyx | so, when I have a "param: varargs[…]", how would I construct an array that has a length of len(param) + 1? |
11:22:29 | flyx | array[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:01 | BlaXpirit | flyx, exactly, it is not static |
11:45:05 | BlaXpirit | so it is impossible |
11:45:20 | BlaXpirit | how do you expect to create a type based on a runtime value? |
11:45:35 | flyx | well, it works in Ada |
11:45:42 | flyx | so it's possible |
11:45:52 | BlaXpirit | -_- |
11:45:59 | BlaXpirit | you're definitely confusing something |
11:46:05 | BlaXpirit | how about u explain what u want |
11:46:57 | flyx | I 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:33 | flyx | I would use a seq, but the varargs param doesn't take a seq |
11:49:21 | BlaXpirit | .eval proc f(a: varargs[int]) =; var t = @a; t.add(5); f(t) |
11:49:24 | Mimbus | BlaXpirit: <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:06 | flyx | hmm okay, I misinterpreted the error message |
12:59:54 | * | saml_ joined #nim |
13:00:47 | flyx | is 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:43 | tmku | http://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:51 | tmku | something akin to python's __init__ I guess |
15:34:32 | * | Jehan_ quit (Ping timeout: 246 seconds) |
15:36:29 | flaviu | tmku: array length is a compile-time value, not a runtime value. |
15:37:21 | tmku | ah. so I should use open arrays instead? |
15:38:01 | flaviu | I don't think openarray works in that context, but I never figured out what it was. |
15:38:21 | flaviu | What I'd do is create a type that maps a 2d index to a sequence. |
15:40:34 | tmku | hm, I see. kind of like pointer arithmetic? |
15:41:46 | flaviu | Well, it's not pointer arithmetic, this sort of thing is done is languages like javascript. |
15:42:14 | flaviu | really just (x, y) -> (y * width) + x |
15:45:20 | tmku | aha, got it. How would I go about overloading the [] operator? |
15:47:03 | * | Jehan_ joined #nim |
15:47:56 | flaviu | .eval type Test = object; proc `[]`(self: Test, x, y: int) = echo((y * 10) + x); Test()[1,2] |
15:47:57 | Mimbus | flaviu: 21 |
15:49:14 | * | Jehan_ quit (Client Quit) |
15:49:42 | * | Jehan_ joined #nim |
15:49:45 | * | Ven joined #nim |
15:54:14 | tmku | thanks, 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:41 | dhasenan | This seems like a dumb question, but: how do I cast BiggestInt to float? |
16:34:00 | dhasenan | If I do cast[float](someBiggestInt), that does a reinterpret cast using a union. |
16:34:09 | dhasenan | I want the same numeric value instead. |
16:38:40 | dhasenan | Ah, 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:54 | def- | dhasenan: float(someBiggestInt) |
16:39:12 | def- | cast is just reinterpretation of the bits, usually you want a type conversion |
16:39:30 | dhasenan | Thanks, def- . |
17:05:26 | * | NimBot joined #nim |
17:06:33 | tmku | aha, 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:48 | matkuki | Is there something builtin for removing duplicates from a sequence? |
18:15:32 | Jehan_ | sequtils.deduplicate |
18:15:44 | matkuki | Jehan_: Thanks. |
18:16:22 | Jehan_ | 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:45 | matkuki | Got it. |
18:16:50 | Jehan_ | You can write faster implementations for types that support hashing or ordered comparison. |
18:17:35 | matkuki | For 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:19 | BlaXpirit | can i prevent copying of my object? |
20:34:34 | def- | BlaXpirit: ref or ptr |
20:34:50 | BlaXpirit | object |
20:35:01 | def- | I mean: use refs or ptrs |
20:35:02 | BlaXpirit | there is probably some pragma |
20:35:07 | BlaXpirit | but no, that is not worth it |
20:36:07 | def- | what would happen when the original object gets removed from the stack? |
20:37:17 | BlaXpirit | i want to prevent var b = a |
20:38:17 | def- | 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:03 | BlaXpirit | why is intset not sorted? |
22:21:14 | * | CryptoToad joined #nim |
22:23:10 | BlaXpirit | IntSet with numbers 1..2000 .items gives 1536..2000 & 1024..1535 & 512..1023 & 1..511 |
22:24:38 | BlaXpirit | https://github.com/Araq/Nim/blob/master/lib/pure/collections/intsets.nim#L199 |
22:25:02 | def- | BlaXpirit: where does it say that they should be sorted? |
22:25:10 | BlaXpirit | this gives 1056 1 2 7 1 2 7 1056 |
22:25:12 | BlaXpirit | it doesn't say |
22:25:18 | BlaXpirit | but why wouldn't it be sorted? |
22:25:54 | def- | Haven't looked at the implementation, maybe it's just more efficient this way |
22:26:03 | EXetoC | is that more important than what you get if it isn't? but maybe there should be two different types then |
22:26:19 | BlaXpirit | well of course it is important |
22:29:48 | def- | In this case I guess you could traverse r.bits in reverse in items |
22:32:14 | EXetoC | is it a more common requirement? sometimes you need ordering and other times not |
22:32:52 | * | bcinman joined #nim |
22:35:05 | BlaXpirit | geez |
22:35:29 | BlaXpirit | so my lib HAS been horribly broken the whole time |
22:36:19 | EXetoC | yeah? |
22:36:23 | BlaXpirit | i don't know what to do |
22:37:32 | BlaXpirit | https://github.com/BlaXpirit/nim-random/blob/7c434e3cf698f0e9a979c503cdc742ac66403065/src/random/common.nim#L158 |
22:37:32 | * | gsingh93 quit (Ping timeout: 264 seconds) |
22:38:24 | BlaXpirit | if someone wants 900 randomly chosen numbers from 1..1000 i actually only choose 100 |
22:38:44 | def- | it's broken because of the intsets? |
22:38:46 | BlaXpirit | and yield numbers that are not in the intset |
22:39:00 | BlaXpirit | it's broken because i rely on intset to be sorted |
22:39:23 | def- | I guess you can try to make intset sorted, document it, and make sur performance is still about the same |
22:39:29 | def- | or change your code |
22:39:30 | BlaXpirit | lol i have no idea |
22:39:38 | BlaXpirit | and there is no good way to change the code |
22:39:46 | def- | let me check |
22:39:52 | def- | i think it should be easy to make the intset sorted |
22:40:04 | BlaXpirit | the only way to change the code is |
22:40:14 | * | johnsoft quit (Ping timeout: 245 seconds) |
22:40:23 | BlaXpirit | drop any optimization and just generate 900 numbers and return intset |
22:40:29 | * | johnsoft joined #nim |
22:41:14 | flaviu | correctness is better than performance. |
22:43:28 | BlaXpirit | def-, check out intsets.nim line 199 that i linked to |
22:43:53 | BlaXpirit | whoever wrote that (that reminds me of git blame) knew that it is not sorted |
22:44:38 | def- | well, it's a set, why would it be sorted? |
22:45:08 | BlaXpirit | C++'s sets are sorted :| |
22:45:10 | EXetoC | def-: don't you think there should be two types? or maybe the current type could be made more flexible |
22:45:13 | BlaXpirit | again, why wouldn't it be sorted? |
22:45:39 | EXetoC | and there's also unordered_set for a reason |
22:45:51 | CryptoToad | does nim have a command to get the last X characters of a string? |
22:47:42 | BlaXpirit | s[0 .. s.high-2] is a safe bet |
22:47:58 | BlaXpirit | there is a neater way but it's subject to change |
22:48:32 | flaviu | don't you mean s[s.high-n .. s.high]? |
22:48:44 | BlaXpirit | what a dummy :| |
22:49:25 | BlaXpirit | it's actually s[s.len-2 .. s.high] |
22:49:40 | BlaXpirit | and by 2 I mean n |
22:50:07 | BlaXpirit | s.substr(s.len - n) |
22:50:51 | def- | 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:06 | MagusOTB | How do I read an int32 from a file? |
23:01:23 | def- | BlaXpirit: i don't see a simple way to make Nim's intsets sorted |
23:02:03 | def- | MagusOTB: as raw data or as a text? |
23:03:08 | MagusOTB | raw data. |
23:03:14 | BlaXpirit | what should i do then? |
23:03:22 | MagusOTB | (I'm trying to write a program that loads MD3 model files) |
23:04:40 | flaviu | MagusOTB: That's a little harder, is it stored as big or little endian? |
23:04:43 | def- | MagusOTB: http://nim-lang.org/streams.html#readInt32,Stream |
23:05:59 | MagusOTB | flaviu: native (in my case, small) |
23:06:05 | MagusOTB | def-: oh hey perfect |
23:06:08 | MagusOTB | thanks |
23:08:21 | def- | MagusOTB: You can always search through http://nim-lang.org/theindex.html if you don't know where to look |
23:09:06 | flaviu | From what I can tell, the streams module uses pointer punning to read bytes into an int, so it should work here. |
23:09:08 | MagusOTB | def-: Yeeeaaaah, the problem with that is knowing what to look for. I've been writin this language for like, 2 days :) |
23:10:12 | MagusOTB | also streams don't seem to support seeking, which sort of makes sense, but also sort of isn't what I need. |
23:10:24 | MagusOTB | Files appear to |
23:12:01 | def- | they have getPosition and setPosition at least |
23:12:06 | MagusOTB | oh |
23:12:29 | MagusOTB | that'll do |
23:13:24 | * | MagusOTB was looking for the wrong thing |
23:14:24 | MagusOTB | What's the difference between 'pointer' and 'ptr <thing>'? |
23:14:40 | MagusOTB | it seems like in theory I should be able to convert between them, but for some reason I can't. |
23:14:40 | BlaXpirit | untyped pointer, maybe you're familiar with void*\ |
23:14:45 | MagusOTB | yea |
23:14:55 | MagusOTB | I know C/Python pretty well |
23:15:02 | BlaXpirit | cast should convert between them |
23:15:15 | MagusOTB | but in C you can go from void* to basically anything really easy (and hilariously unsafely) |
23:15:23 | MagusOTB | hmm... lemme try again |
23:15:24 | BlaXpirit | that's cast |
23:15:40 | MagusOTB | ok wait |
23:15:40 | BlaXpirit | and by cast i mean cast[Type](thing) |
23:15:47 | MagusOTB | ah |
23:16:08 | MagusOTB | I was sing thing.Type |
23:16:11 | MagusOTB | *using |
23:18:54 | * | gokr quit (Quit: Leaving.) |
23:19:05 | EXetoC | the source has no type information so that's why it's not possible to perform a conversion |
23:20:24 | BlaXpirit | cast is indeed "hilariously unsafe" |
23:20:52 | MagusOTB | is it literally like a C cast? |
23:21:06 | MagusOTB | i.e. "I know what's at this memory, pretend I'm correct" |
23:21:50 | BlaXpirit | pretty sure |
23:22:11 | BlaXpirit | i am sure that it's at least somewhat like it |
23:22:45 | cazov | so 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:13 | flaviu | Almost, 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:26 | flaviu | cazov: Yep, exactly. |
23:24:41 | cazov | so 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:14 | BlaXpirit | ye |
23:25:27 | cazov | nifty, thanks :] |
23:25:28 | EXetoC | that's true. the range is not validated in C though |
23:26:05 | EXetoC | in Nim it is unless that behavior is disabled |
23:26:06 | MagusOTB | cazov: FWIW, that's totally legal in C. |
23:27:04 | MagusOTB | can you use cast[] to get the pointer value of a ref? |
23:27:26 | EXetoC | he might have meant in nim, but all these things have equivalents |
23:27:55 | flaviu | MagusOTB: You don't need cast, just do addr(foo) |
23:28:13 | BlaXpirit | maybe addr(foo[]) ? |
23:28:25 | MagusOTB | flaviu: oh neat, didn't know about that. |
23:28:31 | BlaXpirit | definitely need [] |
23:28:37 | MagusOTB | what does the [] do? |
23:28:40 | flaviu | BlaXpirit: yes, I forgot about that. |
23:28:54 | BlaXpirit | addr(foo[]) would be &(*foo) |
23:29:05 | MagusOTB | oh, so [] in this case means exactly the same thing as C |
23:29:08 | MagusOTB | neat |
23:29:31 | EXetoC | unless the data happens to be layed out in a certain way? |
23:29:48 | MagusOTB | well, same as foo[0] in C |
23:30:20 | EXetoC | no, [] dereferences |
23:31:03 | EXetoC | soo foo[] is like *foo. foo[i] is indexing like in C |
23:31:17 | MagusOTB | indexing in C is semantic sugar for dereferencing :) |
23:31:22 | MagusOTB | *syntactic? |
23:32:11 | MagusOTB | so if I wanted to assign to the value pointed to by a ref type I'd need to do that too |
23:32:14 | MagusOTB | like |
23:32:19 | MagusOTB | ? |
23:32:22 | BlaXpirit | foo[i] is definitely not like indexing in C :| |
23:33:00 | BlaXpirit | yes, 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:05 | MagusOTB | I know. That's what I'm saying, what I'm confused about is what the empty [] means |
23:33:13 | BlaXpirit | dereference |
23:33:26 | MagusOTB | "it can be implied" ? |
23:33:42 | BlaXpirit | myref.x works like myref[] . x |
23:33:48 | BlaXpirit | etc |
23:34:05 | MagusOTB | so like if I have a: int32 and b: ref int32, if I said a = b it would work? |
23:34:18 | BlaXpirit | probably not, dunno |
23:34:37 | EXetoC | a = b[] |
23:35:20 | flaviu | .eval var a: int32 = 1; var b: ref int32 = new(int32); b = 2; a = b; echo a, b |
23:35:21 | Mimbus | flaviu: eval.nim(5, 4) Error: type mismatch: got (int literal(2)) but expected 'ref int32' |
23:35:38 | flaviu | .eval var a: int32 = 1; var b: ref int32 = new(int32); b[] = 2; a = b; echo a, b |
23:35:39 | Mimbus | flaviu: eval.nim(6, 4) Error: type mismatch: got (ref int32) but expected 'int32' |
23:37:12 | MagusOTB | but that does work for overloading purposes? |
23:37:24 | EXetoC | .eval var a: int32 = 1; var b: ref int32 = new(int32); b[] = 2; a = b[]; echo a, b |
23:37:25 | Mimbus | EXetoC: eval.nim(7, 8) Error: type mismatch: got (ref int32) |
23:37:50 | EXetoC | crap |
23:37:56 | * | MagusOTB is confused |
23:37:57 | BlaXpirit | MagusOTB, Nim doesn't like when you use a type as both normal and ref |
23:38:11 | EXetoC | .eval var a: int32 = 1; var b: ref int32 = new(int32); b[] = 2; a = b[]; echo a, b[] |
23:38:12 | Mimbus | EXetoC: 22 |
23:38:18 | BlaXpirit | when you create a type, you decide if you want a normal type or a ref type |
23:38:29 | BlaXpirit | and then you just use it, without needing to write ref |
23:38:36 | MagusOTB | ah, so ref is more a property of the type than of an instance |
23:38:45 | MagusOTB | so really you would never use 'ref int32' in practice |
23:38:54 | MagusOTB | ? |
23:38:57 | BlaXpirit | ref int32 is pointless |
23:39:06 | MagusOTB | ok cool, that makes more sense. |
23:39:30 | BlaXpirit | but if it was some other complex type, then it's not so pointless |
23:39:54 | MagusOTB | yeah. But you'd put ref on that types type declaration, not every time you used one, right? |
23:39:55 | flaviu | I wouldn't say it's pointless, although its use is limited. |
23:40:12 | BlaXpirit | MagusOTB, yes, that's what people usually do, but it's not enforced |
23:40:22 | Jehan_ | ref int32 has its uses when you explicitly want to share the value between multiple places. |
23:40:50 | Jehan_ | It's relatively rare to not have it as part of a bigger object, of course. |
23:40:55 | flaviu | MagusOTB: 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:52 | BlaXpirit | def-, flaviu, so what should I do about https://github.com/BlaXpirit/nim-random/blob/d38e06e81e9e64910ff8bf77344d96e8ae66249f/src/random/common.nim#L158 ? |
23:48:20 | BlaXpirit | intset is exactly what I need, and even without that optimization it would be advantageous to return the results in order |
23:52:14 | flaviu | Well, you could require that the range == (0..(2^64 - 1)), in which case pcg32_c64 would work. |
23:52:29 | flaviu | You wouldn't even need temporary space! |
23:53:53 | Jehan_ | BlaXpirit: What's the problem with the code? |
23:54:25 | BlaXpirit | Jehan_, it's relying on intset.items being sorted, but it's not |
23:54:42 | BlaXpirit | [:23:09] <BlaXpirit> IntSet with numbers 1..2000 .items gives 1536..2000 & 1024..1535 & 512..1023 & 1..511 |
23:55:59 | Jehan_ | In order for the return values to be in the same order as before? |
23:56:19 | BlaXpirit | that, and the optimization "not direct", "missingItems" |
23:57:56 | Jehan_ | 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. |