<< 20-12-2017 >>

00:02:18*sz0 quit (Quit: Connection closed for inactivity)
00:24:30*MJCaley quit (Quit: MJCaley)
00:45:51*MJCaley joined #nim
01:35:14*SenasOzys__ quit (Read error: Connection reset by peer)
01:35:16*marenz__ quit (Ping timeout: 272 seconds)
01:35:36*SenasOzys joined #nim
01:35:55*radagast quit (Quit: radagast)
01:42:25*kalkin- quit (Remote host closed the connection)
01:42:50*kalkin- joined #nim
01:43:21*skelett quit (Read error: Connection reset by peer)
01:43:29skrylarvarriount: did you ever have time to look over the sheet for miglayout and comment on it?
01:43:45*skelett joined #nim
01:44:36*SunDwarf quit (Remote host closed the connection)
01:44:52*SunDwarf joined #nim
01:49:23*vlad1777d quit (Ping timeout: 268 seconds)
02:00:49*user0 joined #nim
02:00:59*user0 is now known as radagast
02:02:01radagastIs there a forum where they review your algorithms and give you suggestions?
02:02:24FromGitter<zacharycarter> stackoverflo0w
02:02:37radagastOther than that?
02:02:53FromGitter<zacharycarter> if your implementation is written in Nim, you could always ask on the nim forums
02:04:23skrylarthat might be programmer overflow, zacharycarter
02:04:29FromGitter<zacharycarter> truth
02:04:39skrylarif its a general algorithm question they tend to move it to compsci/math/programmer
02:06:29FromGitter<zacharycarter> Hrm, I need to spend some time over the holidays on this task scheduling system
02:07:08skrylarnaughty dog also isn't relying on a GC, something to keep in mind
02:07:19skrylarif you use their system you have to account for that, unless you're just doing one-thread tasklets
02:07:30skrylaradmittedly, one-thread fibers can get you very far
02:07:34*chemist69 quit (Ping timeout: 272 seconds)
02:08:54FromGitter<zacharycarter> yeah I think the shared memory approach you suggested the other day is probably the right approach, I just need to gain a better understanding of how to implement it
02:20:36*chemist69 joined #nim
02:21:35skrylarzacharycarter: depends on your model
02:21:42skrylarunity/godot style stuff is heavy on dynamic allocation
02:22:01skrylari think the really old games, mayeb a few AAA ones, just sit down and go "we have a limit of N objects" and just preallocate them
02:22:14skrylarStarcraft had a global sprite limit (if you ran out of sprites, marines couldn't shoot)
02:22:55FromGitter<zacharycarter> didn't know that but it makes sense
02:23:58skrylari don't know what Overwatch uses, but they coudl use similar. There's at most 16 people, and a very low numer of persistant elements
02:24:13skrylarSo the whole game state without graphics is probably under 100kb, would definitely fit in a single block
02:24:52skrylarthings like Minecraft or maybe Stardew Valley are where you start getting hosed.
02:30:19FromGitter<zacharycarter> right - lots of state to manage and pass around
02:41:46FromGitter<Varriount> skrylar: hm?
02:42:18GitDisc<awr> How do you import a C preprocessor variable into Nim?
02:43:35FromGitter<Varriount> awr: What are you trying to accomplish?
02:44:09GitDisc<awr> trying to get the GCC version
02:44:26GitDisc<awr> i think I'm gonna try this
02:44:33GitDisc<awr> {.emit: "int gccMajor = __GNUC__;".}
02:44:34GitDisc<awr> var gccMajor {.importc.}: cint
02:48:30skrylarconst something {.importc: "__GNUC__".}?
02:48:51FromGitter<Varriount> That would probably be best
02:48:53skrylarnever tried importing a constant, but i see no reason for it to be impossible
02:49:22skrylarVarriount: http://www.migcalendar.com/miglayout/mavensite/docs/cheatsheet.pdf
02:50:04FromGitter<Varriount> skrylar: Might behave oddly if it isn't bound to a variable. Macros have no types.
02:50:19skrylartrue
02:50:36GitDisc<awr> const won't work without an assignment
02:50:59FromGitter<Varriount> Skrylar: The best test of such things is to apply it to real-world examples.
02:50:59GitDisc<awr> an assignment inside nim, I mean
02:51:24skrylarvarriount: some java people use and recommend that.
02:51:38skrylarit's partly implemented in nim, just becoming a time suck to deal with all the edge features
02:51:44FromGitter<Varriount> "How would I use this to implement Slack/Windows Explorer/Chrome"
02:53:07skrylarawr: assign it to soem random value? the generated C code isn't going to use the value
02:53:27FromGitter<Varriount> skrylar: Well, it looks like a decent layout.
02:54:37skrylarthere are some other options but trying to understand simplex-based engines was difficult
02:54:54GitDisc<awr> i set it to 0, didn't work
02:55:04GitDisc<awr> the emit and var works
02:55:06*radagast quit (Quit: radagast)
02:55:21skrylarjust never ever write to the var :)
02:56:17GitDisc<awr> lol
02:56:24*radagast joined #nim
03:05:04FromGitter<Ajusa> I am trying to concat the nimbase.h and my generate main.c file, and then trying to run with gcc, but I am getting a few errors that I don't know how to solve. ⏎ ⏎ ```undefined reference to `setStackBottom' ⏎ undefined reference to `systemInit000'``` [https://gitter.im/nim-lang/Nim?at=5a39d35f232e79134d6ea0c6]
03:07:32FromGitter<gogolxdong> How to new a table to add any type of key:value combination?
03:13:42FromGitter<Quelklef> what?
03:13:58FromGitter<Quelklef> are you trying to make an untyped table or something?
03:14:21FromGitter<gogolxdong> or pointer something
03:14:35FromGitter<Quelklef> er, what for
03:15:00FromGitter<Quelklef> sounds like you're trying to circumvent type safety
03:15:03FromGitter<Quelklef> which is questionable
03:16:52FromGitter<gogolxdong> As a parameter passed in ,it will be added with key:value pairs of many type,like string:string string:int string:float
03:18:11FromGitter<Quelklef> Do something like
03:19:02FromGitter<Quelklef> ```type KeyType = string | int ⏎ type ValType = string | int | float``` ⏎ ⏎ Then parameterize the table with `[KeyType, ValType]`. [https://gitter.im/nim-lang/Nim?at=5a39d6a6a2be466828c1d8e7]
03:19:19FromGitter<Quelklef> is probably what you want
03:19:32FromGitter<gogolxdong> ok,that's kind of work around.
03:19:47FromGitter<Quelklef> would it be better in your situation to create a container type?
03:19:50FromGitter<Quelklef> like, a C union
03:19:58FromGitter<Quelklef> that'd feel weird
03:20:01FromGitter<Quelklef> What's the context?
03:20:36FromGitter<gogolxdong> I put translating a bunch of PHP API to Nim
03:20:54FromGitter<Quelklef> Ah. Well, sounds like a lot of it's gonna be workarounds then
03:21:34FromGitter<Quelklef> If there's no abstraction that you can make for this,
03:21:55FromGitter<Quelklef> That is, if there's no new datatype you can make that makes sense abstractly and works well in the code,
03:22:18FromGitter<Quelklef> I'd say just emulate a C union
03:23:41FromGitter<Quelklef> unless you don't actually need to be aware of their types, in which case use the `KeyType` / `ValType`
03:24:13FromGitter<ephja> type classes are compile time only
03:24:16FromGitter<ephja> https://nim-lang.org/docs/manual.html#types-object-variants ?
03:24:52FromGitter<Quelklef> right, so good if he doesn't need to be aware of type, ye?
03:31:29*MJCaley quit (Quit: MJCaley)
03:36:13*astronavt joined #nim
03:43:16FromGitter<Ajusa> I am still trying to get one compilable file output from Nim. I even tried using the C++ backend output, but I get the same error. I looked it up, and the last time someone else had the same request as me Araq said no :P
03:44:07skrylarit might be possible to do something like a unity build, although i haven't tried and unity builds don't *always* work
03:44:25skrylarfor instance if a file does a local #define and doesn't undo it, then unity builds can bork
03:45:54FromGitter<Ajusa> Unity as in Unity 3d?
03:46:22skrylarno, unity builds mean you have one file that just #includes the other .c files
03:46:27skrylarsqlite calls it an amalgamation
03:46:36skrylarits equivalent to cat'ing the C files together
03:47:45FromGitter<Ajusa> I basically did that by hand (I believe) and I got a few errors of things being undefined. I have heard of amalgamation before, thanks for expanding on that
03:48:11skrylarthat was a linker error. it means you didn't get the file (or library) which included the symbols
03:49:38FromGitter<Ajusa> I have the main.c and the nimbase.h, what else could I need?
03:50:30skrylarls nimcache/*.c
03:53:08*dddddd quit (Remote host closed the connection)
03:53:51FromGitter<Ajusa> Okay, so I have main.c and stdlib_system.c
03:56:26FromGitter<Ajusa> ``````
03:56:55FromGitter<Ajusa> that is the error I am getting now.
03:57:16FromGitter<Ajusa> actually never mind, it compiled!
03:58:17*zama quit (Ping timeout: 255 seconds)
03:58:46FromGitter<Ajusa> any way to make the final c file smaller? My actual code is 2kb, but the stdlib_system is 115kb. ⏎ I realize that this may be a stupid question.
03:59:25*zama joined #nim
04:00:26FromGitter<gogolxdong> initTablestring,Node () as https://nim-lang.org/docs/manual.html#types-object-variants implied , assignment becomes tricky , like ``` ⏎ var secretIdNode = Node(kind: nkString,strVal: secretId) ⏎ paramTable["SecretId"]= secretIdNode ⏎ ⏎ `````` [https://gitter.im/nim-lang/Nim?at=5a39e059a2be466828c1fbfa]
04:03:20FromGitter<gogolxdong> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a39e08c03838b2f2a16d16b]
04:03:20FromGitter<gogolxdong> hints me type mismatch
04:13:02*BitPuffin|osx joined #nim
04:20:17*marchon joined #nim
04:20:38marchonHello there new friends.
04:21:10marchonAfter reading a couple of articles about nim - I would like to use it to prototype a project.
04:21:33marchonI am struggling with a couple of things, and was hoping to get some pointers.
04:22:10marchonI would like a crossplatform app that uses a traybar for user interaction.
04:22:44marchonThe stat is UI elements seems rough around the edges.
04:23:45marchonIt seems like I should be trying to use sciter / in theory. but can quite figure out where to start.
04:25:00marchonI prototyped what I wanted for a traybar app on osx with rumps.
04:25:01marchonhttps://github.com/jaredks/rumps
04:25:23marchonbut do know see that there is a py2nim convertor.
04:25:49marchonshould I try to hand code that converstion myself, or use one of the python wrapper methods to try to call it?
04:28:49*kalkin-- joined #nim
04:30:25marchonany thoughts?
04:32:35*kalkin- quit (Ping timeout: 265 seconds)
04:42:09*radagast quit (Ping timeout: 248 seconds)
04:55:36*astronavt quit (Quit: Leaving...)
04:56:42*marchon quit (Quit: marchon)
04:58:16*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
05:17:56*marchon joined #nim
05:20:19*marchon left #nim (#nim)
05:42:28*SenasOzys quit (Ping timeout: 240 seconds)
06:01:39*nsf joined #nim
06:06:28*SenasOzys joined #nim
06:13:40*nyeaa joined #nim
06:41:56*Elronnd joined #nim
07:08:34*solitudesf joined #nim
07:10:48*jjido joined #nim
07:19:06*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
07:21:39*skrylar quit (Remote host closed the connection)
07:24:13*jjido joined #nim
07:52:25*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
07:55:57FromGitter<mratsim> The codebase is small so maybe try porting it?
07:57:30FromGitter<mratsim> Or you can fork the repo and replace functionalities by Nim little by little until everything is replaced: https://github.com/yglukhov/python, https://github.com/jboy/nim-pymod
08:06:40*SenasOzys quit (Remote host closed the connection)
08:07:18*SenasOzys joined #nim
08:08:45*PMunch joined #nim
08:19:54*Zardos quit (Quit: Page closed)
08:20:29*Zardos joined #nim
08:24:09*Vladar joined #nim
08:25:14*claudiuinberlin joined #nim
08:25:28*gokr quit (Ping timeout: 240 seconds)
08:28:37*couven92 joined #nim
08:39:08*floppydh joined #nim
08:41:39*gokr joined #nim
08:44:20GitDisc<awr> wow slurp() and gorge() are really awesome
08:44:22GitDisc<awr> but uh
08:44:27GitDisc<awr> what's the story behind their names?
08:47:43FromGitter<gogolxdong> How to fetch the value of Node in Table[string,Node] which Node defines as manual instructs ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a3a23afba39a53f1a8139bd]
08:51:07*kalkin-- quit (Quit: Leaving)
08:51:17GitDisc<awr> oh a few other langauges (perl 6?) call their readFile string function "slurp()"
08:53:32FromGitter<alehander42> @gogolxdong what do you call "the value of Node"
08:54:02FromGitter<alehander42> you can define a `$` function if you want to just get some representation of each object
08:56:05FromGitter<gogolxdong> I have considered `$` ,even define such a operator still face to fetch the value of Node like C union mechanism.
08:56:53FromGitter<alehander42> well yeah, that's the point of a variant, you have to define what happens in each branch
08:57:32FromGitter<gogolxdong> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a3a25fb03838b2f2a180042]
08:58:28FromGitter<gogolxdong> like this pseudocode
08:58:33FromGitter<alehander42> so, if you define a `$` method, you'll be able to just `var v = $value`
08:58:40FromGitter<alehander42> but I am not sure what you want to do
08:58:49FromGitter<alehander42> if you want to do something different with ints and floats
08:59:05FromGitter<alehander42> then having a case or if would be needed anyway
09:01:46FromGitter<gogolxdong> yeah,this pseudocode is invalid
09:02:31FromGitter<alehander42> I know, ok, what you want to do in of nkInt:
09:03:02*gmpreussner quit (Ping timeout: 255 seconds)
09:04:57*gmpreussner joined #nim
09:05:39FromGitter<gogolxdong> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a3a27e3540c78242de7c981]
09:07:14FromGitter<gogolxdong> ```code paste, see link``` ⏎ ⏎ this works [https://gitter.im/nim-lang/Nim?at=5a3a28425355812e57f909fd]
09:07:16FromGitter<alehander42> that wouldn't make sense, as all those fields are different types
09:07:40FromGitter<alehander42> yes, well, exactly, just move this to a function and you have your `$` which you can reuse later
09:17:25*Arrrr joined #nim
09:30:47*radagast joined #nim
09:37:26*couven92 quit (Ping timeout: 260 seconds)
09:49:46FromGitter<mratsim> @awr I think it's usual name in some foreign world (JavaScript tooling?) But yeah I agree that's so weird.
09:52:26*yglukhov joined #nim
09:52:39*yglukhov quit (Remote host closed the connection)
09:52:55*yglukhov joined #nim
09:55:37*geocar joined #nim
09:58:52*PMunch_ joined #nim
10:00:18*skrylar joined #nim
10:00:57*PMunch quit (Ping timeout: 256 seconds)
10:02:43*PMunch_ is now known as PMunch
10:04:09*SenasOzys quit (Ping timeout: 265 seconds)
10:08:03FromGitter<gogolxdong> @Araq Is there an example of your libcurl to fetch the curl result? I've checked the c version from many blogs bug don't quite get it.
10:08:14FromGitter<gogolxdong> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a3a368e5355812e57f9557f]
10:10:18Araqdon't use libcurl, use the standard library
10:14:04*SenasOzys joined #nim
10:14:20FromGitter<gogolxdong> Please shed more light, didn't get a clue how to.
10:15:24*Yardanico joined #nim
10:16:23*jjido joined #nim
10:20:47FromGitter<andreaferretti> there is an `httpclient` module in the standard library
10:21:09*Zardos quit (Quit: Page closed)
10:21:44FromGitter<gogolxdong> Yes, I just got it .
10:21:49FromGitter<gogolxdong> thanks
10:33:16*def- quit (Quit: -)
10:35:59*def- joined #nim
10:46:18skrylargogolxdong getting data from libcurl requires setting a callback
10:46:51skrylarhttps://gist.github.com/Skrylar/9c735f4a6e50c5778e02054ac1a8cfe0
10:47:24skrylari'm fully aware that i could probably use movemem to copy the data out
10:52:42*PMunch_ joined #nim
10:54:21*PMunch quit (Ping timeout: 264 seconds)
10:58:17*PMunch_ quit (Ping timeout: 265 seconds)
11:03:32skrylarballs. gettype{impl,inst} isn't giving me the ast for a type in a macro
11:03:48*marenz__ joined #nim
11:04:14nivhello. what's the cleanest way to have a string "enum" that can be used in case (somestring) of ..?
11:05:19*PMunch joined #nim
11:08:54nivnvm, found my answer in strutils
11:09:23skrylarah the good old gettype(gettype(x)[1]) :\
11:16:37skrylarmratsim: well, slight poop. turns out macros-as-pragmas don't work on object fields
11:17:09FromGitter<mratsim> Yes they don't there is a feature request for custom pragmas for types and object fields
11:17:23skrylari would be happy with go tags tbh
11:17:50FromGitter<mratsim> https://github.com/nim-lang/Nim/issues/6696#issuecomment-346831813
11:18:44skrylarflatpack doesn't really need pragmas, as long as you never re-order fields or delete old ones it will work fine
11:19:28*jjido quit (Ping timeout: 240 seconds)
11:19:40skrylarwell flatbuffers
11:22:03skrylarwell, with a (non-standard) adapter module you could probably get away with no pragmas in a flatbuffer
11:22:09*arthurz quit (Ping timeout: 248 seconds)
11:22:30*arthurz joined #nim
11:22:35skrylarstuff the schema as a json or a flatbuffer in a separate sbox field, then have a scanner compare the two and build a converter
11:27:15FromGitter<data-man> Hi! ⏎ How to list only directories? I have tried to use walkDirRec("./", {pcDir}) but it doesn't work.
11:29:44skrylarmratsim: https://github.com/Skrylar/skflatbuffers/issues/2
11:34:42*Yardanico quit (Read error: Connection reset by peer)
11:39:05*Yardanico joined #nim
11:40:35skrylarmratsim: hoboy. was just thinking about a memory allocator, mmaped file, and this silliness, you could sorta achieve a generic ACID blob module
11:41:21*craigger quit (Ping timeout: 248 seconds)
11:43:31*PMunch quit (Ping timeout: 256 seconds)
11:43:45skrylarthe real question is, does anyone actually need transactional binary files -_- probably, no
11:44:02*PMunch joined #nim
11:45:09radagastWhat is a good data structure, for strings, to be used by a text editor? Rope? Trie?
11:45:18skrylargap buffers
11:46:39skrylarropes are really handy if you are Sublime Text and are doing multiple carets, or splicing a LOT of text, but most edits are around one point and gap buffers solve that simply
11:46:50skrylarhttps://www.finseth.com/craft/ relevant
11:47:29radagast>https://www.finseth.com/craft/ Thanks! I actually have this page loaded in my browser
11:55:15FromGitter<data-man> @radagast ⏎ https://en.wikipedia.org/wiki/Piece_table
12:09:24*Yardanico quit (Read error: Connection reset by peer)
12:09:37*xkapastel quit (Quit: Connection closed for inactivity)
12:09:45*craigger joined #nim
12:10:04*Ne0t0N joined #nim
12:12:07*Yardanico joined #nim
12:21:37FromGitter<alehander42> oh I started using strformat
12:21:47FromGitter<alehander42> so much better than `% [..]` everywhere
12:21:52Yardanico:)
12:22:26FromGitter<alehander42> still `%` seems good for some multiline templates
12:24:54Araq'%' is for runtime stuff, fmt"" is resolved at compile-time
12:25:31Araqbtw there is also strutils.format
12:25:50Araqecho format("$#: $#", a, b) # no need for $s
12:26:18Araqecho fmt"{a}: {b}" is much shorter though
12:27:16FromGitter<alehander42> I know `%` happens on runtime, but I usually don't need dynamic templates (I just use it to join strings with expressions)
12:27:34Araqnow if only typing of output instructions would be a bottleneck for me ...
12:27:35*Snircle joined #nim
12:28:52*jjido joined #nim
12:29:14FromGitter<alehander42> :D it's bottleneck in reading usually.
12:29:15Araqyay after VS-Code update it cannot find my git.exe anymore, fun
12:29:32*Ne0t0N quit (Quit: Page closed)
12:29:33Araqbut it's "faster" now
12:29:47Araqat starting up
12:30:16AraqI only start it once though and need its git integration ...
12:31:19YardanicoAraq, can https://github.com/nim-lang/Nim/issues/4218 be finally closed? I think everything from it is implemented in current Nim
12:35:39Araqsure, done
12:38:30*floppydh quit (Quit: WeeChat 2.0)
12:40:10*floppydh joined #nim
12:47:08*arthurz quit (Ping timeout: 255 seconds)
12:47:20*arthurz joined #nim
12:50:33*Arrrr1 joined #nim
12:50:33*Arrrr quit (Disconnected by services)
12:50:40*Arrrr1 quit (Client Quit)
13:04:34*skrylar quit (Remote host closed the connection)
13:14:03*freevryheid joined #nim
13:14:09*jjido quit (Ping timeout: 264 seconds)
13:14:11*freevryheid is now known as fvs
13:15:42fvshi, any "nearest neighbor" algos in nim? Need to find closest P(x,y) to point cluster.
13:16:09Yardanicofvs, well they aren't hard to port from python usually
13:16:41*Yardanico quit (Read error: Connection reset by peer)
13:17:58FromGitter<data-man> @fvs: See closestPoint in the basic2d package
13:19:46*Yardanico joined #nim
13:23:29fvsdata-man: thanks, closestPoint looks like it runs a brute-force search, not viable for huge point clusters.
13:31:05fvshmm, found this: http://rosettacode.org/wiki/K-d_tree - I'll try porting the c verison.
13:32:08*dddddd joined #nim
13:38:08*dddddd quit (Ping timeout: 240 seconds)
13:50:14FromGitter<mratsim> @fvs cool! @Stefansalewski also started a port of rtree which are also used for geocoordinates algorithm
13:51:46FromGitter<mratsim> @dom96 @araq, I think there is an opportunity for "1 year in Nim" blog article. Should we open a RFC for subject ideas?
13:52:38FromGitter<mratsim> @fvs I'll add you there as soon as you have a GitHub repo: https://github.com/nim-lang/needed-libraries/issues/77
13:53:18*Jesin quit (Quit: Leaving)
13:53:19*dddddd joined #nim
14:00:06FromGitter<zacharycarter> fvs: there are a lot of good algorithms for detecting nearest neighbors in a graph
14:00:06*yglukhov quit (Read error: Connection reset by peer)
14:00:19*yglukhov joined #nim
14:00:33FromGitter<zacharycarter> I guess it depends mostly on your requirements as to which you'd want to use
14:07:02fvsmratsim: i made a start on the gdal geospatial library: https://github.com/freevryheid/nim-gdal. Only vector funcs atm.
14:07:25FromGitter<RedBeard0531> In a proc that takes a non-var seq, is it possible to get the address of elements in the seq? I assume `unsafeAddr someImmutableSeq[0]` will return the address of the temporary T that is returned by [], which is no good. This is necessary in order to do a simd load of the data.
14:08:45FromGitter<zacharycarter> I don't think you can use unsafeaddr on non-pointers
14:08:51FromGitter<mratsim> `unsafeAddr yourseq[10]`
14:09:06FromGitter<mratsim> Will get the address of the 11th elements.
14:09:16FromGitter<zacharycarter> @mratsim he said non-var seq though
14:09:31FromGitter<mratsim> Yes. It works.
14:09:35*FromGitter * RedBeard0531 goes off to double check the codegen...
14:09:45FromGitter<zacharycarter> ``````
14:09:52Yardanicobut seq is copied, no?
14:09:57FromGitter<zacharycarter> does not compile for me
14:10:16FromGitter<mratsim> For non-var primitive types it wouldn't but seq are managed by GC they always have an address
14:10:19FromGitter<zacharycarter> what's the difference between addr and unsafeaddr
14:10:38Yardanicowith unsafeaddr you can take an adress of a "let" variable for example
14:10:40FromGitter<zacharycarter> because ⏎ ⏎ ```let foo = @[1,2,3] ⏎ ⏎ echo repr unsafeaddr foo[0]``` [https://gitter.im/nim-lang/Nim?at=5a3a6f605355812e57faa5a6]
14:10:41FromGitter<zacharycarter> compiles
14:10:41FromGitter<mratsim> addr won't give you an address of non-var.
14:10:42Yardanicoor non-var variables in procs
14:10:53FromGitter<zacharycarter> ah okay thank you for the clarification
14:11:32FromGitter<mratsim> unsafeAddr cannot get you addresses of let on the stack (int, float, etc)
14:15:28FromGitter<RedBeard0531> @mratsim that worked. Thanks! Is that because seq[] is a compiler magic and the compiler knows not to create the return value rvalue if it is passed to unsafeAddr?
14:15:56FromGitter<RedBeard0531> Because otherwise the types just don't line up...
14:15:59FromGitter<mratsim> @RedBeard0531 @Yardanico addr and unsafeAddr are magic, it doesn't copy. It says instead of returning this, give me its address.
14:16:14YardanicoI was talking not about addr copying
14:16:26YardanicoI was talking about copying if you pass something to proc :)
14:16:37YardanicoI know that addr gives an address
14:16:38FromGitter<RedBeard0531> arguments are never copied
14:16:59FromGitter<mratsim> ^
14:17:14FromGitter<RedBeard0531> (if the copy is expensive)
14:17:37FromGitter<RedBeard0531> ints and such are passed by copy because it is dumb not to
14:22:53FromGitter<RedBeard0531> I was curious the limits to this. Tuples up to 3 ints are passed by copy. Tuples with 4 ints or more are passed by (implicit) ptr.
14:23:53*couven92 joined #nim
14:24:34floppydhI'm using a "table-literal" like this: `const A = { "ASD": 10 }` now I'm trying to do `if "ASD" in A: ...` yet it fails compiling - any pointers?
14:25:03*yglukhov quit (Remote host closed the connection)
14:25:33*PMunch quit (Ping timeout: 264 seconds)
14:28:08Yardanicofloppydh, did you import tables?
14:28:19Yardanicoah
14:28:23Yardanicoyou didn't even use them :)
14:28:36Yardanicotable-literal is just a [(key, val)]
14:29:06Yardanicoif you want to actually use tables - use "tables" module
14:29:16Yardanico{} is just a shortcut
14:29:35FromGitter<RedBeard0531> @Araq you may want to consider dropping the threshold for reference passing to anything over 2 ints (16bytes) on non-windows x86_64 since the c compiler will pass by reference implicitly. From page 21 of the ABI: "If the size of the aggregate exceeds two eightbytes and the first eightbyte isn’t SSE or any other eightbyte isn’t SSEUP, the whole argument ⏎ is passed in memory."
14:29:35FromGitter... https://software.intel.com/sites/default/files/article/402129/mpx-linux64-abi.pdf
14:29:36Yardanicofloppydh, https://nim-lang.org/docs/manual.html#statements-and-expressions-table-constructor
14:29:58floppydhYardanico: thanks
14:33:17AraqRedBeard0531: I increased the threshold recently because it helps clang's optimizer
14:34:23radagastWhy is incremental GC better than deferred ref counting (or vice versa)?
14:36:28FromGitter<RedBeard0531> @Araq: interesting. As long as there's a reason for the discrepancy, that seems fine. It only affects tuples with exactly 3 ints anyway.
14:36:36floppydhYardanico: can't have a const Table tho?
14:40:18Yardanicofloppydh, you can
14:41:11floppydhYardanico: `const mymap = { ... }.newTable` => invalid type for const: TableRef
14:41:17Yardanicofloppydh, yes
14:41:21Yardanicoyou need to use toTable instead
14:41:35Yardanicoyou can't have const references (newTable creates a reference to a table)
14:41:51floppydhYardanico: true, thanks
14:42:03*PMunch joined #nim
14:42:14FromGitter<zacharycarter> radagast - maybe read the comments here : https://news.ycombinator.com/item?id=11759762
14:42:21*yglukhov joined #nim
14:42:30*yglukhov quit (Remote host closed the connection)
14:42:34FromGitter<zacharycarter> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a3a76da1a4e6c822330e1db]
14:47:45FromGitter<mratsim> "It is well known" sounds like a reasoning by authority (not discussing the conclusion but source).
14:48:31FromGitter<mratsim> 1) This doesn't discuss the trade-off of latency/max-pause vs throughput.
14:48:37Araqmratsim: the JVM and .NET started with reference counting and moved to tracing GCs.
14:48:39FromGitter<mratsim> +*
14:49:00Araqlatency with simple RC is unbounded
14:49:34FromGitter<mratsim> I only believe in benchmarks :P.
14:49:52Araqso run koch boot -d:release vs koch boot -d:release --gc:markAndSweep
14:50:32Yardanicobtw - https://blog.canya.com.au/2017/12/20/canya-acquires-majority-stake-in-bountysource-adds-over-46000-users/
14:51:45Araqmratsim: for your use case RC should win though, you want to reuse that 300MB blobs as soon as possible ;-)
14:53:30FromGitter<mratsim> Btw I tried debugging the allocation/deallocation SIGSEGV yesterday, but it is really hard to isolate. Will continue in the evening.
14:57:56FromGitter<RedBeard0531> Is --gc:markAndSweep precise with heap objects? Meaning does it avoid scanning strings or seq[int] and similar for pointers?
14:58:54Araqof course
15:00:20FromGitter<RedBeard0531> just checking. I was a bit thrown by your comment the other day that one of the things you wanted to get out of the llvm backend was a precise GC. I guess that just refers to the stack?
15:03:44*fvs left #nim ("ERC (IRC client for Emacs 25.3.1)")
15:10:04*yglukhov joined #nim
15:11:12Araqyes
15:11:45floppydhI somehow fail to have a proc allocate the return type of a var of a non-ref object type ...
15:12:23floppydhalong `proc foo: var Bar = new(result)` where `Bar` is just a normal object
15:12:39Araqdon't use 'var' here
15:12:55floppydhI want to return a ref tho
15:13:04Yardanicoit would return a ref
15:14:04floppydhso I can use `ref Bar` but that requires me to deref it to access members?
15:14:46Araqthat's not how the language works, read the tutorials at least
15:15:32*sz0 joined #nim
15:17:28*Jesin joined #nim
15:18:14FromGitter<zacharycarter> I wonder why - https://github.com/pragmagic/nimue4 were seemingly abandoned in favor of the godot bindings
15:18:24FromGitter<mratsim> result will be constructed directly in the assignee `let your car: Bar = foo()` won't copy even if it's a non-ref object.
15:18:48FromGitter<mratsim> yourvar*
15:20:02FromGitter<data-man> Will try to ask again. ⏎ How to list only directories? I have tried to use walkDirRec("./", {pcDir}) but it doesn't work. ⏎ Is this my mistake or a bug in the implementation?
15:20:06*yglukhov quit (Remote host closed the connection)
15:20:13floppydhmratsim: don't follow
15:20:39floppydhI read the `Reference and pointer types` section in tut1 and am not any wiser
15:21:05floppydhI assume I could define a `type BarRef = ref Bar` and that would work
15:21:06Araqzacharycarter: UE4 doesn't work well on mobile and has bugs in its UI subsystem
15:21:16floppydhbut I'm not trying to do that
15:21:25Yardanicofloppydh, what you're trying to do?
15:22:03FromGitter<zacharycarter> Araq: gotcha
15:22:30floppydhYardanico: I have a `type Bar = object` from another module, now I want a proc that constructs a Bar and returns a ref to it, so I can use it in further `proc doSomeWithbar(b: var Bar)` calls
15:22:34FromGitter<zacharycarter> @data-man : ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a3a803a03838b2f2a1a0c49]
15:22:41FromGitter<zacharycarter> says directories are ignored
15:22:54FromGitter<zacharycarter> https://nim-lang.org/docs/os.html#walkDirRec.i,string
15:23:10Yardanicofloppydh, you don't need to have a "var Bar" if you have a ref variable
15:23:14Yardanicoah
15:23:20FromGitter<mratsim> @floppydh don't use new, you don't need to worry about passing it as a var.
15:23:21Yardanicothen you would need to use "ref Bar"
15:23:31Yardanicoor better - create "type BarRef = ref Bar"
15:23:32floppydhmratsim: oh I see, let me try
15:23:40floppydhYardanico: I'm trying not to do that
15:24:37FromGitter<mratsim> `proc initBar(): Bar = Bar(field1: value)`
15:24:44floppydhmratsim: type mismatch got `ref Bar` but expected one of `var Bar`
15:25:03floppydhI guess I would need to change the signature of the doSomeWithBar procs to `ref Bar` too
15:25:15*yglukhov_ joined #nim
15:25:34FromGitter<mratsim> I don't think you need ref.
15:25:34Araqdata-man: it's a bit weird but 'filter' is only used for traversal, not for 'yield'. Probably it shouldn't support 'filter' at all
15:26:20FromGitter<mratsim> `proc useBar(a: var Bar)= ...`
15:26:39floppydhmratsim: I do because the doSomeWithBar proc changes bar - now I get: "for a 'var' type a variable needs to be passed, but initBar() is immutable"
15:27:04FromGitter<mratsim> No you don't, assign it to a var.
15:27:08floppydhI'm basically doing `doSomeWithBar(newBar())`
15:27:14floppydhI don't want to do that tho
15:27:26floppydhI guess I could write a template
15:27:33floppydhits in a unittest thing
15:27:33FromGitter<mratsim> But you can't modify something that has no address.
15:27:53floppydhwhich is why I want my newBar to return a var/ref :3
15:28:47FromGitter<mratsim> Assign it first, then modify it then check if your test passed no? That would mimics how your library is used I suppose.
15:28:57floppydhyes
15:29:54floppydhso we conclude that it's not possible without putting it in a var first?
15:30:28FromGitter<mratsim> `var tmp = initBar(); doSthWithBar(tmp); check: tmp == ...` (I'm on mobile so I sert new lines)
15:30:31floppydhjust trying to match what seems to be a conceptual misunderstanding of mine
15:30:34FromGitter<RedBeard0531> @floppydh: does doSomeWithBar() modify its argument in a way that the caller is expected to see? If not, don't take Bar by var.
15:30:56Araqmutate(4) vs var x = 4; mutate(x)
15:30:57floppydhRedBeard0531: it does
15:31:27Araqyou cannot modify the number 4
15:31:30floppydhits: mutate(newIntThatReturnsARef(4)) vs var x = 4; mutate(x)
15:32:23FromGitter<data-man> @zacharycarter @Araq Thanks. That is, there is no way to get a list of dirs by std procs.
15:32:28floppydhso `var T` is not a valid return type?
15:32:42Araqdata-man: sure there is, os.walkDir
15:32:46FromGitter<mratsim> But after your mutate since nothing owns newIntThatreturnsARef(4) what can you do with it?
15:33:07Araq'var T' is a valid return type, it opens a view into some existing data structure
15:33:26Araqit's never valid as a return type for a constructor though
15:33:38floppydhI, think I, see
15:34:27floppydhmratsim: sure, nothing, but you get my use-case I'm just trying to save a stmt :P
15:35:11FromGitter<mratsim> You will have the same issue in any language actually, you can mutate a variable (change its value), you can't mutate a value (mutate(4)) of Araq.
15:35:40FromGitter<mratsim> In hardware term you can mutate what a memory location holds
15:36:42FromGitter<data-man> @Araq: os.walkDir is not recursive :(
15:36:43floppydhmratsim: that's not what I'm doing tho, I'm calling a function that I expect to return a reference, because mutate expects reference-semantics, not value-semantics
15:37:07FromGitter<mratsim> var deals with that for you.
15:37:35FromGitter<mratsim> value vs reference in Nim is only relevant for assignment/copy.
15:37:51floppydhmratsim: ah
15:38:11FromGitter<mratsim> If you declare a variable as var, and pass it to a var parameter Nim will pass a hidden pointer for you.
15:38:39FromGitter<mratsim> So you're worrying too much ;)
15:38:47FromGitter<RedBeard0531> @floppydh: it is technically possible to do what you want but it is probably a bad idea. I take no responsibility if this formats your harddrive: ```proc foo(a: var int) = discard ⏎ proc bar(): int = 4 ⏎ proc badIdea(a:int): var int = (unsafeAddr a)[] ⏎ ⏎ foo(badIdea(bar())) ... [https://gitter.im/nim-lang/Nim?at=5a3a8406a2be466828c54f57]
15:41:55FromGitter<data-man> @Araq: Maybe to add one more parameter to walkDirRec? Or one more flag.
15:42:25FromGitter<mratsim> Oh @floppydh if you understood (and have the time), it would be great if you add it to Nim wiki on GitHub because I suppose others who'll come to Nim from languages that worry about ByVal/ByRef might find it valuable.
15:44:01*couven92 quit (Ping timeout: 248 seconds)
15:47:20*safvav712t85 quit (*.net *.split)
15:51:38floppydhmratsim: sure, don't think I fully understood it tho, might have the time in the future to revisit, I'll see what I can do
16:02:05*safvav712t85 joined #nim
16:05:23*Senketsu quit (Remote host closed the connection)
16:07:48*Senketsu joined #nim
16:29:24*Arrrr joined #nim
16:29:24*Arrrr quit (Changing host)
16:29:24*Arrrr joined #nim
16:33:43*PMunch quit (Ping timeout: 265 seconds)
16:36:35FromGitter<nitely> According to the manual "Constants cannot be of type ptr, ref, var or object", and yet objects *seem* to work (object variants do not). So, which is it? can or can not be a const?
16:38:07FromGitter<nitely> I could as well just use a tuple, but I'm curious about it
16:41:16*claudiuinberlin quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
16:43:21FromGitter<nitely> https://play.nim-lang.org/?gist=5f4c92ab7b54ea08e80e626f69e68bd3
16:43:46Yardaniconitely: this is fixed in devel
16:43:51Yardanicoconstants can be of type "object"
16:44:00Yardanicohttps://github.com/nim-lang/Nim/blob/3d69c1bd0b877b36a4568860274c362c5cbae6fb/doc/manual/stmts.txt#L202
16:44:21*claudiuinberlin joined #nim
16:44:26*claudiuinberlin quit (Client Quit)
16:44:45Yardanicoalways check devel to see if it has the same error or not :)
16:44:51FromGitter<nitely> ah, awesome! thanks
16:44:57FromGitter<nitely> will do
16:45:41Yardanicobtw Crystal is finally able to compile/run hello world on windows - https://github.com/crystal-lang/crystal/pull/5339
16:48:12Arrrrmmm
16:51:41FromGitter<alehander42> I am still not sure what took them so long
16:52:04ArrrrSomeone with free time and knowledge it seems
16:52:43FromGitter<alehander42> hm, it appeared in 2014, I somehow assumed it started 2009 or something
17:06:11GitDisc<NopeDK> I am trying to interface with a binary with the Nim code as a shared library this it imports. I keep getting SIGSEGV when I attempt to access an extern struct field that is a pointer to an array of structs. I tried to declare it as both with and without "incompleteStruct", tried declaring the field as both "ptr Worker" and "UncheckedArray[Worker]". In the first I can't compile and in the second it <message clipped>
17:06:31*zahary_ quit (Quit: Connection closed for inactivity)
17:10:09euantor@Yardanico: Still half of their stdlib doesn't work though I believe
17:10:24Yardanicoeuantor, yes, they just ported the things needed to run hello world :)
17:10:39euantorDo they still have compilation issues too due to how they use LLVM? Last time I heard they were using insane amounts of memory to compile
17:10:53Yardanicowell I don't know about that, never used crystal personally :)
17:11:37euantorI think they had an issue on their repository saying that building Crystal itself was impossible on 32 bit machines and took ages on 64 bit
17:11:43euantorMight be making it up though
17:12:31FromGitter<alehander42> yep, I was doing a benchmark once, and while debug mode worked quickly, release mode took forever
17:12:39FromGitter<alehander42> not sure about the memory tho
17:12:46*Trustable joined #nim
17:14:21euantorhttps://github.com/crystal-lang/crystal/issues/4864
17:14:28euantor^ Kind of explains a bit of the issue
17:15:56euantorhttps://github.com/crystal-lang/crystal/issues/4341
17:19:43GitDisc<NopeDK> Code example for my problem: https://pastebin.com/Bf6gJUpw
17:34:39FromGitter<zacharycarter> NopeDK - do you have your C code handy?
17:34:47FromGitter<zacharycarter> and if so, can you also share it?
17:36:29*claudiuinberlin joined #nim
17:41:25*nsf quit (Quit: WeeChat 1.9.1)
17:59:46GitDisc<NopeDK> zacharycarter, https://github.com/NopeDK/Nimgi and https://github.com/unbit/uwsgi
18:04:04GitDisc<NopeDK> Just a tiny project to get started with Nim properly xD Just need to get past the C interfacing issues...
18:05:04*floppydh quit (Quit: WeeChat 2.0)
18:13:25FromGitter<zacharycarter> Hrm I'm trying to produce a shared library from uwsgi and not having much luck :/
18:17:49GitDisc<NopeDK> What I did was compile uwsgi as a core build (no plugins), compile corerouter and http as plugins. Compile the Nim code as per the cfg and move the library file into the uwsgi folder and rename it to nimgi_plugin.so
18:20:49*Trustable quit (Remote host closed the connection)
18:22:50*safvav712t85 quit (Ping timeout: 260 seconds)
18:28:41*Arrrr quit (Ping timeout: 256 seconds)
18:30:14*Vladar quit (Quit: Leaving)
18:33:40*yglukhov_ quit (Remote host closed the connection)
18:36:24*yglukhov joined #nim
18:39:08GitDisc<NopeDK> I have updated the repo with new files and instructions on how I use them.
18:41:03*yglukhov quit (Ping timeout: 248 seconds)
18:41:11*benoliver999 quit (Quit: ZNC - http://znc.in)
18:50:15*benoliver999 joined #nim
18:53:41*foo_ quit (Ping timeout: 268 seconds)
18:58:30GitDisc<NopeDK> zacharycarter, I have added a script that should handle the necessary installation if you are on Linux (and have the equivalent of "build-essentials", "gcc" and "python" installed already)
19:00:14FromGitter<zacharycarter> NopeDK: cool - thank you for doing that. I'll have a look this evening for sure
19:03:16GitDisc<NopeDK> Thank you for being willing to help
19:15:37*foo_ joined #nim
19:30:35*yglukhov joined #nim
19:32:52FromGitter<RedBeard0531> What is the best way to serve up a local copy of the devel docs? I tried just using a static http server in doc/html, but the search functionality doesn't work. Is there a server compiled somwhere?
19:34:57*yglukhov quit (Ping timeout: 240 seconds)
19:37:50*claudiuinberlin quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
19:38:04YardanicoRedBeard0531: use devdocs.io maybe? :) and about search - it just uses js
19:38:33*yglukhov joined #nim
19:38:57Yardanicoor wait
19:39:08Yardanicoah yes
19:39:19Yardanicoit just downloads theindex.html from the server and uses js to search in it
19:40:15*Vladar joined #nim
19:41:10*fvs joined #nim
19:41:40dom96wassup guys?
19:41:54FromGitter<RedBeard0531> @Yardanico but that is for master not devel
19:42:05FromGitter<RedBeard0531> I wanted to show someone strformat :)
19:42:52fvswhile waiting for a native version, here's a wrapper for a kd-tree lib: https://github.com/freevryheid/nim-kdtree
19:42:54Yardanicobut I think devel uses the same search function
19:43:28Yardanicoyou just need to generate it
19:44:04YardanicobuildIndex
19:44:14Yardanico"nim buildIndex"
19:45:13Yardanicohmm wait
19:46:02*yglukhov quit (Read error: Connection reset by peer)
19:46:38*yglukhov joined #nim
19:52:28FromGitter<ephja> badger badger badger badger badger badger badger badger
19:54:51Yardanico?
19:55:11*BitPuffin|osx quit (Ping timeout: 248 seconds)
19:59:13*claudiuinberlin joined #nim
20:11:49*claudiuinberlin quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
20:18:28*foo_ quit (Ping timeout: 265 seconds)
20:27:47FromGitter<mratsim> @Araq regarding the bug reported yesterday, it’s too difficult to investigate reproduce. While narrowing down a test case, I needed to keep some very rare conditions in my code otherwise it just disappeared: ⏎ ⏎ 1) the times module, ⏎ 2) a let variable that goes unused, ⏎ 3) a function that returns a constant instead of just a constant, ... [https://gitter.im/nim-lang/Nim?at=5a3ac7c3540c78242deb5954]
20:28:16*nsf joined #nim
20:31:01FromGitter<mratsim> So giving up for now. Plus it was only happening when benchmarking different implementations of the same algorithm so I can just use one that never triggers this bug.
20:31:22FromGitter<zacharycarter> there's a discord for Nim right?
20:31:25*yglukhov quit (Remote host closed the connection)
20:31:25FromGitter<zacharycarter> does anyone have a link?
20:32:21Yardanicoyep
20:32:38Yardanicoone sec
20:32:41FromGitter<zacharycarter> thx
20:33:18Yardanicohttps://discord.gg/ezDFDw2
20:33:21FromGitter<zacharycarter> thank you
20:42:09*vivus joined #nim
20:46:14*claudiuinberlin joined #nim
21:00:45*Yardanico quit (Read error: Connection reset by peer)
21:08:54*MollyTheSizzler_ joined #nim
21:17:58*MollyTheSizzler_ quit (Quit: Page closed)
21:19:01*vlad1777d_ joined #nim
21:23:34*claudiuinberlin quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
21:32:28GitDisc<Calinou> here I am, the world record holder on the Nim snake game
21:35:15*foo_ joined #nim
21:37:04*yglukhov joined #nim
21:39:51*foo_ quit (Client Quit)
21:40:26FromGitter<mratsim> I bow to your supremacy
21:43:01*claudiuinberlin joined #nim
21:54:24GitDisc<Knob Ed> 
21:58:06GitDisc<NopeDK> Is there any fast way to update a Nim installation in place?
22:04:52GitDisc<Calinou> if it's compiled from source, yes, `git pull && ./koch boot -d:release && ./koch nimble -d:release && ./koch nimsuggest -d:release`
22:05:06GitDisc<Calinou> (this works if the `bin` directory in the Git clone is in the `PATH` environment variable)
22:06:49*xkapastel joined #nim
22:08:16GitDisc<NopeDK> Darn, only got the csources version. Oh well, time to start the download
22:10:37*Vladar quit (Quit: Leaving)
22:19:13*solitudesf quit (Ping timeout: 248 seconds)
22:20:10FromGitter<mratsim> or just use choosenim
22:20:25FromGitter<mratsim> then update is just `choosenim update devel`
22:20:47*nsf quit (Quit: WeeChat 1.9.1)
22:21:21GitDisc<NopeDK> Got an open issue on choosenim, doesn't work on arm
22:21:37GitDisc<NopeDK> Would have loved to use it though
22:29:00*Jesin quit (Quit: Leaving)
22:34:08GitDisc<treeform> Wow so many new people from discord. Hey guys.
22:37:32*claudiuinberlin quit (Quit: Textual IRC Client: www.textualapp.com)
22:38:44CalinouI'm also on IRC (and technically Gitter, but I never check there) :)
22:45:31*drs joined #nim
23:21:10GitDisc<treeform> D has this blog post about name mangling ( https://news.ycombinator.com/item?id=15970052 ), but I just don't get it. One of the comment says "Hashing + lookup seems much less error prone." ? It seems like it is? What does nim do?
23:22:52*nyeaa quit (Quit: leaving)
23:30:31FromGitter<RedBeard0531> There are definitely advantages to a reversible name-mangling scheme
23:56:08FromGitter<zacharycarter> I've been trying to convert all the godot users to Nim :P
23:56:50FromGitter<zacharycarter> to me anyway - it seems like the best language available for writing gameplay code