<< 26-08-2014 >>

00:00:55*Jesin joined #nimrod
00:03:36*saml_ joined #nimrod
00:04:17*Jesin quit (Client Quit)
00:06:15*brson quit (Quit: leaving)
00:06:41*Jesin joined #nimrod
00:22:56*jjap joined #nimrod
00:24:59jjapHi guys/gals, I'm trying to figure out importing C functions. The manual isn't entirely clear (to me). Do I manually write the proc to resemble the C function (variables+return), then add the necessary importc/header pragmas?
00:26:17jjapIf a C function excepts a struct, do I create a similar Object in nimrod, and make the Proc accept that Object where the C function would take the struct?
00:28:22jjapInstead of duplicating a C enum parameter, can I just declare/send an Int? Or must I make a nimrod enum?
00:30:38EXetoCyou often want just importc
00:30:50EXetoCwell, only the size must match (binary compatibility)
00:32:22EXetoCint? can't remember. you want cint for C's int though
00:33:13EXetoCc2nim can be used for generating wrappers (usually after some tweaking)
00:33:22jjapHmm. For example: int clock_gettime(clockid_t clk_id, struct timespec *tp);
00:33:37jjapMy guess was something like: proc clock_gettime(clk_id:int, ts: timespec):int {.importc: "clock_gettime", header: "<time.h>".}
00:33:50jjaptimespec being an object I created to resemble the C struct
00:35:19EXetoClib/posix/posix.nim:2273:proc clock_gettime*(a1: TClockId, a2: var Ttimespec): cint
00:35:19jjapLooking at it now, I see that ts:timespec should be var
00:35:30EXetoCTClockId is an int, so you just got one thing wrong I think
00:35:48EXetoCthat module is present in the standard distribution
00:35:51jjapagg. This is in the posix module?
00:36:05jjapHeh
00:36:32EXetoCyes
00:36:44jjapHmm Ttimespec.. was I right about the object/struct? I'll pull up the code now
00:37:12EXetoCyes
00:37:51EXetoCno
00:38:21jjapAh. I see what you mean about "just importc"
00:38:27jjapno need to say it's function name again
00:38:28EXetoCthe 'pure' pragma is necessary I think (it omits RTTI)
00:40:00jjapI'm looking at the definition now... interesting
00:40:21jjapRTTI?
00:41:10EXetoCruntime type information/identification
00:41:20jjapI'll study the code for this module. It's full of examples I can learn from. Thanks.
00:41:42jjapAny idea why the final?
00:43:11EXetoCit means that said object can't be inherited from
00:45:24jjapI see. Any idea why all these imported structs begin with T? Any important significance to this convention?
00:48:19EXetoCa side-effect of the case-insensitivity, but that's going to be modified slightly, so the prefix will go away
00:48:55jjapThank you
00:50:03jjapI've been test driving nimrod as bash/C replacement. For Better maintainability and safety. That's the idea anyway.
00:54:33*askatasuna joined #nimrod
01:09:52*askatasuna quit (Ping timeout: 255 seconds)
01:15:06*q66 quit (Quit: Leaving)
01:20:11*MightyJoe is now known as cyraxjoe
01:22:59jjapI have some experience creating Mac OS X installers for programming languages (move files into place, create symlinks, option for keep/removing old version, etc). Any concerns/objects/whatever before I cook one up for 0.9.4?
01:23:14jjap*/objections/
01:30:06*EXetoC quit (Quit: WeeChat 1.0)
02:13:37*jjap quit (Ping timeout: 246 seconds)
02:15:44*OrionPK joined #nimrod
02:51:13*bjz quit (Ping timeout: 260 seconds)
03:05:49*askatasuna joined #nimrod
03:32:51*ws joined #nimrod
03:45:57*askatasuna quit (Ping timeout: 240 seconds)
03:48:35*Jesin quit (Quit: Leaving)
03:49:00*saml_ quit (Ping timeout: 260 seconds)
04:08:42*xenagi quit (Quit: Leaving)
04:43:37*kshlm joined #nimrod
05:05:07*ws quit (Ping timeout: 246 seconds)
05:16:43*jjap joined #nimrod
05:19:47jjapWould anyone know why " import posix; var sp = posix.Ttimespec(); discard posix.clock_gettime(0,sp) " would get the compiler complaining "undefined reference to `clock_gettime' ?
05:20:23jjapReference: https://github.com/Araq/Nimrod/blob/3cdc32895258415871f4d183d65544d655ac38cb/lib/posix/posix.nim#L2273
05:20:56*nande quit (Remote host closed the connection)
05:21:28jjapEr. Maybe I'm missing the C header on my machine?
05:22:24jjapNo no. That can't be right. Hrm
05:47:58*gkoller joined #nimrod
06:12:01*Sht0 joined #nimrod
06:38:55*ome joined #nimrod
06:39:04*ome quit (Client Quit)
06:59:33*darkfusion quit (Ping timeout: 240 seconds)
07:01:14*darkfusion joined #nimrod
07:15:48*disconnected_ is now known as disconnected
07:29:46*BlaXpirit joined #nimrod
07:53:22*kunev joined #nimrod
08:08:31*jjap quit (Ping timeout: 246 seconds)
08:13:49*Boscop joined #nimrod
08:18:28*io2 joined #nimrod
09:27:03*lyro quit (Ping timeout: 272 seconds)
09:27:22def-in case jjap comes back or reads the logs: It's probably -lrt missing at linktime
09:29:18*lyro joined #nimrod
10:01:15*jasondotstar|afk quit (Quit: Leaving)
10:12:38*vegai_ is now known as vegai
10:13:00*zahary joined #nimrod
10:15:20*Matthias247 joined #nimrod
10:17:23*Ven joined #nimrod
10:36:37*EXetoC joined #nimrod
11:07:00*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
11:22:49*Ven joined #nimrod
11:36:24*io2 quit (Quit: ...take irc away, what are you? genius, billionaire, playboy, philanthropist)
11:53:50*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
12:07:57*gkoller quit (Ping timeout: 260 seconds)
12:09:37*gkoller joined #nimrod
12:20:40BlaXpiritis there a way for a function to accept any array, sequence, iterator as argument?
12:30:02*disconnected left #nimrod (#nimrod)
12:50:14*gkoller quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
12:58:46*Araq_ joined #nimrod
12:59:35Araq_BlaXpirit: yes, but until 'generic' works, you need to underspecify the contraint
12:59:41*gkoller joined #nimrod
12:59:49Araq_proc foo[T](x: T) =
12:59:59Araq_ for a in x: echo a
13:00:03BlaXpirit:| ok
13:00:17Araq_--> works for everything that has 'items'
13:00:37BlaXpiritthank you
13:01:30BlaXpiritI don't understand
13:01:31Araq_personally I'm a fan of this sine the constraint only reimplements the body anyway
13:01:35BlaXpiritI import intsets
13:01:59BlaXpiritand it doesn't see anything the module exports
13:02:06BlaXpiritI can only do intsets.stuff()
13:02:36*kshlm quit (Quit: Konversation terminated!)
13:03:06BlaXpirite.g. for el in intsets.items(s) works
13:03:10BlaXpiritbut for el in s doesn't
13:03:26Araq_yes, I'm aware
13:03:48Araq_you can report it anyway
13:03:50BlaXpiritAraq_, and what does this mean?
13:04:07BlaXpiritis it only for intsets? what is the scope?
13:04:43Araq_for el in items(s) # should work
13:04:49BlaXpirits.contains_or_incl(x) doesn't work but intsets.contains_or_incl(s, x) works
13:04:51Araq_for el in s # should work too, but doesn't
13:05:16Araq_what version do you use?
13:05:29BlaXpiritAraq_, 0.9.5
13:06:02Araq_damn
13:06:54BlaXpiritah, don't need to specify "intsets."
13:06:59BlaXpiritworks without it
13:07:01BlaXpiritbut still........
13:08:25Araq_well it's a big bug for sure
13:08:53Araq_most annoying is that I fixed it, but apparently my tests are almost worthless
13:09:52Araq_but in my defense, it's already marked as a showstopper bug ...
13:14:41*darkf quit (Quit: Leaving)
13:18:50BlaXpiritecho intset doesn't work too :(
13:19:07BlaXpiritbut all that i've just mentioned does work in my 1-file script
13:19:21BlaXpiritjust not in an imported module
13:29:53*bjz joined #nimrod
13:30:45*gkoller quit (Read error: Connection reset by peer)
13:31:35*gkoller joined #nimrod
13:42:29BlaXpiritwhy are slices so useless :(
13:42:37BlaXpiritno len, no indexing, no conversion to seq
13:43:47*gkoller quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
13:46:19BlaXpiritI wonder why sequtils.to_seq is not @
13:55:27*io2 joined #nimrod
13:56:04EXetoCthe slice type? why index it?
13:56:18Araq_I don't know what he means either
13:56:52Araq_bbl
13:56:54*Araq_ quit (Quit: ChatZilla 0.9.90.1 [Firefox 31.0/20140716183446])
13:57:19EXetoCthe "length" can be retrieved using high and low
13:58:06EXetoCI assume you don't mean a slice operation, which gives you a seq
13:58:30EXetoCit once again becomes confusing because of the conflated terminology
14:00:29BlaXpiritbasically, i would love to use a..b as openarray
14:01:04BlaXpiritnot entirely sure what openarray is, anyway, because it is not explained in detail
14:03:17BlaXpiriti think openarray should support everything that has low, high and []
14:03:55BlaXpiritor maybe that it should just be a generic thing and then openarray would not need to exist
14:09:07BlaXpiritand really, why aren't there shorter versions of sort?
14:12:09EXetoCa..b is just a slice (see the TSlice type)
14:12:27BlaXpirituhh yes
14:12:28EXetoCand you have the iterator version
14:12:34BlaXpiritand i don't want it to be just a slice
14:13:32BlaXpiritPython's `range` is really needed
14:14:15EXetoCwell you did mention toSeq
14:14:42BlaXpirit1..100000000000 toSeq won't do
14:15:52EXetoCyeah that's not a lazy operation. I can't remember what the limitations were
14:16:22BlaXpirithttps://docs.python.org/3/library/stdtypes.html#range this is good stuff and I need it all the time
14:17:20BlaXpiritit's not just an iterator, it's an object that you can do things with. it acts a lot like a list but stores only 3 numbers
14:17:52BlaXpiritand I can't think of a reason why slices can't be made like this
14:19:15BlaXpiritin python you can do `random_sample(range(10000000), 60)`
14:19:38BlaXpiritand the function random_sample doesn't need to know that what it receives isn't actually a list
14:29:36EXetoCso, slice + iterators then? but iterators can't really be used as objects yet I think
14:30:15BlaXpiritEXetoC, `range` is not an iterator, but it can give you an iterator
14:30:29BlaXpiritlike Python's analog of `items`
14:31:12BlaXpirita slice is already a lot like it
14:31:31BlaXpiritit's just an object that contains 2 numbers and can be iterated
14:31:52BlaXpiritand i would like it to get more functionality, make it more like python's `range`
14:32:43BlaXpiritmake len(slice), slice[i]
14:32:53BlaXpiritcuz why not if it already has contains
14:33:55EXetoCI wonder why there's a .. iterator also. there could just be an items function for TSlice instead
14:34:09BlaXpirit.. iterator?
14:34:25EXetoCiterator `..`
14:34:47EXetoCand then you have proc `..`*[T](a, b: T): TSlice[T]
14:34:51BlaXpiritok, now that is frickin weird
14:35:14BlaXpiritwhy isn't it items(TSlice) ???
14:35:19BlaXpiriti was sure that it was
14:36:34EXetoCno. will discuss that also
14:36:49BlaXpiriti may as well just make myself a `range` and ignore slices' existence
14:40:35EXetoCit's used for slice operations too
14:40:44EXetoCwhen slicing a sequence for example
14:41:22BlaXpiritEXetoC, beats me why the slice doesn't have a "step"
14:41:39BlaXpiritall the languages i know that have such slicing, support a step
14:41:53BlaXpiritreally cuts the usefulness
14:43:27BlaXpiritsure, maybe I just want Nimrod to be Python
14:43:51BlaXpiritbut this stuff is just too good http://stackoverflow.com/a/509295
14:52:38EXetoCdo you need stepping for something other than iteration?
14:52:54BlaXpiritslicing!
14:53:23BlaXpirit[1,2,3,4,5][::2] == [1,3,5] and stuff (this is python code)
14:54:05EXetoCI don't know if performance has anything to do with this, though optimizations should help in some cases
14:54:51BlaXpiritso, what is openarray?
14:55:06BlaXpiritis it really just "hardcoded" for arrays and seqs?
14:59:00BlaXpiritusing openarray doesn't seem feasible at all to me
14:59:00EXetoCit also makes it so that the index starts from zero http://nimrod-lang.org/manual.html#open-arrays
14:59:09BlaXpiriti understand
14:59:11EXetoCthe lower index can be something other than 0 for arrays
14:59:30BlaXpiritbut can't it just make the adaptation for any type that has len and [] ?
14:59:44BlaXpiritor low, high, []
14:59:50EXetoCwell, Araq did mention generics before, which are still broken
15:00:08EXetoChence why he brought up unconstrained type parameters
15:00:13BlaXpiritok so i have this
15:00:15BlaXpiritproc random_choice*[T](arr: openarray[T]): T
15:00:20BlaXpirithow do i change it to generic
15:00:36BlaXpiritI understand that the first step is proc random_choice*[T](arr: T):
15:00:38BlaXpiritbut then what?
15:13:03*johnsoft quit (Ping timeout: 240 seconds)
15:15:04EXetoCno, as in user-defined typeclasses, but it seems reasonable to just use openarray, unless you want it to apply to non-random access containers too
15:15:36BlaXpirit> range
15:17:17BlaXpirithttps://gist.github.com/BlaXpirit/09290912725ef623d430
15:18:28BlaXpiritis it so unreasonable to want to support any container?
15:19:14*brson joined #nimrod
15:22:08EXetoCjust assume that items(T) exists then
15:22:58BlaXpiritEXetoC, no, i don't use that in my function
15:23:04BlaXpiriti use len and []
15:23:23BlaXpiritand what am i supposed to assume if i just accept openarray anyway
15:23:46BlaXpiritI sure would like to be able to assume
15:24:13BlaXpiritbut you didn't tell me how; didn't answer my question from [:00:36]
15:25:10EXetoCnot all containers support indexing though, but just use those functions then instead of items if you want
15:25:29BlaXpiriti don't understand
15:26:28EXetoCjust use len and [] then
15:26:47BlaXpiritand that's what i'm doing
15:26:58EXetoCok
15:27:02BlaXpiritbut for some reason giving TRange to my function doesn't work
15:27:23BlaXpiritbecause it looks like this proc random_choice*[T](arr: openarray[T]): T
15:28:26EXetoCjust use T then
15:28:40EXetoCand not openarray[T]
15:28:41BlaXpirit[:24:10] <BlaXpirit> but you didn't tell me how; didn't answer my question from [:00:36]
15:29:11BlaXpiritwhat is the return type supposed to be then?
15:32:31EXetoCdoes arr[0].type work?
15:32:58BlaXpiritI don't know
15:33:03BlaXpiritdon't remember ever seeing such a thing
15:33:05BlaXpiritwill try
15:33:24EXetoCI might've mentioned it yesterday
15:33:50*enquora joined #nimrod
15:34:03EXetoCdoesn't seem to work
15:34:53BlaXpiritno, it definitely doesn't work
15:35:29EXetoCproc p[T](arr: T): expr = arr[0]
15:35:56BlaXpirit..?
15:36:27EXetoCI don't think there's anything better
15:36:43BlaXpiritI don't understand how this is relevant to my problem
15:37:13BlaXpirithmm actually, in this particular case it might just work
15:37:22BlaXpiritbut not with my other function
15:38:14BlaXpiritwhich returns seq[T]
15:38:24BlaXpiritbut i still would like it to accept anything that has [] and len
15:39:42EXetoCI don't know why you can't just extend my snippet, but I'm not sure what you mean so a test case would be nice
15:40:49BlaXpiritEXetoC, https://github.com/BlaXpirit/nimrod-random/blob/master/src/random.nim#L93
15:42:53EXetoCnot quite a test case, but maybe I can get it to work anyway
15:43:20*gkoller joined #nimrod
15:45:19EXetoCseq?
15:45:30BlaXpiritEXetoC, all that's needed is a function signature that would accept, for example, that TRange I showed earlier
15:45:34BlaXpiritEXetoC, yes, what about it?
15:45:38*kunev quit (Quit: leaving)
15:45:39BlaXpiritit's a different function now
15:46:06BlaXpirit[:37:11] - [:38:12]
15:47:53EXetoCinstead of openarray[T] for the arr parameter?
15:48:23BlaXpiritwhat do you mean by this?
15:49:17BlaXpiritmaybe it can even stay openarray, how do I know... what matters to me is that it accepts arbitrary containers and not just arrays
15:49:32EXetoCit can't
15:49:40EXetoCiterator random_sample*[T](self: var TRandomGenerator; arr: T, n: Natural): expr?
15:49:48EXetoC'expr' might not work with iterators
15:50:57BlaXpiritoh i forgot that I decided against using seq
15:51:01BlaXpiritsorry I confused you
15:51:26EXetoCin which case you might have to provide an overload, in which case 'arr' for the current overload might have to remain openarray[T]. I don't know if conflicts can be resolved otherwise
15:52:24BlaXpiritthis expr thing is a hack anyway
15:52:40EXetoCso maybe something like this the above doesn't work: "iterator random_sample*[T](self: TRandomGenerator; arr: openarray[T], n: Natural): T =" and "iterator random_sample*(self: TRandomGenerator; arr: TRange, n: Natural): int ="
15:54:25BlaXpiritno, no, I don't want *just* TRange
15:54:40EXetoCusing expr is often very effortless, but is indeed hacky in many cases, so we'll just have to do with what we've got until user-defined typeclasses become usable
15:54:59EXetoCbut these are two overloads
15:55:16BlaXpiritI don't want TRange at all, it was just an example
15:55:29BlaXpiritthat any such class would be acceptable for the function
15:56:00EXetoCtry the expr approach then and hope that it works
15:56:23BlaXpiritmeh
15:56:52BlaXpiritif the language doesn't have such elegance in its standard library, then why should i care about it for my library
15:59:18BlaXpiritbut in my opinion, openarray should either not exist or support custom classes
15:59:41EXetoCI don't know. it's up to you if you want to use Nimrod in its current state
16:00:12BlaXpiriti want to want to use it
16:00:59BlaXpiritcuz i could just shut up and use Python
16:01:31BlaXpiritbut it really is way too slow. people saying that it shouldn't matter doesn't change the situation
16:08:27BlaXpiritanyway, about my library. i think it's ready. if someone evaluated it, that would be great. https://github.com/BlaXpirit/nimrod-random
16:08:31EXetoCyes, and I'm saying that the actual language supports these constructs, but the implementation currently does not, and mostly because of UDTC bugs in this case
16:09:30EXetoCpython's speed in comparison to other language does indeed not matter in most cases, but I guess it does matter for you
16:09:49*BlaXpirit started making a game in it
16:09:52EXetoCthough many people write slow parts in C if necessary
16:12:04*untitaker quit (Ping timeout: 240 seconds)
16:17:50*untitaker joined #nimrod
16:45:43*gkoller quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
16:48:24*q66 joined #nimrod
16:49:20*gkoller joined #nimrod
17:07:55*Sht0 quit (Ping timeout: 255 seconds)
17:37:23*io2 quit (Ping timeout: 240 seconds)
17:41:29*gkoller_ joined #nimrod
17:41:36AraqBlaXpirit: yeah it is stupid that we don't support RandomAccess[T] yet. But on the other hand ... RandomAccess[T] is academic. In practice it's always an array or a seq anyway
17:41:51BlaXpiritno, Araq
17:42:01Araqno?
17:42:03BlaXpiritand i've provided a perfect example
17:42:22BlaXpiritsee the "range" thing i've been talking about
17:42:43BlaXpiritnot an array, not a seq, and yet a very useful thing
17:43:09Araqwhat is the "range" thing that you talked about?
17:43:22BlaXpiritdont u see message history, Araq?
17:43:59BlaXpirithttps://docs.python.org/3/library/stdtypes.html#range https://gist.github.com/BlaXpirit/09290912725ef623d430
17:44:07Araq"basically, i would love to use a..b as openarray" ?
17:44:40Araqah so python-like range
17:45:25BlaXpirityes, and in general I think Nimrod would be better off if it had slices like Python and ranges like Python
17:45:50BlaXpiritbut that is not my main concern
17:46:03BlaXpiritindeed, the main thing I would like to see is support for general containers
17:46:13Araqwe recently got zero-copy slices that can be passed to openarray fwiw
17:46:24Araqit's not even documented yet though
17:46:31*BlaXpirit rolls eyes
17:47:04Araqwelcome to nimrod land. where nothing ever works. where essentially everything is missing.
17:47:46Araqbut hey, many people can work with it, so yay ;-)
17:48:03BlaXpiritAraq, what about, say, those sparse int sets
17:48:14BlaXpiriti'm pretty sure functions that accept openarray can't work with them
17:48:28BlaXpiritwhat do u suggest doing - copying it into a seq?
17:48:39BlaXpiritwell, this is not really a good example
17:48:41Araqyeah, but the question is: what does '[]' on an intset do?
17:48:51BlaXpirityes, yes, hence "not really a good example"
17:48:57BlaXpiritbut there can be other ... sparse things
17:48:59BlaXpiritjust sparse array
17:50:38Araqdid you try: proc foo[T](x: T): auto ?
17:50:42BlaXpiritno
17:51:50*Ven joined #nimrod
17:52:38BlaXpiritaaaand it works
17:52:44BlaXpiritnow this is impressive
17:52:50*Johz joined #nimrod
17:53:50BlaXpiritecho range(1000000000).random_choice()
17:53:52BlaXpirityup
17:53:53BlaXpirityup
17:53:58BlaXpiritthis is impressive
17:54:03skyfexAraq: I don't know if I've mentioned.. I've used threads and channels quite heavily in the last project. Works quite well :)
17:54:26skyfexI only missed two functions I wish were in the standard library..
17:54:52skyfexOne function to flush a channel (ignoring everything)
17:56:37skyfexAnother to create a kind of T-junction.. take input from one or more channels and join them into one channel.. or a macro that processes several channels, and gives you a case-like statement for each chanenl
17:56:48skyfexI could try to contribute it
17:57:39AraqI'd rather see a new Chan that works with spawn, FlowVar and awaitAny
17:58:41*jhc76 joined #nimrod
17:59:46BlaXpiritokaaay so this ``echo to_seq(range(1000000000).random_sample(100))`` simply ends the program without any output
18:04:10BlaXpiritmostly because i'm a dummy
18:05:00jhc76I never heard of nimrod until recently. What is a simple demo of a code that can show off some of its powers for sysadmin profession? trying to wrap my head around it so that I can weigh if I want to dive in deeper.
18:05:21BlaXpiritah good stuff `` to_seq(range(1000000000).random_sample(5)) == @[890758599, 447430954, 452397207, 895844180, 674346587]``
18:05:40BlaXpiritruns instantly btw
18:06:50BlaXpiritnow all we need is to actually have `range` in nimrod :|
18:08:17Araqjhc76: dunno for sysadmins maybe koch.nim is a good start
18:09:24jhc76Araq: thanks! I'll start there.
18:09:58Araqskyfex: I can tell you how it's supposed to work
18:15:08*EXetoC quit (Quit: WeeChat 1.0)
18:15:12skyfexAraq: Hmm, I think I read your articles on concurrency a long time ago, I'd forgotten about them.. how's the work on that going?
18:16:07AraqI implemented something else instead :P
18:16:11Araqsomething better
18:26:14*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
18:26:35*Ven joined #nimrod
18:31:34*gkoller_ quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
18:31:43*io2 joined #nimrod
18:32:02BlaXpiritAraq, did you see this? https://github.com/BlaXpirit/nimrod-random Ideally, I would like this to be included with Nimrod, but, of course, someone has to evaluate it before I can even start to have such thoughts.
18:33:11BlaXpiritBecause the current `random` functions in Nimrod can be problematic, I've said this before. The main concern is on Windows it will actually never generate a number above 32k, even if you want a random number from 0 to a billion
18:33:58BlaXpiritnot to mention just 15 bits of resolution
18:34:39BlaXpirit1 global instance of a generator and a compiler dependent implementation of it doesn't help
18:36:24dom96A 'random' module would be nice.
18:36:48BlaXpiritdom96, could you look at it please? I don't see a better candidate :p
18:37:38dom964 spaces need to be 2 spaces.
18:38:18BlaXpiritdom96, isn't nimrod supposed to be independent of such conventions?
18:38:36BlaXpiritof course, it's an easy change, but for me it's actually difficult to read code with so little indentation
18:38:38dom96BlaXpirit: The code in the stdlib needs to be consistent.
18:39:06BlaXpiritlet's not think particularly about stdlib just yet
18:39:10dom96If it's your own package then I don't care.
18:39:31BlaXpiritnext thing you'd say is probably camelCase or whatever it's called instead of underscores
18:39:54BlaXpiritbtw, i've just started up windows virtual machine, and what I guessed would be the case from the code was just confirmed - random(1000000000) indeed gives numbers below 32k
18:44:40*Ven quit (Ping timeout: 255 seconds)
18:45:25dom96Looks good to me.
18:45:41BlaXpiritdom96, really? not even nitpicks?
18:46:43BlaXpiritwhat about usage of `uint8`? was that the right choice?
18:47:47BlaXpiritand these aliases in the end - first of all, they don't look good to me (or maybe even inefficient - how I did it for the iterator seems bad to me)
18:48:01BlaXpiritand that comment at line 199
18:48:56*Ven joined #nimrod
18:49:07BlaXpiritcan't call these functions from outside the library if `mersenne_twister_inst` is not public
18:49:08dom96Does line 198 not work or the code below it?
18:49:34BlaXpiritso basically code below it, yeah
18:50:00dom96perhaps because you are inlining?
18:50:13BlaXpiritI did it without {.inline.} first
18:50:25BlaXpiritand {.closure.} just caused a different problem from what I remember
18:51:01BlaXpiritI can try to remove inline now again
18:51:43dom96why would you make that a closure?
18:51:51BlaXpiriti dunno
18:51:57BlaXpiritso i removed inline and the star
18:52:02BlaXpirit(227, 4) Error: undeclared identifier: 'mersenne_twister_inst'
18:52:30dom96ahh, that's a generic.
18:52:52BlaXpirit:|
18:52:55BlaXpiritbad surprise
18:52:56dom96try writing 'mixin mersenne_twister_inst'
18:53:13BlaXpiritoooh right
18:54:13BlaXpirituhh I'm not sure I'm writing it in the right place
18:54:22dom96Do you really need those methods?
18:54:43BlaXpiritwhat do you mean?
18:54:53BlaXpiritthese are what people are gonna use most of the time
18:54:53dom96If you really want nitpicking then you shouldn't use inheritance.
18:55:14BlaXpiritdom96, i really don't see a better way
18:55:18BlaXpiritinheritance achieves a lot here
18:56:48dom96I still haven't used methods once.
18:56:59BlaXpirit:|
18:57:01dom96So i'm not sure what they achieve really.
18:57:09BlaXpiritjust look
18:57:25BlaXpiriti made a whole new random number generator class with only 9 lines of code
18:57:30dom96I would just overload the procs.
18:57:42dom96on the different generator types
18:57:53BlaXpiritdon't understand
18:58:19BlaXpiritwrite the same functions twice or what
18:58:39dom96essentially s/method/proc/
18:58:48BlaXpirit. . . .
18:59:08BlaXpiriti'll just disagree here
18:59:17BlaXpiritit's really extensible this way
18:59:47Araqwe usually use proc vars for extensibility
19:00:01BlaXpiriti'm pretty sure one could write their own RNG very easily
19:00:24Araqyeah but we usually don't want that
19:00:50BlaXpirit!?
19:03:53BlaXpirityeah, it works nicely https://gist.github.com/BlaXpirit/a6b5fec8785a59158716
19:04:18Araqyes, and it's horrible
19:05:14Araqhint: ever looked at the infered effects?
19:05:34BlaXpirit(woops, that was a fluke. updated the code, now it's actually correct)
19:05:35BlaXpiritAraq, ?
19:05:40Araqthat's how you can reason about this kind of code. you can't.
19:06:48BlaXpiritthis is just so extremely strange to hear
19:08:07Araqwhy? because people with no idea about formal semantics wrote some wrong books about how to do programming? ;-)
19:08:28BlaXpirityou still haven't provided any good arguments
19:08:53BlaXpirithaven't said how it can be made differently
19:09:50AraqI told you proc vars are better
19:10:23BlaXpiritjust "better", huh
19:10:55BlaXpiritwell how about this - one class overrides only one of the methods and the other one overrides two
19:11:16BlaXpiritand one of the classes also defines extra procs
19:11:32Araqyes, yes and it's all downhill from there
19:11:53Araqdo this with the rest of your codebase and Java is not far away
19:12:09BlaXpiritstill just stabs and not real arguments
19:12:24BlaXpiriti'm not an OOP maniac by any means
19:12:30BlaXpiritbut sometimes it just makes so much sense
19:14:34BlaXpiritI actually don't know how to do this with proc vars
19:15:40*EXetoC joined #nimrod
19:16:18Araqhow is "not even the compiler can figure out what it does" not a real argument?
19:16:30Matthias247polymorphism with a value object? Wasn't that the broken thing?
19:16:59Araqor make that "ok, ok, it can with global program analysis"
19:17:41BlaXpiritwhat are you even talking about?
19:18:41*EastByte joined #nimrod
19:20:48AraqI'm still explaining why we don't like 'method'
19:24:24BlaXpiritI really don't see any other way.
19:24:35EXetoCwhat's the short version? I just joined
19:24:38BlaXpiritAnd I really did try to think of one
19:25:09BlaXpiritshort version was just posted
19:25:20BlaXpirit[:20:45] <Araq> ... we don't like 'method'
19:25:35BlaXpiritin regards to https://github.com/BlaXpirit/nimrod-random
19:26:16EXetoCdoesn't go into why though
19:26:28*Trustable joined #nimrod
19:26:52EXetoCok so the short version why it's disliked is because it is :p
19:26:55BlaXpiritEXetoC, there is no short version of "why" because there wasn't really a long one
19:27:31EXetoCso it's short in any case
19:28:25*jasondotstar joined #nimrod
19:30:14*Sht0 joined #nimrod
19:32:56AraqBlaXpirit: ok, how about this reason: it's slower than an ordinary proc call
19:33:12BlaXpiritAraq, that's nice
19:33:13*jhc76 quit (Remote host closed the connection)
19:33:57BlaXpiritin c++ nobody cares about, it's really just like 2 atomic operations
19:34:19BlaXpiritif the situation with performance is worse in Nimrod... well... too bad
19:35:09BlaXpiritand i don't think procvars don't have any overhea
19:35:11BlaXpiritd
19:36:02Araqthey have less overhead, but still have overhead and in C++ people most certainly do care about it
19:36:33Araqespecially for any architecture that is not x86 based
19:38:15Matthias247I would guess that atomic ops are far more expensive than virtual calls.
19:38:41BlaXpiritthe overhead from looking up a method is much less than from calling it
19:39:48Araqactually nimrod optimizes it to a static call if you never override it iirc, so it's faster than c++
19:39:58BlaXpiritbut wait a second
19:40:01BlaXpiriti never use any pointers
19:40:05*noam__ is now known as noam
19:40:23BlaXpiritso it's possible to just
19:40:29AraqBlaXpirit: well but you use 'var T'
19:40:37BlaXpirityes, yes, i thought about it
19:40:46BlaXpiritbut i mean in regard to methods and polymorphism
19:41:19BlaXpiritisn't it possible to make methods 0 overhead if it's not called from pointer?
19:42:48Araqyes it is but the compiler doesn't do that yet
19:43:07Araqbut it should optimize it if you don't override it
19:43:37BlaXpiritso we come to compiler again
19:44:01BlaXpiritalso, if anyone is familiar with c++, a function doesn't have to be virtual to let it be overridden
19:44:21BlaXpiritand I thought "method" was a full analog of "virtual" in c++
19:44:26BlaXpiritapparently it's not
19:46:05BlaXpiritlike, if I just replace "method" with "proc" in my code, the program crashes (not even doesn't compile)
19:47:10BlaXpiritah no, it's doesn't crash. it's the assert
19:47:57Araqer ... you can assume I'm familiar with c++ ....
19:48:26BlaXpiritwell then, "virtual" in c++ is only when you want pointer-based polymorphism
19:48:52BlaXpiritsince I don't need this, i wouldn't have any virtual methods if I were to write this in c++
19:49:28BlaXpiritNimrod, on the other hand, required me to use "method" because otherwise it just doesn't work, even without pointers
19:50:03Araqnot sure what you mean
19:50:20BlaXpiritwhat part is unclear?
19:50:30Araqto get dynamic dispatch in c++ you have to use virtual
19:50:33BlaXpirityes
19:50:41Araqand in nimrod you have to use method
19:50:46BlaXpiritbut dynamic dispatch is only for pointers and polymorphism
19:51:03BlaXpiritI don't need virtual dispatch here, and yet I'm forced to use "method"
19:51:11Araqhow so?
19:51:24BlaXpirit"how so" in regard to what?
19:51:59BlaXpiritif I just replace "method" with "proc" it doesn't work - the function of base class is called, and the right one is just ignored
19:52:42Araqyes ... just like in c++?
19:52:47BlaXpiritno
19:53:05BlaXpiritin c++ i could just not use virtual at all and it would work
19:53:16BlaXpirit(until pointer to base class is involved)
19:54:36AraqI can't see how. can you make a gist?
19:54:54BlaXpiritof what
19:55:09EXetoCwhat's the difference? casting?
19:55:18BlaXpiritthere is no casting involved
19:55:45EXetoCnot in nimrod?
19:55:51BlaXpiritnowhere
19:55:55BlaXpiritwe are not talking about casting
19:56:40dom96Hah. Imagine if this gets accepted: http://www.freepatentsonline.com/y2014/0196008.html
19:56:53BlaXpiritcool story
19:56:55EXetoCthere is if you want to call the right overload
19:57:31EXetoCwhatever
20:01:20BlaXpirithttps://gist.github.com/BlaXpirit/222ab964824f3541f72a
20:01:22BlaXpiritAraq,
20:03:02*io2 quit (Quit: ...take irc away, what are you? genius, billionaire, playboy, philanthropist)
20:03:24EXetoCum, Base in the C++ code isn't used
20:03:34BlaXpiriti'm an idiot
20:04:08EXetoCis that a self-portrait?
20:04:09BlaXpiritupdated code, same thing
20:05:44Araqwell?
20:05:57EXetoCbut now TChild is never instantiated in the nimrod code
20:06:22BlaXpiritnow i'm really an idiot
20:06:55BlaXpiritso then, why doesn't it work in my code?
20:08:07BlaXpiritah but of course, because it's called by another method
20:09:55BlaXpiritso I really do need dynamic dispatch then
20:10:00BlaXpiriti'm sorry
20:12:18Araqno worries
20:19:19Skrylarmeep
20:20:44Skrylardom96: o_O are they trying to patent shit that erlang already did in the 90s?
20:20:51dom96Skrylar: yep
20:21:18Skrylarmeh. USPTO will accept it because they don't bother to check anything
20:21:24dom96If it succeeds I am going to patent the if statement.
20:21:26Skrylarand thanks to obama its now first to file instead of first to invent
20:21:33Skrylarbecause that makes TOTAL sense
20:21:47*io2 joined #nimrod
20:22:09Skrylar"our courts are full of patent litigation, we need reform" "ok, i will fuck you with a larger dildo" ":/"
20:22:17Skrylaranyway
20:22:38Skrylari would just eradicate patents wholesale if it were up to me; evidence does not show that they are statistically used for their stated purposes
20:23:15Skrylarand nature doesn't abide by them anyway
20:28:40*Mat3 joined #nimrod
20:28:43Mat3hello
20:35:15dom96hi Mat3
20:37:56Mat3hi dom96
20:38:31dom96Mat3: What's new?
20:41:44*io2 quit (Quit: ...take irc away, what are you? genius, billionaire, playboy, philanthropist)
20:42:38Mat3I'm working on a port of these little C compiler
20:45:44dom96awesome
20:48:14Mat3how can I include an external C function in Nimrod ?
20:49:06dom96http://build.nimrod-lang.org/docs/manual.html#importc-pragma ?
20:49:59Mat3thanks
20:50:45*gkoller quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
20:51:35*zahary quit (Quit: Leaving.)
21:02:59*UNIcodeX joined #nimrod
21:04:03UNIcodeXanyone in here who came from python?
21:07:42*Jesin joined #nimrod
21:10:11*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
21:11:40dom96UNIcodeX: yes
21:11:47dom96welcome :)
21:11:48*Johz quit (Ping timeout: 246 seconds)
21:12:00BlaXpirityes
21:12:02UNIcodeXdom96, thanks
21:12:20UNIcodeXare there any materials that you found particularly helpful in your migration?
21:12:45BlaXpiritthere are no materials, lol. get used to it
21:12:48UNIcodeXhaha
21:13:14UNIcodeXi'm very used to having tons of libraries at my disposal with python, so i'm trying to get used to the newness.
21:13:58UNIcodeXalright. cool. well y'all answered my questions.
21:14:03UNIcodeXi'll just hang out i suppose.
21:14:56dom96UNIcodeX: Best thing is to go through the tutorial, skim the manual, https://nimrod-by-example.github.io/, and to ask questions here.
21:15:11Skrylari use the manual and library reference; though i'm used to learning to program from dirt. xD
21:15:52Skrylartime to offend dom96's sensibilities with another jpg http://i.imgur.com/W09Rd4u.jpg :P
21:16:59BlaXpiritmy eyes
21:17:08dom96disgusting
21:17:23dom96#pngMasterRace
21:17:37Skrylarthe png is also huge
21:19:18Skrylaranyway as i suspected; a tiny-swatch based GUI does indeed seem to be very easy to customize
21:21:22*Ven joined #nimrod
21:33:01dom96Skrylar: What's this GUI thing for?
21:33:13Skrylardom96: same project as two days ago when you asked =p
21:33:33Skrylartrying to stave off my lisp pangs long enough to get it written though :(
21:33:53dom96lol, I can't even remember asking :P
21:34:11Skrylaralso i feel like a tiny hero every time emacs lisp does something xD
21:34:22Skrylarhad to move a proc so i went and added a nimrod-kill-proc
21:34:45Skrylartoo many more of these commands and it will end up just being a structural editor >_<
21:36:24VarriountUNIcodeX: Nice to see another Pythonista!
21:39:17UNIcodeXVarriount: :-) i have to go at the moment, but maybe i'll catch y'all tomorrow.
21:42:05Mat3(defun fun (x) (map x '(* x (sqrt (pot x)))))
21:43:49Mat3^a joke
21:44:28*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
21:48:51BlaXpirituhh but that problem with random number generation remains. have we decided on anything?
21:51:42VarriountBlaXpirit: It might be worth it to put the discussion of random number generation in a forum topic/github issue - it makes it easier for those in other time zones to discuss.
21:52:13VarriountBlaXpirit: Also, whats the problem?
21:52:22BlaXpiritforum, eh? i haven't even noticed any forum
21:52:34BlaXpiritVarriount, i've mentioned a few of them
21:52:35Varriountforum.nimrod-lang.org
21:52:37BlaXpiritbut the main one is
21:52:58BlaXpirit on Windows it will actually never generate a number above 32k, even if you want a random number from 0 to a billion
21:53:15BlaXpiritnot to mention just 15 bits of resolution
21:53:18VarriountWhy?
21:53:35BlaXpiritbecause rand() gives a number from 0 to 32k on windows
21:53:45BlaXpiritand the current implementation is rand() mod max -_-
21:54:13BlaXpiritalso bad seeding
21:54:58VarriountIsn't that what you were working on? Seeding the PRNG with a value from native sources?
21:55:25BlaXpiritthat's part of my new awesome library
21:55:28BlaXpirithavent u seen it?
21:55:42VarriountNo. I've been in classes and work all day.
21:55:50BlaXpirithttps://github.com/BlaXpirit/nimrod-random - it's the solution to everything
21:56:09BlaXpiriti'm looking for feedback and possibility to add it to Nimrod
21:56:16VarriountWhat PRNG algorithm does it use?
21:56:27BlaXpiritit's all there
21:56:39BlaXpirithttp://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
21:56:47BlaXpiritsame one that Python uses
21:57:00BlaXpirit(and it's largely a ripoff of Python's library, but whatever)
21:58:25VarriountBlaXpirit: It looks good (with a casual inspection)
22:00:46Skrylaroh!
22:00:51Skrylarmersenne twister has a caveat
22:01:14Skrylaryou can predict every future output given the previous 4k outputs, which is why roguelikes stopped using it
22:01:52VarriountI seem to remember some discussion on having a generic 'random number generation' module, to which multiple backends could be attached.
22:02:05BlaXpiritVarriount, and that's exactly what this is!
22:02:08SkrylarVarriount: i have one of those
22:02:40BlaXpiritalthough it perhaps could accept input in different ways
22:02:48BlaXpiritand not just random byte thing
22:03:03Skrylarnah a random alg produces random bits or ints
22:03:09Skrylaranything else you want to do is independent of that
22:03:16Skrylarjust remember to scale instead of modulo
22:03:34BlaXpirityou're saying obvious things
22:03:51*Skrylar dons the captain obvious shield and flies to the moon
22:03:57BlaXpiritmaybe what i said wasn't clear, but you understood it wrong
22:04:37BlaXpiritmy library allows you to make an RNG class if you just provide it with a "random byte" function
22:04:58BlaXpiritand optionally a "random 0<=n<1 float" function
22:05:10BlaXpiritso it doesn't have to make floats from those bytes
22:06:36*johnsoft joined #nimrod
22:07:15BlaXpiritVarriount, although maybe for a more comprehensive solution c++'s library could be inspected
22:07:21BlaXpiritbut it's so big and complicated
22:22:23*NimBot_ joined #nimrod
22:23:33*delian66 quit (Ping timeout: 255 seconds)
22:23:35jjapHi guys/gals. Question, the first: Anyone maintaining the homebrew formula for nimrod?
22:23:53*onionhammer quit (Ping timeout: 255 seconds)
22:24:15*onionhammer joined #nimrod
22:24:22*jez0990_ joined #nimrod
22:25:04*Trustable quit (Quit: Leaving)
22:25:46*seubert_ joined #nimrod
22:28:47*delian66 joined #nimrod
22:29:35dom96hey jjap
22:29:44dom96jjap: Not as far as I know.
22:31:19*enquora quit (Quit: enquora)
22:31:50jjapdom96: I see. Install process changed dramatically, and the formula is stuck at 0.9.2
22:38:41*NimBot joined #nimrod
22:38:41*Araq quit (Ping timeout: 261 seconds)
22:38:53*Araq_bnc joined #nimrod
22:39:06jjapIs there any interest in having multiple versions of nimrod install? Like Having Python2.5, 2.7, 3.3 (etc) installed; all binaries symlinked as python-X.X; and latest (orwhatver) additionally symlinked as simply python ?
22:39:18jjap*of nimrod installed?
22:42:19*TylerE quit (Ping timeout: 240 seconds)
22:42:37*delian66 quit (*.net *.split)
22:42:37*NimBot_ quit (*.net *.split)
22:42:37*BlameStross1 quit (*.net *.split)
22:42:38*saml quit (*.net *.split)
22:43:51*OrionPK quit (Read error: Connection reset by peer)
22:44:17*TylerE joined #nimrod
22:45:10*saml joined #nimrod
22:45:14*dom96 quit (Ping timeout: 240 seconds)
22:47:53*dom96 joined #nimrod
22:49:56*reloc0 joined #nimrod
22:55:07*BlaXpirit quit (Quit: Quit Konversation)
22:56:02*TylerE quit (Changing host)
22:56:02*TylerE joined #nimrod
22:56:34*OrionPK joined #nimrod
22:57:22*Mat3 quit (Quit: Verlassend)
23:00:40*jjap quit (Ping timeout: 246 seconds)
23:01:46*saml_ joined #nimrod
23:21:53*darkf joined #nimrod
23:22:03*brson quit (Quit: leaving)
23:22:12*brson joined #nimrod
23:55:32*xenagi joined #nimrod
23:57:07*brson quit (Quit: leaving)
23:57:37*brson joined #nimrod