<< 14-02-2018 >>

00:06:47FromGitter<sclee15> will newStringStream() supported in js back soon?
00:20:58FromGitter<brentp> @mratsim cheers re headers (from 3 days ago) I ended up just rewriting the macros as a template, but would like a simple solution. I'll look into those currentSourcePath solutions next time.
00:30:32*rauss quit (Quit: WeeChat 2.0.1)
00:30:36*yglukhov joined #nim
00:31:32*rauss joined #nim
00:35:13*yglukhov quit (Ping timeout: 248 seconds)
00:38:49FromGitter<mratsim> If you find it I’m interested as well, a forum post would be good :)
00:39:09FromGitter<mratsim> What can trigger this?
00:39:15FromGitter<mratsim> (https://files.gitter.im/nim-lang/Nim/OzsL/2018-02-14_01-36-56.png)
00:39:50*briank joined #nim
00:39:55FromGitter<mratsim> Load average: 400 >_>
00:50:05*d10n-work quit (Quit: Connection closed for inactivity)
01:06:42*endragor joined #nim
01:11:05*endragor quit (Ping timeout: 240 seconds)
01:33:40*yglukhov joined #nim
01:37:22bl4rkjust compiled latest dev and it works fine, but nimble is complaining about missing dlls
01:37:29bl4rkcould not load: (libcrypto-1_1-x64|libeay64).dll
01:37:37bl4rkis this normal?
01:38:05*yglukhov quit (Ping timeout: 255 seconds)
01:38:21bl4rk(on windows 10)
01:40:38bl4rkand installed with koch nimble
01:42:48*vlad1777d quit (Ping timeout: 256 seconds)
01:44:59FromGitter<Varriount> Relatively expected. You need openssl libraries
02:20:09*j_rod_s quit (Ping timeout: 264 seconds)
02:24:26*Tanger joined #nim
02:27:50*SenasOzys quit (Remote host closed the connection)
02:30:04bl4rkweird because it ran fine when i used the prebuilt binary
02:35:23*chemist69 quit (Ping timeout: 276 seconds)
02:35:28FromGitter<Varriount> bl4rk: The prebuilt binary has the dlls bundled
02:36:48bl4rkahh. makes sense, thanks
02:46:26*j_rod_s joined #nim
02:49:03*chemist69 joined #nim
02:52:30*yglukhov joined #nim
02:53:14*rinzai quit (Ping timeout: 252 seconds)
02:56:50*j_rod_s quit (Ping timeout: 276 seconds)
02:57:07*yglukhov quit (Ping timeout: 260 seconds)
03:04:13*JacobEdelman joined #nim
03:04:22JacobEdelmanwhat is the correct way to get the smallest item in a hashset in nim?
03:04:36JacobEdelmanam I supposed to be writing a whole for loop just for this?
03:19:23ieatnerdsI'm a bit of a simpleton, but is there really any other way to find the smallest item, without first checking that its the smallest?
03:22:38ieatnerdseven if nim has a built in to find the minimum, wouldnt it also just be iterating over the set ?
03:30:00*endragor joined #nim
03:31:14*ak102 joined #nim
03:31:37*ak102 is now known as Guest72761
03:34:21FromGitter<treeform> I think the discord bridge is down
03:36:51*rinzai joined #nim
03:38:06*Guest72761 quit (Quit: ZNC - http://znc.in)
03:38:21*ak102_ joined #nim
03:41:16*rinzai quit (Ping timeout: 252 seconds)
03:42:15*ak102_ quit (Client Quit)
03:42:41*ak_ joined #nim
03:43:24*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
04:06:24*yglukhov joined #nim
04:10:27*yglukhov quit (Ping timeout: 240 seconds)
04:10:50*xkapastel quit (Quit: Connection closed for inactivity)
04:14:01Demos[m]I think there's an ordered hashset someplace
04:14:09Demos[m]but the hashset datastructure
04:14:58Demos[m]the hashset datastructure doesn't support that operation, but there exist ordered hashsets that do
04:19:47JacobEdelmanMy issues is that
04:19:58JacobEdelmanI don't want to have to store the items in memory twice
04:20:17JacobEdelmanI can iterate over them but for-looping over . items
04:20:22JacobEdelmanAnd accumulating and such
04:21:10JacobEdelmanBut it feels like I should either be able to fold a function over them functional programming style, or just have some built-in min macro that deals with it
04:22:15ieatnerdscould try and keep track of the lowest value when you build the set?
04:24:08Demos[m]that's what an OrderedSet will do
04:24:58ieatnerdsand there we go
04:30:39*rinzai joined #nim
04:35:04*rinzai quit (Ping timeout: 256 seconds)
04:45:59radagast_04Consider I have initiated a `bin` project with nimble. Is there any way I can use the local libraries under its src/ in other projects?
05:04:31*radagast_04 quit (Ping timeout: 268 seconds)
05:05:26FromGitter<nitely> I think that's called an hybrid. It's explained in the readme
05:09:25*ak_ is now known as ak102
05:09:25*ak102 quit (Changing host)
05:09:25*ak102 joined #nim
05:10:39*miran quit (Ping timeout: 260 seconds)
05:10:42*j_rod_s joined #nim
05:16:33*j_rod_s quit (Ping timeout: 264 seconds)
05:24:26*rinzai joined #nim
05:29:35*rinzai quit (Ping timeout: 276 seconds)
05:29:38*radagast_04 joined #nim
05:40:25*BitPuffin joined #nim
05:47:52*yglukhov joined #nim
05:52:57*yglukhov quit (Ping timeout: 240 seconds)
06:02:48*endragor quit (Remote host closed the connection)
06:14:16bl4rkthis is commonly used in C to call shellcode: ((void (*)(void))shellcode)(); can anyone tell me what the Nim syntax for this would be
06:20:51*rinzai joined #nim
06:25:02*sz0 joined #nim
06:25:05*rinzai quit (Ping timeout: 248 seconds)
06:27:45*nsf joined #nim
06:38:19*endragor joined #nim
06:43:08*endragor quit (Ping timeout: 256 seconds)
06:44:05*solitudesf joined #nim
06:45:25*endragor joined #nim
06:54:25*j_rod_s joined #nim
07:03:35*trincyolo quit (Ping timeout: 240 seconds)
07:10:13*dddddd quit (Remote host closed the connection)
07:14:38*rinzai joined #nim
07:19:09*rinzai quit (Ping timeout: 265 seconds)
07:23:56*PMunch joined #nim
07:26:26FromGitter<mratsim> @bl4rk: shellcode? Is that bash/sh? You can use nimscript: https://nim-lang.org/docs/nimscript.html#exec,string
07:29:12*yglukhov joined #nim
07:30:00*kunev quit (Quit: е те!)
07:30:03Araqmratsim: it's for cracking things
07:30:34FromGitter<mratsim> Otherwise the equivalent seems to be: foo = nil. (void*)foo casting in C equals castpointer (foo) in Nim
07:30:59FromGitter<mratsim> Oh
07:34:00*yglukhov quit (Ping timeout: 256 seconds)
07:43:15*girvo joined #nim
07:45:23*miran joined #nim
07:49:36*yglukhov joined #nim
08:06:43*SenasOzys joined #nim
08:08:08FromGitter<mratsim> bringiton
08:08:25*rinzai joined #nim
08:12:49*rinzai quit (Ping timeout: 260 seconds)
08:20:12*rokups joined #nim
08:22:02*yglukhov quit (Read error: Connection reset by peer)
08:22:40*yglukhov joined #nim
08:23:52FromGitter<mratsim> oops wrong chat
08:24:08PMunchHaha, was wondering what that was about :P
08:34:28PMunchHmm, would it be useful to include a couple more const sets to the strutils module?
08:34:35PMunchLike uppercase, lowercase
08:38:48*floppydh joined #nim
08:39:31Araqno.
08:40:18PMunchWhy not?
08:41:42Araqbecause unicode
08:42:23*vlad1777d joined #nim
08:42:57PMunchHmm, ASCIIUppercase?
08:43:10PMunchOr UppercaseASCII
08:43:26Araq{'A'..'Z'} is shorter than that :P
08:43:36PMunchHaha, fair point :P
08:52:43*yglukhov quit (Remote host closed the connection)
09:02:18*rinzai joined #nim
09:07:04*rinzai quit (Ping timeout: 260 seconds)
09:17:53*gokr joined #nim
09:17:56*gokr left #nim (#nim)
09:26:43*rinzai joined #nim
09:28:03*yglukhov joined #nim
09:30:45*Vladar joined #nim
09:32:06PMunchHmm, some of the nre examples are broken
09:32:25PMunchhttps://github.com/nim-lang/Nim/blob/master/lib/impure/nre.nim#L165
09:32:32PMunchmatch returns an option
09:35:53Araqthis module should be .deprecated
09:36:18Araqand maybe nitely's regexes should become the new standard module
09:36:53Araqbut I haven't studied its API
09:37:07PMunchHmm
09:37:18PMunchWhat should I use to do my matching for AST generation then?
09:37:34Araqwhat do you need?
09:38:02PMunchNot much, match things like " TEST.hello "
09:38:36Araqstrip and == ?
09:38:36PMunchAnd comments like "/* anything else than */" and "// Anything but newline"
09:38:49PMunchYeah I've considered it
09:39:54*yglukhov quit (Read error: Connection reset by peer)
09:40:07Araqwe need a 'lexer' macro and a 'grammar' macro
09:40:31*yglukhov joined #nim
09:42:46*ofelas quit (Ping timeout: 256 seconds)
09:59:41FromGitter<nitely> @Araq "but I haven't studied its API" if you do, I'm open to suggestions
10:01:46FromGitter<nitely> @PMunch there is https://github.com/Araq/lexim but dunno what state it's in
10:01:54Araqlimbo state
10:02:10Araqsomebody needs to take over its development
10:02:13FromGitter<nitely> I'm mean how far is from useful
10:02:31Araqwrote a lexer for Pascal with it and it worked
10:04:43Araqit's ok but a bit messy to setup with the helper program that is staticExec'ed because Nim's VM is too slow
10:20:50Araqhttps://www2.cs.arizona.edu/icon/docs/ipd266.htm inspiring
10:23:48FromGitter<alehander42> https://www.reddit.com/r/programming/comments/7x9hjk/introduction_to_procedural_macros_in_rust_learn/du7wv5c/ ⏎ ⏎ seems people from other languages sometimes underestimate nim macros
10:27:17*chemist69 quit (Ping timeout: 256 seconds)
10:27:40*chemist69 joined #nim
10:30:16FromGitter<alehander42> ha, we studied Icon once in university (we had this not-compulsory ~semantics of prog langs class(effectively history of langs) and the guy was an absolute polyglot and showcased different ones each time)
10:31:42FromGitter<nitely> I was thinking about writing a DFA generator that generates code with goto's to go through states. It seems like that's what lexim does
10:31:45FromGitter<nitely> must be super fast
10:32:43FromGitter<nitely> @Araq is the VM that slow? I haven't notice when compiling regexes with nim-regex
10:39:42Araqit uses some O(n^3) optimization algorithm
10:39:53Araqso yes, it's really slow.
10:40:37Araqtime went from 1 minute to 3s or something when I made the algorithm run at native speed
11:06:19radagast_04man, nimsuggest needs a lot of work. Or probably my VSCode is not working well
11:09:10FromGitter<alehander42> while discussing in the reddit thread linked up, I was asked if nim macros can generate new types. I noted one can generate temporary ones, but if I think about it, you wouldn't be able to construct them out of the same macro.. is there another way to do it @Araq
11:11:08Araqhuh?
11:18:57*vlad1777d quit (Ping timeout: 264 seconds)
11:20:16*vlad1777d joined #nim
11:24:21FromGitter<alehander42> not very important :D anyway, I have to read a bit more about rust procedural macros, to see if they're really gonna compare somehow to nim ones
11:31:05*vlad1777d quit (Ping timeout: 240 seconds)
12:16:34*Snircle joined #nim
12:18:59*cspar quit (Ping timeout: 260 seconds)
12:32:16*clyybber joined #nim
12:33:02*sendell joined #nim
12:38:00*cspar joined #nim
12:44:41Araqhttps://github.com/Microsoft/vscode/issues/36630 this is becoming more and more annoying
12:47:36*cspar quit (Ping timeout: 252 seconds)
12:58:25*adeohluwa joined #nim
12:59:19adeohluwahow do u typically spit json object from jester?
13:05:14Araqinstead of HTML, produce JSON and set the HTTP header to 'json'
13:19:05PMunchnitely, sorry I was AFK. If lexim is in limbo I'll probably just write a simple character matcher and use combparser to do the combinations
13:19:21PMunchThat way I don't have to add another dependency as well
13:21:31PMunchalehander42, you can create types just fine. Or is there something I'm not understanding about your question
13:23:08FromGitter<alehander42> yes, you can, I was confused because I had a situation when I wanted to create top level type from non-top level macro, but otherwise it works fine, yeah
13:23:53PMunchAh yeah, that's a bit tougher :P
13:24:20*gokr joined #nim
13:25:39PMunchYou can sorta do it if you have one macro on top "generateTypes" which returns new code that on the next pass generates the types based on what other macros in the first pass added to a global static structure
13:25:41PMunchI think
13:29:09FromGitter<alehander42> https://www.reddit.com/r/programming/comments/7x9hjk/introduction_to_procedural_macros_in_rust_learn/du88u48/ the question in the last comment here, basically are all macros expanded *while* semantically checking the code (or untyped macros are expanded immediately and typed ones after typecheck, invoking typecheck for their result again?)
13:29:26FromGitter<alehander42> I realized I am not sure how this works internally
13:37:36PMunchHmm, it seems like he's talking about typed vs. untyped in Nim. But not 100% sure
13:51:29*yglukhov quit (Ping timeout: 276 seconds)
13:53:45*gokr quit (Read error: No route to host)
14:14:23*yglukhov joined #nim
14:23:48*clyybber quit (Ping timeout: 240 seconds)
14:48:45*fvs joined #nim
14:55:47*miran_ joined #nim
14:56:06*yglukhov quit (Read error: No route to host)
14:57:40*yglukhov joined #nim
14:59:55AraqtakesUntyped(reduce(x)) # gets 'reduce(x)'
15:00:06*kunev joined #nim
15:00:09AraqtakesTyped(reduce(x)) # gets 'y' where y = reduce(x)
15:00:39Araqalehander42: the macro result is checked either way (it has to, macros can do dangerous things)
15:01:06Araqthe difference is only "input is sem'checked" vs "input is not sem'checked"
15:01:46Araqand soon we'll have "input is semi-checked" too for much better composition of macros
15:04:59fvsneed advice on howto binarySearch a seq[tuple[id,hash]] sorted on hash. I would like to do the binarySearch on the hash. Currently splitting these tables into seq[id], seq[hash] after sorting to achieve this, which seems overkill.
15:06:03radagast_04For array of size <= 4, glibc uses insertion sort
15:06:18Araqthere is little you can do about it except copy and adapt binarySearch
15:06:49Araqfortunately it's short.
15:07:14Araqonce the stdlib is conceptilized these things will be better
15:13:39planetis[m]ok dumb question: How comes rand(float) return a number in 0..max whereas random(float) in 0..<max while the have the same logic? https://github.com/nim-lang/Nim/blob/devel/lib/pure/random.nim Lines 99 and 141.
15:15:10Araqthat's a bug, I have no clue how to write rand() for float including the max
15:15:26Araq:D
15:15:44Araqprobably we should just remove it, who needs random floating point values anyway
15:16:29planetis[m]should a make a Pr to change the docs to say 0..<max ?
15:16:36planetis[m]but it will be inconsistent with the rest
15:17:22miran_"who needs random floating point values anyway" :raises_hand:
15:17:31planetis[m]or de-deprecete random for floats?
15:18:50planetis[m]#metoo
15:19:53*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
15:20:06FromGitter<data-man> @Araq: stdlib's new concept is exist? :)
15:21:31FromGitter<krux02> Araq: is there an equivalent of `#error` and `#warning` that is implemented in a lot of C/C++ compilers?
15:23:01FromGitter<krux02> Araq: never mind I found them
15:25:01*endragor quit (Remote host closed the connection)
15:26:24*PMunch quit (Quit: Leaving)
15:27:44*arnetheduck quit (Ping timeout: 256 seconds)
15:27:44planetis[m]I will look how python does it and make a PR
15:27:50planetis[m]in random.uniform
15:28:04*endragor joined #nim
15:29:15*chemist69 quit (Ping timeout: 265 seconds)
15:29:35shashlickhey araq, did you and dom96 decide on the trunk based or branch based development model going forward?
15:30:11FromGitter<krux02> I also need random float values.
15:30:59FromGitter<krux02> generally random float is very easy
15:31:21*chemist69 joined #nim
15:32:31*endragor quit (Ping timeout: 256 seconds)
15:33:07Araqshashlick: no. But trunk based has no alternative IMO. easily 50-80% of my changes would apply to 1.0
15:33:42Araqcherry-picking that much is not gonna work.
15:35:06Araqmaybe if we update the 1.0.x branch and merge into 1.1.x
15:35:08FromGitter<krux02> just create random bits in form of `uint` then there is an asm instruction that finds the index of the first 1-bit in that random bits seq. Then bitshift that part, then bitshift it, so the randome bits fit in the mantissa of the float but make sure the first one is cut off. then store the number of bits shiftet as a negative exponent of the number. Then there is the rare case that you actually only got only zero bits.
15:35:08FromGitter... needs to be handled bit it is unlikely
15:35:58*yglukhov quit (Remote host closed the connection)
15:36:59FromGitter<krux02> this creates random numbers between [0,1[
15:37:06FromGitter<krux02> for other ranges one needs to multiply
15:39:08FromGitter<krux02> wait a moment since whes does rand include the upper bound for floating point values?
15:39:21*yglukhov joined #nim
15:40:28planetis[m]it doesn't but the documentation says it does
15:40:43FromGitter<krux02> well it does include the upper bound
15:41:00FromGitter<krux02> `(float(x) / float(high(uint32))) * max` does include the upper bound
15:42:07*Jesin joined #nim
15:42:12planetis[m]thats for js what about the code below that?
15:42:24*dddddd joined #nim
15:42:35planetis[m](I just ask for your opinion personally Idk)
15:43:37planetis[m]shouldn't it be "result = cast[float](u) * max"?
15:44:00*yglukhov quit (Ping timeout: 268 seconds)
15:44:27FromGitter<krux02> cast will reinterpret the integer bits as a floating point value
15:47:48planetis[m]currently it is: result = (cast[float](u) - 1.0) * max
15:48:33planetis[m]i thought that -1.0 make the range [0,1)
15:51:12FromGitter<alehander42> @Araq ok, thanks, I'll try to summarize it then (I just hope no rust devs in that thread take inspiration to add further stuff to rust macros 2.0 :D )
15:52:06shashlickaraq: makes sense, so is it worth saying that for the near future, proceed with trunk based and re-evaluate once 1.0 comes out
15:54:30FromGitter<krux02> planetis[m]: yes you are right
15:54:30Araqshashlick: I wrote a 'since' macro that can do version selections but system.nim can't use macros...
15:55:42*clyybber joined #nim
15:55:42*clyybber quit (Client Quit)
15:55:57*clyybber joined #nim
15:55:57*clyybber quit (Client Quit)
15:56:12*clyybber joined #nim
15:56:12*clyybber quit (Client Quit)
15:56:12Araqhttps://gist.github.com/Araq/f41cb3ca3441303a2808a9389650efda
15:56:22FromGitter<andreaferretti> @planetis[m] there is really no difference, isn't it?
15:56:27*clyybber joined #nim
15:56:27*clyybber quit (Client Quit)
15:56:38FromGitter<andreaferretti> a uniform distribution on an interval will give 0 mass to each point
15:56:42*clyybber joined #nim
15:56:42*clyybber quit (Client Quit)
15:57:05FromGitter<andreaferretti> now, you could argue that floating point reals only have a finite number of values
15:57:10*clyybber joined #nim
15:57:10*clyybber quit (Client Quit)
15:57:12Araqrandom floats are weird. why not produce random fractions instead?
15:57:18*clyybber joined #nim
15:57:18*clyybber quit (Client Quit)
15:57:32FromGitter<andreaferretti> random floats are extremely common
15:57:33*clyybber joined #nim
15:57:33*clyybber quit (Client Quit)
15:57:40FromGitter<andreaferretti> probablity distributions are just that
15:57:44FromGitter<andreaferretti> they are everywhere
15:57:49*clyybber joined #nim
15:57:49*clyybber quit (Client Quit)
15:57:55FromGitter<krux02> random floats are almost the only floats that I use
15:58:05*clyybber joined #nim
15:58:05*clyybber quit (Client Quit)
15:58:10FromGitter<krux02> I mean the only random numbers
15:58:12miran_hey andreaferretti! i have a couple neo questions :)
15:58:24FromGitter<krux02> very useful in computer graphics
15:58:27Araqwell I stand by my words.
15:58:43FromGitter<andreaferretti> also in machine learning, differential equations
15:59:08FromGitter<andreaferretti> lattice cryptography
15:59:28planetis[m]i guess not I was just trying to make my nim program output the same results as the python exercise
16:00:02Araqit really doesn't matter how often you use them, they are weird. and probably cause some non-uniform behaviour down the road.
16:00:15FromGitter<andreaferretti> if the python exercise relies on the fact that a uniform distribution on [0,1] differs from a uniform distribution on [0,1[ it is making something wrong
16:00:54miran_Araq: you are trying to go against whole world ;)
16:01:00FromGitter<andreaferretti> floating points are weird for that matter
16:01:13FromGitter<andreaferretti> but as long as we use them to model the real numbers
16:01:16*gokr joined #nim
16:01:17Araqthere are more numbers in 0.0 .. 1.0 than in 1000_000.0 .. 1000_001.0
16:01:20FromGitter<andreaferretti> random floats are going appear
16:01:26Araqor something like that.
16:01:35FromGitter<andreaferretti> yeah, that is true
16:01:46FromGitter<krux02> there are programming languages that call floating point numbers `real`.
16:01:56FromGitter<krux02> that is just wrong
16:02:00FromGitter<andreaferretti> this is not a big impediment to producing a uniform distribution
16:02:02Araqkrux02: yep.
16:02:45FromGitter<andreaferretti> @miran_, please ask, I hope I will be able to answer :-)
16:02:54miran_you surely will
16:03:33Araqthe mythical real numbers which consist almost entirely of numbers that cannot be named
16:03:54miran_first of all - what a great job did you do with it!! yesterday i started converting some of my numpy examples and for some things i found neo easier than numpy (which i'm much more familiar with)
16:04:07FromGitter<andreaferretti> happy to hear that!
16:04:18Araquncountably many of them. nobody ever saw one, but they are out there. really.
16:04:23miran_but, on the other hand, i was struggling to make some things work. for example:
16:05:03miran_A = [[1, 2], [3, 4]]; B = zeros(100, 100)
16:05:06Araqand you can re-arrange them to produce 2 balls of the same volume as the starting ball
16:05:27miran_i didn't know how to do: B[0 .. 1, 0 .. 1] = A
16:06:08miran_or how to make one row/column of the matrix to be equal to some known vector of that dimension
16:06:25FromGitter<andreaferretti> let me see if I remember
16:06:36FromGitter<andreaferretti> for sure you can take slice of matrice
16:06:45FromGitter<andreaferretti> so what you miss is a copy operation
16:07:00FromGitter<andreaferretti> let me check that, I think it should be there
16:07:19miran_yeah, taking a slice works, but assigning to a slice is what i struggled with
16:10:02Araqhttps://en.wikipedia.org/wiki/Banach%E2%80%93Tarski_paradox
16:10:21FromGitter<andreaferretti> @miran_ you are right, it seems it is missing
16:10:29FromGitter<andreaferretti> it should be easy to add though
16:10:38FromGitter<andreaferretti> essentially it is a single blas copy operation
16:10:54FromGitter<andreaferretti> similar to what you have here
16:10:55FromGitter<andreaferretti> https://github.com/unicredit/neo/blob/master/neo/dense.nim#L520
16:11:13FromGitter<andreaferretti> neo should expose `copy` for your use case
16:11:38miran_ok, one more thing i found missing is `+` between vector and float. you can do `3.5 * v1`, but you can't `3.5 + v1`
16:11:59FromGitter<andreaferretti> and overload `[]=` to make `A[S] = B` a template for `copy(A[S], B)`
16:12:30FromGitter<andreaferretti> the latter one makes sense, you cannot add a scalar to a vector :-)
16:12:56miran_true :) should that be `|+|`?
16:13:09FromGitter<andreaferretti> you can write something like
16:13:50FromGitter<andreaferretti> template `+`A: SomeReal (v: Vector[A], k: A) = v + constantVector(k, v.len)
16:14:00FromGitter<andreaferretti> untested, but it should work
16:14:17miran_thanks, will use that
16:14:36FromGitter<andreaferretti> or you can write such small functions with loops
16:14:45miran_that's what i did :)
16:15:01FromGitter<andreaferretti> unlike python, it will be fast
16:15:02planetis[m]last question: is there a point in making a PR to remove -1.0 from https://github.com/nim-lang/Nim/blob/devel/lib/pure/random.nim#L141 or not?
16:15:13miran_and i also used loops instead of that slice assign
16:15:32FromGitter<andreaferretti> for slice assign, could you open an issue?
16:15:38miran_will do
16:15:51FromGitter<andreaferretti> it is easy but I cannot do it right now, and I will forget
16:15:59FromGitter<andreaferretti> or a PR if you have time :-)
16:16:16miran_i have a time, but i don't have enough knowledge
16:16:49miran_that thing you said about using blas copy - i have no idea how that works :D
16:17:05FromGitter<andreaferretti> if you want, read the README to figure out the data structure for a matrix
16:17:48FromGitter<andreaferretti> it should be easy
16:17:56miran_i have read the readme and source code - the latter was very helpful exercise - answered couple of my initial questions
16:18:00FromGitter<andreaferretti> otherwise jsut the issue is fine, I will get to that
16:18:08*Trustable joined #nim
16:18:34miran_e.g. why `len(v1)` doesn't work, but `v1.len` does, how to get nr. of rows/cols of matrix, etc.
16:18:53*fvs left #nim ("ERC (IRC client for Emacs 25.3.1)")
16:19:02FromGitter<andreaferretti> copy takes five arguments: how many elements, source pointer to start from, offset between source elements, target pointer, offset between target elements
16:19:23*SenasOzys quit (Remote host closed the connection)
16:19:52FromGitter<andreaferretti> http://www.netlib.org/lapack/explore-html/de/da4/group__double__blas__level1_ga21cdaae1732dea58194c279fca30126d.html#ga21cdaae1732dea58194c279fca30126d
16:20:00FromGitter<andreaferretti> if you a re curious
16:20:09miran_i am, will take a look
16:20:46FromGitter<andreaferretti> @planetis[m] I have no idea where `let u = (0x3FFu64 shl 52u64) or (x shr 12u64)` comes from
16:21:05FromGitter<andreaferretti> hence I have no idea whether it makes sense to subtract 1.0 from it
16:21:25*SenasOzys joined #nim
16:23:44*gokr quit (Read error: No route to host)
16:24:01FromGitter<krux02> @andreaferetti there should be a comment
16:24:16FromGitter<krux02> just look at https://de.wikipedia.org/wiki/IEEE_754
16:24:30FromGitter<krux02> it is a trick to fill the mantissa of the floating point number with random bits
16:25:01FromGitter<krux02> then you have in binary 1.XXXXXXXXX
16:25:24Araqзагорает
16:25:29FromGitter<krux02> when you subtract one, the rusult will be in [0 1)
16:25:33Araqwhat does it mean?
16:25:39FromGitter<andreaferretti> but will it be uniform?
16:25:44FromGitter<krux02> yes
16:25:51Araqah never mind
16:25:52*yglukhov joined #nim
16:26:08FromGitter<andreaferretti> > **<planetis[m]>** last question: is there a point in making a PR to remove -1.0 from https://github.com/nim-lang/Nim/blob/devel/lib/pure/random.nim#L141 or not?
16:26:21FromGitter<andreaferretti> it seems not, according to @krux02 answer
16:26:22FromGitter<krux02> in [1,2) floating point values are uniform distributed
16:26:33FromGitter<andreaferretti> nice trick
16:27:56FromGitter<andreaferretti> I still think that distinguishing between [0,1] and [0,1[ for the purpose of producing random numbers is not really meaningful
16:28:18FromGitter<krux02> there are as many floating point values between `[1,2)` and `[2,4)` and `[4,8)` etc
16:28:27FromGitter<krux02> well it is
16:28:50FromGitter<andreaferretti> is it?
16:28:57AraqI still think there are no exclusive bounds in programming :-)
16:29:04FromGitter<krux02> the probability of 1 is higher the lower the precision of the floating point number is
16:29:17FromGitter<andreaferretti> what I mean is
16:29:18Araqyou always have bits, you can always do <=
16:29:43FromGitter<andreaferretti> is there any application where using one makes sense and the other does not?
16:29:48Araqand < N is really <= N-1
16:30:18FromGitter<krux02> Araq: only for ℕ
16:30:25FromGitter<krux02> I mean ℤ
16:30:52*yglukhov quit (Ping timeout: 268 seconds)
16:31:04Araqthere is nothing else. floats are fiction.
16:31:16*floppydh quit (Quit: WeeChat 2.0.1)
16:31:42Araqthere is a number X so that < Z can be written as <= X for every float.
16:31:53Araqit's just that X is really hard to write sometimes.
16:33:49FromGitter<krux02> well for infinite precision a random number in the range [0,1] has the propability of 0 to become 1
16:33:57FromGitter<krux02> same goes for all other numbers
16:34:39FromGitter<andreaferretti> this is my point
16:34:58FromGitter<andreaferretti> usually floats are used as an imprecise model for the reals
16:35:11FromGitter<andreaferretti> and for the reals, it would not matter
16:35:23FromGitter<krux02> all I want to say is, all random nuber generaters for floating point values exclude the upper bound, I use random float values, and including the upper bound would create rare cases that I never covered, meaning nondeterministic crashes.
16:35:32FromGitter<krux02> I don't want this at all.
16:35:46FromGitter<krux02> I was wrong with "all"
16:35:49Araqyou wanted inclusive upper bounds in random for consistency
16:36:01FromGitter<krux02> but I mean all that I have worked with
16:36:09FromGitter<krux02> for integers, yes
16:36:16FromGitter<krux02> not for floats
16:36:23FromGitter<krux02> seems strange, I know
16:36:25Araqfor floats the same argumentation holds
16:36:34FromGitter<krux02> but that is exactly what I think is correct
16:36:43AraqI cannot get an inclusive upper bound when MAX is meant to be exclusive
16:37:04FromGitter<andreaferretti> the point is
16:37:12FromGitter<andreaferretti> leave rand exclusive for floats
16:37:16FromGitter<andreaferretti> it is easier
16:37:19FromGitter<krux02> yes
16:37:31FromGitter<krux02> and consistent with c++11
16:37:34FromGitter<andreaferretti> and if any application relies on actually ever getting the MAX exactly
16:37:45FromGitter<andreaferretti> it is written wrong
16:38:21FromGitter<krux02> and you can say about c++ a lot. A lot of bad design decisions, but since c++11 they only were really careful about choosing what to add. And they added good stuff
16:39:40Araqok, fine
16:39:53*endragor joined #nim
16:40:01Araqso we'll just fix the docs to mention for floats it's an exclusive upper bound
16:40:10FromGitter<krux02> yes
16:40:13Araqbut it's inconsistent and a bad idea.
16:40:36planetis[m]so all there needs to be done is to change the documentaion for rand(float) to say the range is exclusive
16:40:36FromGitter<krux02> well I like to disagree. But do you use random floating point values?
16:40:47Araqbecause I cannot easily get an inclusive upper bound which is what I might want for testing
16:41:09FromGitter<andreaferretti> even if you could
16:41:18miran_andreaferretti: i get a lots of these warnings:
16:41:19FromGitter<andreaferretti> you would not get this value in tests
16:41:20miran_"rewriteLinearCombinationMut(self.A[i, j], s, row(k, j)) --> '; linearCombinationMut(self.A[i, j], s, row(k, j))' [Pattern]"
16:41:27FromGitter<krux02> and the javascript version needs to be changed
16:41:39Araqif I claim my code for work for 0.0 .. 1.0 then 1.0 better should work too
16:42:15FromGitter<andreaferretti> @miran_ I have not used neo lately, but they should be just warning from NIm compiler
16:42:21FromGitter<andreaferretti> some operations are rewritten
16:42:29FromGitter<andreaferretti> to combine them into more efficient ones
16:42:39miran_ah, ok
16:42:56FromGitter<andreaferretti> when I used neo there were no explicit warning if I recall correctly
16:43:08FromGitter<andreaferretti> but the rewrites are intentional
16:43:15FromGitter<andreaferretti> actually there should be more
16:43:29FromGitter<andreaferretti> sometimes a pattern is detected where one can avoid intermediate results
16:43:36FromGitter<andreaferretti> and optimize that a bit
16:44:37miran_thanks, will look into that
16:44:41*Jesin quit (Quit: Leaving)
16:46:45FromGitter<andreaferretti> this is the manual https://nim-lang.org/docs/manual.html#term-rewriting-macros
16:47:12*miran_ quit (Quit: Konversation terminated!)
16:48:09*miran_ joined #nim
16:56:05*yglukhov joined #nim
16:59:59shashlickaraq: your since macro seems interesting, so it can still be used in stdlib, just not in system.nim?
17:00:37*yglukhov quit (Ping timeout: 260 seconds)
17:11:52*nsf quit (Quit: WeeChat 2.0.1)
17:14:32*endragor quit (Remote host closed the connection)
17:17:30*adeohluwa quit (Quit: Connection closed for inactivity)
17:38:19*nsf joined #nim
17:42:35miran_andreaferretti: one more question and i'll stop (for today :)) - i've tried to compile my code with both `-d:blas=openblas` and the usual `-d:release`. the latter is about 7x faster!
17:43:07miran_is this expected? or is this because my code is mostly regular nim and just some operations use blas?
17:45:52*rockcavera joined #nim
17:46:31miran_for all interested - i tried to translate my python/numpy code to nim/neo, to see if there are any speed improvements (both numpy and neo use BLAS and should be roughly the same speed)
17:47:01miran_anybody wants to guess the speed improvements, and if there are any at all?
18:00:51*joebo quit (Quit: WeeChat 1.1.1)
18:04:54*sendell quit (Remote host closed the connection)
18:14:18Demos[m]If it was like straight line code with big array operations I’d expect bumpy to be marginally faster
18:14:36Demos[m]If there were lots of little arrays then I’d expect nim to be much faster
18:31:15miran_Demos[m]: it is numerical integration problem, so basically one big loop which increases time steps one by one, and in each time step you solve some equations
18:31:59miran_i expected to see improvements in that looping part, but had no clue what % improvement to expect
18:33:34miran_in the end, nim vas 30x faster!!!
18:33:52miran_that's not 30%, it is 30x!
18:37:50miran_THIS. CHANGES. EVERYTHING.
18:47:54FromGitter<krux02> miran_: yea and people argue that they need multithreading to solve thear speed bottlenecks in python programs
18:48:15FromGitter<krux02> they need to change their language :P
18:48:58miran_krux02: if only i could solve these equations without knowing previous values, multithreading/multiprocessing would be useful :)
18:50:37miran_krux02: the next plan is to compare nim with numpy+numba.jit - if there nim shows such a huge speed dominance, this will be huge news!!
18:53:29*TakeYourFreedom joined #nim
18:54:05FromGitter<krux02> well there is also julia for numerical values
18:54:46FromGitter<krux02> and numby is not necessarily very slow, it has blas under the hood, but that cal only be an advantage, when you actually provide blas big execution chunks
18:55:37miran_krux02: i have never tried julia (i had the plan to do it before i discovered nim), but i try to avoid numerics-only languages (like matlab) and prefer general purpose ones
18:55:54FromGitter<krux02> good argument
18:56:03FromGitter<krux02> that is also why I did stay away from it.
18:56:28miran_and the slowness is not because of numpy, but because of loops in python are relatively slow
18:56:49FromGitter<krux02> but for scientific applications, not realtime, julia really could get a dominance.
18:56:59miran_things that can be vectorized are in numpy, but that time loop must be (a singlethreaded) loop
18:57:35FromGitter<krux02> yes, loops in python are slow, when you can transform the loop into a bigger problem that can be solved with blas, then you might get a speed improvement
18:57:43FromGitter<krux02> but that is always the case.
18:57:58FromGitter<krux02> I like to compare that with a saltstick factory.
18:58:18miran_i have no idea what that is :)
18:58:50FromGitter<krux02> saying 1_000_000 times make me a saltstick, vs saying 1 time make me 1_000_000 saltsticks.
18:59:30FromGitter<krux02> it is not only the overhead of `saying`, but also that a big chunk problem can be solved faster.
18:59:45miran_re julia: it has much bigger audience/adoption than nim, although it is also in pre-1.0 phase. i guess it is because they are focused only on scientific applications
19:00:03miran_thanks for clarification, makes sense
19:00:06FromGitter<krux02> well matlab is expensive :P
19:00:30miran_matlab should be put on fire and left to die
19:00:31*Ven`` joined #nim
19:00:44FromGitter<krux02> well I like the documentation of matlab.
19:01:33FromGitter<krux02> I once had a matlab license, I was only allowed to use it while I was connected to the internet. So when I had network problems, matlab closed automatically.
19:01:45FromGitter<krux02> not the best when you are not on a wired connection.
19:02:55miran_see my last comment
19:03:10Amun_RaI have an object of packed fields, what's the best way to fill it with data from file?
19:03:57*Ven` joined #nim
19:03:59FromGitter<krux02> Amun_Ra: a loop
19:03:59*yglukhov joined #nim
19:05:18*Ven` quit (Read error: Connection reset by peer)
19:05:23Amun_RaI mean the object contains a few cuints, cushorts, etc. I was thinking of a way to fill those at one step; with readBuffer or something similar
19:05:50*Ven` joined #nim
19:08:07*Ven`` quit (Ping timeout: 268 seconds)
19:09:42*SenasOzys quit (Remote host closed the connection)
19:10:22*yglukhov quit (Remote host closed the connection)
19:10:25Amun_RaI can't find an equivalent of struct s {unsigned x; short y;}; struct s s1; fread(&s1, …); I guess I have to read and fill it field by field
19:10:54*sz0 quit (Quit: Connection closed for inactivity)
19:11:24*BitPuffin quit (Remote host closed the connection)
19:12:29mrshuhi guys, is there any way of getting the absolute path of a symlink?
19:13:58*SenasOzys joined #nim
19:18:33mrshuI've tried explandFilename but that also follows the symlink
19:21:01*Ven` quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
19:22:41*Ven`` joined #nim
19:31:18*miran_ quit (Quit: Konversation terminated!)
19:39:44FromGitter<Quelklef> Is there anyway to allow Nim files with the same name? I'm trying to do quasi-bootstrapping and it's stopping me.
19:47:57*j_rod_s quit (Ping timeout: 240 seconds)
19:52:29*chemist69 quit (Ping timeout: 255 seconds)
19:52:52*chemist69 joined #nim
19:53:22*yglukhov joined #nim
19:56:34*Snircle joined #nim
19:58:51*d10n-work joined #nim
20:00:32Araqshashlick, that is correct
20:03:32AraqAmun_Ra, I don't understand your question, you already found readBuffer
20:03:48shashlickaraq: looks like more stuff needs to move out of there. How about the compiler itself? Do you see a need for version specific variation there?
20:04:33Araqshashlick, what do you mean? stdlib requires 'whens' (or 'since' annotations), compiler requires 'ifs'
20:05:09AraqI made NimMajor etc .intdefine so these can be set from the command line or configuration
20:05:23Araqthe compiler needs to look at these for its internal version checking
20:05:55Araqthat requires a helper proc
20:09:57Amun_RaAraq: you are right, my mistake was using ptr instead of addr
20:12:26FromGitter<tyrion> Hello, this function definition compiles, but then I cannot use it: `proc test(x: openArray[int]): auto = x` is there a way to make it work? Let's say I want to define a function that works for every array and that returns a copy of the array with first and last elements swapped
20:12:58Araqit shouldn't compile.
20:13:32*Ven`` quit (Read error: Connection reset by peer)
20:13:35Araqproc swapAll[I, T](x: array[I, T]): array[I, T]
20:13:52Araqproc swapAll[T](x: seq[T]): seq[T]
20:13:58Araqis what you need.
20:14:02FromGitter<tyrion> umh, it doesn't compile, I was wrong
20:14:09Araqyou can share the proc bodies via a template
20:15:12*tyrion-mx joined #nim
20:15:14Araqor you define an inplace swapAll
20:15:27Araqproc swapAll[T](x: var openarray[T])
20:15:46*Ven`` joined #nim
20:15:47AraqI think the random module has shuffle already
20:15:58shashlickaraq: okay that's cool then - looks like including that macro into nim goes a long way in supporting trunking beyond stdlib, packages, etc.
20:16:18tyrion-mxAraq, sorry gitter was messing with your code and I couldn't understand. Could you post it again pls?
20:16:43Araqshashlick, not really :-) 'nim doc' eliminates the .since
20:17:10Araqwhich works but is suboptimal. one set of docs for every version would be cool
20:17:37Araqevery proc should have some *since x.y.z* annotation
20:18:13Araqtyrion-mx, http://irclogs.nim-lang.org/
20:18:23tyrion-mxthanks
20:19:28shashlickaraq: I guess we could write some code to identify which nim release a proc came out in and use nimgrep to append it to the code or something
20:19:42shashlickapart from the nim doc fix of course
20:21:44Araqto "fix" nim doc means to make nim aware of what 'since' means
20:21:52Araqin other words I need to make a builtin
20:22:19Araqand then it works in system.nim too, but it's yet another pragma
20:22:41Araqnot sure what to do :-(
20:22:46shashlickI see
20:24:44Araqmaybe we should use versionized docs and when it's easy enough to switch between them we don't need to have this all in one file
20:25:25Amun_Rawhich approach would you recommend in nim? https://hastebin.com/nokijupudo.nim
20:25:49Araqhttps://docs.oracle.com/javase/7/docs/api/java/io/File.html#setWritable(boolean)
20:26:07AraqJava seems to do what I have in mind
20:27:33Araqhmm I think I'm overthinking this
20:28:56federico3Amun_Ra: the latter looks more readable and you can reuse readLeUint* elsewhere. FYI https://github.com/xomachine/NESM
20:30:46Araqshashlick, we can run the docgen for the latest version and either write ## *Since version 1.0* everywhere or we extract this somehow
20:31:14shashlickaraq: how much effort is it to implement this as a pragma? seems like "since" is a pretty core function and needs to be understood by the compiler instead of an overlay. sorry I'm not aware of how the compiler works to compare with your macro implementation
20:31:19Araqhmm the since macro can patch the proc's doc comment
20:31:41Araqyeah, I think the since macro can just patch the doc comment
20:31:50Amun_Rafederico3: thanks, I like #2 too, it'll be for reading a few different chunks of some binary format
20:31:57Araqand then we don't have to make the compiler aware of it
20:32:11shashlickaraq: how much effort is it to implement this as a pragma? seems like "since" is a pretty core function and needs to be understood by the compiler instead of an overlay. sorry I'm not aware of how the compiler works to compare with your macro implementation
20:32:34Araqit's cooler as a macro, no?
20:32:50Araqas a pragma it's actually somewhat hard to implement
20:33:17Araqsince usually the builtin pragmas don't cut whole procs out of the syntax tree
20:33:27Araqthere is no logic for that in the compiler.
20:33:40shashlickdoesn't seem worth the effort then - I can write some code to figure out when a proc was introduced from past versions
20:34:38shashlickwill be harder to figure out if a proc gets moved from one file to another
20:35:15shashlickof course, I need to understand how to use the compiler package to parse files and get proc signatures, etc. and if they are impacted from variable name changes
20:36:03Araqhuh? what are you working on?
20:37:32shashlicknothing yet, but we could figure out which past release a given proc was introduced by parsing older versions on github
20:37:58shashlickand figure out the {.since.} signature of most of them
20:38:46*miran_ joined #nim
20:39:30*TakeYourFreedom quit (Remote host closed the connection)
20:43:58*yglukhov quit (Remote host closed the connection)
20:56:17*miran_ quit (Quit: Konversation terminated!)
20:58:52*rokups quit (Quit: Connection closed for inactivity)
21:06:24FromGitter<krux02> Amun_Ra: sorry I had to leave the office, In nim you have a loop that iterates over the fields of a struct. Internally the compiler just completely unrolls that loop but it will help you to do what you want.
21:06:47FromGitter<krux02> you can also generate that code with a macro and the reflection library.
21:16:17*Ven`` quit (Ping timeout: 265 seconds)
21:18:42*nsf quit (Quit: WeeChat 2.0.1)
21:23:37*Trustable quit (Remote host closed the connection)
21:31:55*Ven`` joined #nim
21:39:51FromGitter<mratsim> Coming after the war but, huh without random floats there is no machine learning/deep learning. Actually I would love to have several other random distributions. ⏎ ⏎ And in my experience Python+Numpy was faster than Julia for my basic use case + Python is saner than Julia syntax-wise (except for the operator overloading)
21:45:52*Snircle quit (Ping timeout: 252 seconds)
21:46:05*Ven`` quit (Ping timeout: 240 seconds)
21:47:02*Snircle joined #nim
21:51:38*Ven`` joined #nim
21:52:42*gokr joined #nim
21:58:56*solitudesf quit (Ping timeout: 268 seconds)
21:59:33*Snircle_ joined #nim
22:00:44*vlad1777d joined #nim
22:01:33*Ven`` quit (Ping timeout: 264 seconds)
22:01:49*Snircle quit (Ping timeout: 256 seconds)
22:04:58*vlad1777d quit (Client Quit)
22:05:07*Ven`` joined #nim
22:05:14*Ven`` quit (Client Quit)
22:19:28*vlad1777d joined #nim
22:32:48*Vladar quit (Quit: Leaving)
23:04:04FromGitter<krux02> @mratsim https://github.com/krux02/opengl-sandbox/blob/master/fancyglpkg/ziggurat_normal_dist.nim
23:13:30*j_rod_s joined #nim
23:14:53FromGitter<mratsim> oh nice
23:15:11FromGitter<mratsim> Everytime i see Ziggurat, I think Warcraft 3 ...
23:18:34*j_rod_s quit (Ping timeout: 265 seconds)
23:35:33FromGitter<krux02> no me I only played Warcraft 2
23:55:15FromGitter<mratsim> In nimscript there is a mvFile but no mvDir? :/
23:56:01*j_rod_s joined #nim
23:57:04FromGitter<mratsim> ah mvFile can move dir
23:59:11*vlad1777d quit (Ping timeout: 268 seconds)