<< 25-11-2017 >>

00:03:05*jsgrant joined #nim
00:15:38*MJCaley joined #nim
00:25:57*MJCaley quit (Quit: MJCaley)
00:28:10*skrylar joined #nim
00:30:24*dddddd quit (Ping timeout: 248 seconds)
00:45:12*cspar_ joined #nim
00:46:27*cspar quit (Ping timeout: 240 seconds)
00:48:00*craigger_ quit (Quit: bye)
00:48:19*craigger joined #nim
00:48:33*craigger quit (Client Quit)
00:48:49*craigger joined #nim
00:55:43*couven92 quit (Quit: Client Disconnecting)
01:03:44*MJCaley joined #nim
01:07:46FromGitter<raydf> hello guys
01:08:24FromGitter<raydf> is there any example using the js backend with a function that has a callback as param?
01:09:52*vivus joined #nim
01:13:56*MJCaley quit (Quit: MJCaley)
01:17:39*MJCaley joined #nim
01:19:14*skrylar quit (Remote host closed the connection)
01:24:21*endragor joined #nim
01:28:41*endragor quit (Ping timeout: 240 seconds)
01:33:41FromGitter<Varriount> @raydf Well, using a function as a callback on the JS backend should be no different from using a function as a callback on the other backends.
01:33:56Araqraydf: read my karax examples perhaps
01:34:04FromGitter<Varriount> Or look here: https://nim-lang.org/docs/manual.html#types-procedural-type
01:34:07Araqhttps://nim-lang.org/araq/karax.html
01:35:01FromGitter<raydf> i'm trying to use cordova with karax and all the plugins use callbacks
01:35:40FromGitter<raydf> i'll experiment with both examples, thanks
01:38:07FromGitter<raydf> @Araq where is the code for ``` from future import `=>` ```?
01:40:35FromGitter<raydf> never mind
01:40:42FromGitter<raydf> thanks
01:44:27*yglukhov joined #nim
01:45:19*yglukhov quit (Read error: Connection reset by peer)
01:45:44*yglukhov joined #nim
01:52:03*vivus quit (Quit: Leaving)
02:02:11*mr_yogurt joined #nim
02:06:36*cspar__ joined #nim
02:07:06mr_yogurtVarriount: your plugin might be randomly inserting DELs (ascii character \127) into my code
02:09:22*cspar_ quit (Ping timeout: 240 seconds)
02:10:04FromGitter<Varriount> mr_yogurt: O_o
02:10:30FromGitter<Varriount> When?
02:10:30mr_yogurteither that or sublime text, or i have clumsy fingers and am accidentally hitting the hotkey for it
02:10:38mr_yogurti'm not even sure
02:11:04FromGitter<Varriount> I've never had the plugin insert odd characters for me..
02:11:07mr_yogurtjust, sometimes nim breaks because of unexpected character \127
02:11:32mr_yogurti don't know if it's your plugin
02:11:37FromGitter<Varriount> I'll add it to the list of things to look out for.
02:22:48*chemist69 quit (Ping timeout: 240 seconds)
02:25:15alexdayI am trying to unmarshal json on a type, so I did a import json and then I am using the to(resp.body, SuccessResponse) . but when I compile with nim c -r then it says Error: undeclared identifier: 'to'
02:25:20alexdaywhat am I missing
02:35:43FromGitter<Varriount> alexday: Could you show us your code?
02:35:59alexdayok. let me gist it
02:36:08alexdayits pretty bad though :P
02:36:48*chemist69 joined #nim
02:37:41alexdayhttps://gist.github.com/argentum47/ef27c93c1a4f96e60f25692141c3522c
02:38:04alexdayNim Compiler Version 0.16.0 (2017-01-09) [MacOSX: amd64]
02:38:26alexdayapis.nim(35, 16) Error: undeclared identifier: 'to'
02:38:48*MJCaley quit (Quit: MJCaley)
02:51:17*vlad1777d quit (Ping timeout: 268 seconds)
02:59:50*skrylar joined #nim
03:05:15*Serenit0r joined #nim
03:07:40FromGitter<Varriount> in.nim(35, 18) Error: type mismatch: got (string, type ApiResponseSuccess) ⏎ but expected one of: ⏎ macro to(node: JsonNode; T: typedesc): untyped
03:26:15*redlegion quit (Ping timeout: 255 seconds)
03:29:57*redlegion joined #nim
03:29:58*redlegion quit (Changing host)
03:29:58*redlegion joined #nim
03:47:43*marenz_ joined #nim
03:51:02alexdayhow do I convert response body to json node?
03:51:28*marenz__ quit (Ping timeout: 248 seconds)
03:51:53alexdayparseJson I think
03:52:07alexdayoh got it
03:55:13alexdaybut I still get an undeclared keyword `to`.
03:57:58alexdayis this a version mismatch?
04:00:32*sz0 quit (Quit: Connection closed for inactivity)
04:01:06alexdayupdating to 0.17.2 fixes that.
04:01:17alexdayI have other errors now. cool
04:04:20*mr_yogurt quit (Ping timeout: 260 seconds)
04:08:26*endragor joined #nim
04:10:56alexdayusing a tuple in my code example is ok? or is there a way to say like the function return type can be any of this two types? or what is the right way?
04:12:10*dexterk joined #nim
04:44:21alexdayhttps://gist.github.com/argentum47/ef27c93c1a4f96e60f25692141c3522c I am getting this error:
04:44:23alexdayapis.nim(40, 18) template/generic instantiation from here
04:44:25alexdaylib/pure/json.nim(1692, 7) Error: attempting to call undeclared routine: 'val='
04:44:28alexdaywhat does it mean?
04:45:54*Yardanico joined #nim
04:46:39*Yardanico quit (Remote host closed the connection)
04:49:23alexdayif I remove the Option[string] then everything works. but I need the next to be opional
04:52:05*marenz_ quit (Ping timeout: 240 seconds)
05:00:08skrylarmratsim: oi. do you have problems with NaNs in your neural nets?
05:00:36skrylari sometimes get them, but its usually when the hyperparameters are set very wrong; although i don't read people having the issue
05:04:32*SenasOzys quit (Ping timeout: 248 seconds)
05:06:34*noonien quit (Quit: Connection closed for inactivity)
05:07:06*jsgrant_ joined #nim
05:08:47*jsgrant quit (Ping timeout: 248 seconds)
05:16:46*SenasOzys joined #nim
05:17:50*cspar__ quit (Ping timeout: 255 seconds)
05:31:18*JappleAck joined #nim
05:34:24*jhope joined #nim
05:38:07jhopeHello, we're looking to build out a remote team to port a Python project over to Nim, since the community is small, it's unclear what the best way to find/solicit Nim developers? are job posts welcome in the forums?
05:41:54*SenasOzys quit (Remote host closed the connection)
05:42:06*SenasOzys joined #nim
05:47:11FromGitter<Varriount> jhope: How big is the project?
05:47:27FromGitter<Varriount> And is this a commercial project, or an open-source one?
05:49:37jhopeVarriount, it's commercial (in the sense that it's paid), and open source, we're looking to implement an Ethereum Blockchain client in Nim
05:51:19jhopeIt's rather large, we're looking to have an initial team size of 5 on it,
05:54:36jhopeThe reason for Nim is it's portability, we want to run on resource-restricted devices. Currently we're using a Golang implementation go-ethereum on mobile devices and its rather hefty, in addition to this the latest research is currently done in Python, so having a Nim port being closer in style may serve in porting latest developments out faster.
05:57:22*jsgrant_ quit (Ping timeout: 240 seconds)
05:59:36*SenasOzys quit (Read error: Connection reset by peer)
05:59:43*SenasOzys_ joined #nim
06:00:22FromGitter<Varriount> jhope: I would post on the forum. I wish you luck!
06:01:30jhopeThanks Varriount
06:01:42FromGitter<Varriount> jhope: Feel free to post here and on the forum any questions you have. The community is pretty helpful
06:09:37alexdayhow do I marshal an object of a custom type? if I do %(someobject) it shows error. if I do $$someobject , then it wraps the hash structure in array with some random number as the first value.
06:10:20alexdayis there something like {.inheritable.} ?
06:10:57alexdayoh sorry my bad
06:11:07alexdayit works actually.
06:16:36alexdayhow to stop comparing response.status to strings? can I have only integers? or are there constants in the language?
06:17:21alexdayoh got them. Http<Tab> I was doing http<tab> :P
06:18:02*miran joined #nim
06:27:47*dexterk quit (Quit: Konversation terminated!)
06:34:53skrylarhow many libs do we actually have for that stuff
06:35:04skrylardoesn't etherium need some SECP curve crypto things
06:38:11skrylar@qqtop well you can now get data out of firebird
06:43:22skrylarthere is also a new 'fun' landmine in that varchars are returned as pascal strings which means you have to decode a cshort when copying values out of the cursor
06:50:02*JappleAck quit (Ping timeout: 240 seconds)
06:59:07jhopeskrylar: i imagine wrapping libgcrypt , also theres talk of moving to libp2p instead of devp2p, in thise case there is c-libp2p
07:00:48ipjkWrapping is so nice and smooth in Nim.
07:01:09jhopethere's already a wrapper for gmp
07:02:02jhopethat pretty much covers the majority of dependencies, except maybe database, most implementations use leveldb and i've seen a few wrappers for that
07:02:53skrylari looked at rocksdb once
07:02:56skrylarit seemed okay
07:03:02skrylarrocks is leveldb plus some stuff iirc
07:03:21skrylarwe have mysql/postgres stuff somewhere. i have a firebird wrapper
07:03:21*JappleAck joined #nim
07:04:39jhopeRocksdb would be really interesting
07:05:10jhopethe leveldb in memory requirement is not really ideal
07:05:14Xea remote nim job does sound good, you by chance based in canada?
07:05:23Xe(looking to GTFO trumpland)
07:06:38jhopeWe're based out of Switzerland, most of the team is remote but euro-centric
07:07:40skrylarThe last holdout for privacy laws =p
07:08:25skrylarwhat do you actually need the database for; storing blockchain data?
07:09:31jhopeIndeed :)
07:09:40jhopeyeah for blockchain data
07:11:11*jsgrant_ joined #nim
07:11:48skrylari looked in to that at one point for caching namecoin (and clones) for an altdns thing
07:12:25skrylari suppose leveldb is fine-ish? it works if you're just storing stacks of blocks, i'd just go with a normal db if you're doing something like the querying servers
07:12:31skrylarRethink DB was nice
07:14:55skrylarthough probably not appropriate for that as blockchains dont change schema. meh
07:15:30jhopeI dont think leveldb is actually ideal, iirc it's designed as a disk backed mem db, Blockchain is much larger than what can be held entirely in memory
07:15:46ipjkXe Europe is kind of messy atm
07:16:21skrylarjhope, well, most of those servers are just using it as a data dump
07:16:44skrylarthey aren't making queries, they're just checking signatures
07:18:04skrylarSince I don't know what you're actually doing (writing nodes?) i can only point you towards things like DruidDB (columnar, time-series data) Rethink (real-time, nosql) Sqlite/Firebird (embeddable, transactions) and such.
07:18:05Xeipjk: which is why i'm hoping to move to canada, at the very least i'll be insulated from the insanity
07:19:09skrylaralthough you will probably still need the rocks/leveldb (or just a flat file store?) for raw blocks, since those are basically the transaction logs for the whole system x_x
07:24:33jhopeOur predominant use case is on mobile, so Rocksdb-lite is interesting for sure, having that said we have to have archival nodes also
07:26:07jhopeI notice the Parity implementation uses Hashdb on servers and Rocksdb for their light clients
07:26:08skrylarMmm. Mobile stuff tends to just use obelisk servers last i was involved
07:26:34jhopethey store blockchain headers from checkpoints
07:26:59jhopethey don't store state, except that which they cache when requesting it
07:27:03skrylaron android, sqlite is ubiquitous (and part of the OS)
07:28:33skrylarwhen i was last involved, the mobile clients would use obelisk or some internal thing (there was some popular light client at the time; although this was just for bitcoin) because they could just ask it 'show me all transactions for my wallet'
07:29:06skrylarmobile clients don't really need much more than that, and since metering is the default its sort of costly to parse blockchains on the phone
07:30:03skrylarunless you're making an app for fellow cypherpunks and not normies, in which case meh
07:30:22jhopehttps://status.im/
07:30:50jhopefor normies, but staying true to cypherpunk ideal as possible
07:31:16*skrylar shakes head at ETH but no ETC
07:31:38skrylarETH is not trustworthy. The DAO rollback defeated the whole chain of trust ETH was supposed to engender. But its a product so. meh
07:31:58jhopethe problem is of trust, if you have to extend too much trust to servers theres some seirous problems.
07:32:07jhopeskrylar: i felt like that too when it happened
07:32:24skrylarI will never use ETH personally for that reason
07:32:40skrylarETC is debatable. neat idea
07:32:40jhopeBlockchains are only immutable insofar is that there is not enough majority rule
07:32:54jhopefor ever the Parity hacks have't been unfrozen
07:32:59jhopefor example*
07:33:29skrylarwell the thing in this specific case is that the founders of eth had a conflict of interest in the decision
07:33:39skrylarthey did it to recover their own losses for their own careless mistakes in something they put on the platform
07:34:06skrylarwhich sets a precedent that its only safe as long as nobody cares. which is pointless
07:34:48jhopewell, thats hard to deny, I think demonstrating that ETH can handle its problems is useful to demonstrate to the SEC
07:35:36skrylarwell. you can write safeties in to dapps
07:35:46skrylarthey just didn't, and then learned why orgs have chairmen lol
07:36:11jhopeWe don't really have the tooling available to write ultra-reliable smart contracts
07:36:35jhopeWe need formal verification solution thats easy to use and way better practices, ie multiple implementations checking state
07:36:41skrylari haven't seen that smart contracts can actually do much
07:37:30skrylari think they were working on that, because they really do need a signal layer for dapps to interact with non-dapps
07:37:38skrylarsame thing is biting IPFS right now
07:40:35skrylarjhope, well let me know if you find a db system that is particularly interesting. some of them aren't hard to wrap
07:40:37jhope for state changes on blockchain Logs work well, acts as signal, could be better though I agree
07:41:04jhopewill do, thanks skrylar!
07:41:40skrylarRocks and Level are probably simple since they are fundamentally memcached-esque, although i think rocks client lib is in C++ only
07:41:54skrylarseem to recall that one is 3-4 core functions but more like 80 in total for weird things
07:45:00*JappleAck quit (Remote host closed the connection)
07:45:43*JappleAck joined #nim
07:54:41*skrylar quit (Ping timeout: 248 seconds)
08:03:12*SenasOzys_ quit (Ping timeout: 248 seconds)
08:03:52*nsf joined #nim
08:06:55*SenasOzys_ joined #nim
08:11:32*SenasOzys_ quit (Ping timeout: 255 seconds)
08:12:46*SenasOzys_ joined #nim
08:21:13cremIs there nim's equivalent of C's ` while (MyObj* x = GetNextObj()) { /* do something with x */ } ` ?
08:23:20cremSomething shorter than `while true: let x = getNextObj(); if x == nil: break`
08:26:40FromGitter<mratsim> @skrylar I get them in Python sometimes --> vanishing gradients
08:26:55*SenasOzys_ quit (Remote host closed the connection)
08:27:06*SenasOzys_ joined #nim
08:27:27FromGitter<mratsim> @crem we had this discussion like 8 hours ago alehander42 posted a macro that does Rust while let
08:28:20FromGitter<mratsim> For iterators this works: https://gist.github.com/mratsim/e0c7f2eefb8fa91fb27f0cd9a97cff00
08:29:22FromGitter<mratsim> mratsim: Regarding loops, a construct I found useful is Rust “while let” in combo with their option type, especially for stack and queues. ⏎ while let Some(foo) = bar_seq.pop() ⏎ —> It assigns to foo as long as pop() returns something, and if it returns none it stops the loop
08:30:03FromGitter<mratsim> Alehander42: <Arrrr> Would be nice to expose seq capacity for 1.0 ⏎ ⏎ From IRC (bridge bot) Nov 24 19:31 ⏎ <dom96> That's not a breaking change, is it? ⏎ <dom96> It can be exposed at any point after 1.0 too ... [https://gitter.im/nim-lang/Nim?at=5a192a0b232e79134dccc1c3]
08:30:20*yglukhov quit (Read error: No route to host)
08:30:30FromGitter<mratsim> Argh, >< gitter mobile ...
08:30:42*yglukhov joined #nim
08:31:03cremHm, I'll do with "while true, if nil break" approach I guess, even though I don't like it much. But I'm not comfortable with macros even more.
08:31:59ipjkcrem: can't you do "if getNextObj() == nil: break"?
08:32:27cremI need that obj.
08:32:36cremif it's not nil.
08:33:10cremI can do in 4 lines as I wrote. But it would be nicer to write that in 1.
08:33:46ipjklet obj = getNextObj(); if obj == nil: break works in one line
08:34:42ipjkis the function an iterrable?
08:34:48FromGitter<kayabaNerve> Make get next obj an iterator?
08:35:12FromGitter<kayabaNerve> for obj in getNextObj():
08:35:13ipjkkayab: Yeah, that's what I was thinking to
08:35:19FromGitter<kayabaNerve> Yeah
08:36:21cremHm, yeah, that actually may be nice trick.
08:37:12ipjkfor ojb in getObjs(): is probably the most cleanest
08:38:02FromGitter<stisa> crem: what about `while (let x = getNextObj(); not x.isnil): echo x` ?
08:38:33cremMy getObj() can sometimes throw an exception. Can iterator outlive it?
08:38:47cremstisa, if that works, that's what I need. Let me try.
08:39:49cremWorks, thanks!
08:40:16cremBut for iterator approach, a question. My getNextObj() sometimes throws exception. Will iterator survive that?
08:40:26ipjkI'm not sure about that
08:40:29ipjkTrying to look it up
08:40:39FromGitter<kayabaNerve> In try catch?
08:40:45ipjk"exceptions a proc/iterator/method/converter is allowed to raise", looks like it
08:40:58ipjkhttps://nim-lang.org/docs/manual.html#effect-system
08:45:51*yglukhov quit (Remote host closed the connection)
08:57:20*Vladar joined #nim
09:05:29crem"type X = ref object discard raise new(X)" crashes. How to raise exception? Do I have to use that newException always?
09:06:30FromGitter<kayabaNerve> Did you just try to raise an object?
09:07:08cremLike, in two lines? let x = new(X); raise x?
09:07:49cremOr in three lines? var x: X; new(x); raise x?
09:08:23cremNeither works
09:09:44cremhttps://play.nim-lang.org/?gist=f9efb940bd32980a30d86992eb2a993e
09:11:01*claudiuinberlin joined #nim
09:13:45FromGitter<alehander42> `Each exception has to inherit from `Exception`. `
09:14:06FromGitter<alehander42> why do you expect raising a custom object to work
09:14:26cremAh, will try that. That worked in C++. :) And in python2 I guess.
09:14:35ipjktype MyError = object of Exception
09:14:49cremI'd expect it not to compile though if compiler can detect that.
09:15:07ipjkAren't exceptions runtime errors?
09:15:43cremThey are, but compiler sees "raise" with type which it not inherited from Exception.
09:15:59cremTypes are compile-time.
09:17:37FromGitter<kayabaNerve> ^^ I didn't know how to correct it but
09:17:49FromGitter<kayabaNerve> *but I knew something was wrong
09:18:12cremWith inheriting from Exception it worked, thanks!
09:18:32*xkapastel quit (Quit: Connection closed for inactivity)
09:25:34ipjkraise takes an expression, not a variable of exception type, guess that's why.
09:27:07cremExpression also has type, known at compile time.
09:53:31*couven92 joined #nim
09:55:32cremWhat to do with "Warning: not GC-safe: 'Main()'"? I suspect it doesn't like sdl's window.getSurface() returning raw pointer and worries about it being hanging. How to tell it that that's fine!
09:55:59cremHm, actually not.
09:57:34cremIt didn't like global variable. Alright, I can understand him.
09:58:36*Trustable joined #nim
10:08:40*yglukhov joined #nim
10:10:05*Arrrr joined #nim
10:13:13*yglukhov quit (Ping timeout: 252 seconds)
10:14:24*SenasOzys_ quit (Remote host closed the connection)
10:14:40*SenasOzys_ joined #nim
10:18:47FromGitter<ephja> raise '\n' ;)
10:19:44crem"Cannot prove new(MyObj) is not nil"... Do I really have to check result of new(MyObj) for being nil?..
10:20:51FromGitter<ephja> it's probably still not possible to get rid of all of those warnings
10:21:41cremIt's actually not even warning but error. (when I try to assign that to non-nil field)
10:22:31FromGitter<ephja> the same goes for errors associated with 'not nil'
10:24:17FromGitter<ephja> let me check if 'not nil' is even used for anything other than tests in the official distribution
10:25:07FromGitter<ephja> here's a nice little search tool for windows, btw https://www.voidtools.com/support/everything/
10:26:09*SenasOzys_ quit (Ping timeout: 248 seconds)
10:29:20*yglukhov joined #nim
10:33:47*yglukhov quit (Ping timeout: 268 seconds)
10:36:20*SenasOzys_ joined #nim
10:45:37FromGitter<Varriount> @ephja I'll never understand why Windows search is always so slow
10:48:42FromGitter<ephja> with indexing as well?
10:49:50FromGitter<ephja> I mostly rely on other applications because of the lack of various search function, but it's possible that it has also been slow
10:49:55*yglukhov joined #nim
10:50:43*MJCaley joined #nim
10:54:45*yglukhov quit (Ping timeout: 268 seconds)
10:56:14FromGitter<Varriount> @ephja Rarely do I search for something using a term found in file contents. Usually it's the title I'm looking for.
10:57:03FromGitter<Varriount> It still takes 1-2 seconds for my computer to bring up results.
11:00:56FromGitter<ephja> doesn't seem *that* bad, but then again I don't know how many files you have :p
11:04:01*MJCaley quit (Quit: MJCaley)
11:05:21*BitPuffin|osx joined #nim
11:07:14*sz0 joined #nim
11:08:01*nsf quit (Quit: WeeChat 1.9.1)
11:10:35*yglukhov joined #nim
11:15:06*yglukhov quit (Ping timeout: 268 seconds)
11:23:43*ofelas joined #nim
11:29:42*BitPuffin|osx quit (Ping timeout: 240 seconds)
11:30:10FromGitter<mratsim> @crem Alehander added a PR just for you: https://github.com/nim-lang/Nim/pull/6806
11:32:59*ofelas_ joined #nim
11:35:50*ofelas quit (Ping timeout: 255 seconds)
11:41:27*miran quit (Ping timeout: 240 seconds)
11:42:23FromGitter<Varriount> @mratsim That macro seems a bit niche, and doesn't really save that many lines.
11:43:56*ofelas_ quit (Quit: shutdown -h now)
11:44:16*ofelas joined #nim
11:46:30FromGitter<mratsim> The one in sequtils I agree it might be too much. The one in Option module I like
11:48:27cremActually `while (let x = nextObj(); not x.isnil):` is good enought for me.
11:49:02FromGitter<mratsim> flatten proc coming soon: https://github.com/nim-lang/Nim/pull/6807
11:53:31*marenz_ joined #nim
11:57:43*Arrrr quit (Ping timeout: 252 seconds)
12:18:27*ofelas quit (Ping timeout: 240 seconds)
12:23:53*Trustable quit (Remote host closed the connection)
12:35:55*endragor quit (Remote host closed the connection)
12:49:29FromGitter<dom96> @Yardanico you around?
12:55:57*vlad1777d joined #nim
12:57:06FromGitter<alehander42> @Varriount I agree, I just enjoy writing macros :D
12:58:28*dddddd joined #nim
13:12:21*zolk3ri joined #nim
13:17:16*endragor joined #nim
13:23:23FromGitter<mratsim> A chance to talk about Nim memory region: https://news.ycombinator.com/item?id=15773283
13:30:22*Sentreen quit (Ping timeout: 260 seconds)
13:40:32*themagician joined #nim
13:43:04*Sentreen joined #nim
13:50:03dom96Cool, we're getting spam on the forum from Neo himself
14:05:02dom96mratsim: cool, didn't know this was implemented already
14:07:16AraqNeo?
14:13:53dom96https://upload.wikimedia.org/wikipedia/en/c/c6/NeoTheMatrix.jpg
14:13:59FromGitter<mratsim> It’s the Mr Hide version of @andreaferretti
14:16:30*Amrykid2 joined #nim
14:23:38*miran joined #nim
14:25:04FromGitter<Veladus> I'm currently making my first PR, which consists of moving the functions encodeUrl and decodeUrl to uri and deprecating to old one ⏎ Now my question the test cases in the old cgi module use plain assert, but the testcases in uri all use doAssert, which one shall I use
14:35:11Araqveladus: don't deprecate the old ones, forward them via 'export'
14:35:14*Veladus joined #nim
14:35:26*Veladus quit (Client Quit)
14:36:23dom96You should use doAssert
14:36:29dom96Araq: Why?
14:37:06dom96I mean, meh, I suppose that's fine too
14:37:29dom96Veladus: just add 'export encodeUrl, decodeUrl' in cgi.nim
14:37:41dom96but yeah, use doAssert
15:12:22miranis there any official style how nimble package repo should look like?
15:14:05federico3miran: there's a link at https://github.com/nim-lang/nimble/issues/413
15:14:09*couven92 quit (Ping timeout: 250 seconds)
15:14:37miranfrom what i've seen some packages have source files in `src` folder, some in `$packagename` folder, some other have no sub-folders at all
15:15:30miranfederico3: thanks for the lin
15:15:34miran...k
15:16:11FromGitter<Veladus> @dom96 is adding a nexport enough to ensure js compatability? I don't know about the details of ``export``
15:24:36dom96Veladus: well, that part is irrelevant to JS compat.
15:24:46dom96It's just so that users of cgi won't have to change their code
15:25:10dom96Move the proc into the uri module and then just add an `import uri` and export in the cgi module
15:30:32*sz0 quit (Quit: Connection closed for inactivity)
15:31:02*Snircle joined #nim
15:33:25FromGitter<Veladus> @dom96 got it, thanks for your help :)
15:33:33dom96np :)
15:36:10Araq## A module that contains a macro ``runnableExamples`` you should use to mark
15:36:10Araq## `runnable example`:idx: code with.
15:36:10Araq## - In normal debug and release builds code within
15:36:10Araq## a ``runnableExamples`` section is ignored.
15:36:11Araq## - The documentation generator is aware of these examples and considers them
15:36:12Araq## part of the ``##`` doc comment.
15:36:13Araq## - A helper program that is built from this module when it is compiled as the
15:36:16Araq## main module collects the runnable examples in a module file and ensures
15:36:18Araq## they continue to compile and run. The collected examples are put into
15:36:20Araq## their own module to ensure the examples do not refer to non-exported
15:36:22Araq## symbols.
15:36:24Araqcomplain now if there is something you don't agree with
15:36:34Araqbecause I'm writing this module/tool.
15:38:43dom96It should be the other way around
15:39:03dom96Examples should be tested by default
15:39:05Araq?
15:39:12Araqhow so?
15:39:16dom96And a way to ask the tool not to test them should be provided
15:39:19Araqthat's stupid.
15:39:30dom96Thanks
15:39:44Araqthe tool is not called during compilations
15:40:24Araqthere is no "default".
15:40:37dom96We should test all code examples in doc comments
15:40:39dom96By default
15:40:48dom96That's not "stupid"
15:41:15Araqwhich tool should test it?
15:41:22dom96testament
15:41:44Araqthat's not used by nimble packages.
15:43:00AraqI'm writing something for everybody, not just for Nim's core.
15:44:17dom96okay, so why not test all examples?
15:45:10cremShould I use Vladar4/sdl2_nim or nim-lang/sdl2 ? First one says "I wouldn't create this one if I knew there was official one", and "official" one is outdated, doesn't even have functions of 2.0.5 which is 18 months old..
15:45:11dom96oh good. @Yardanico is still around, just posted on my GitHub PR. Was getting worried there.
15:45:21Araqthat's not the topic. we can do that but it's some work and I'd rather patch the stdlib instead
15:45:42Araqbecause runnable code in doc comments is annoying me
15:45:53Araq## .. code-block:: nim
15:45:56Araq## ...
15:45:59Araq## ...
15:46:20Araqand then you probably have comments within comments
15:46:43AraqI know Python and Rust do it this way so it cannot be improved upon, but I disagree.
15:46:54dom96oh, so you want a runnableExample section outside of the doc comment
15:47:00dom96like in the proc's body?
15:47:02Araqyes!
15:47:30dom96Okay, fine, but you lose a lot of formatting capability
15:47:46Araqhuh? what do you mean?
15:47:49dom96Call it `runnableExample` and give it an id
15:48:07*miran_ joined #nim
15:48:13*miran quit (Ping timeout: 258 seconds)
15:48:18*miran_ is now known as miran
15:48:24dom96so I can write "## My awesome example of doing this thing. **WArning:** This may be dangerous. .. runnable-example:: ID
15:48:26dom96or similar
15:48:31dom96and the doc gen knows to place that in there
15:48:35dom96we can implement that later
15:48:42dom96but future proof the macro so it accepts an ID
15:48:58miranany way to use iterators outside for loop? something like `next(iterator)`?
15:49:10dom96crem: Good question.
15:52:10cremIt seems that sdl2_nim is much more up to date, so may be it's a good idea to deprecate the other. But they have a bit different interfaces. I'm trying to adapt what I wrote for nim-lang/sdl2 to sdl2_nim.
15:54:51cremIt seems to be a bit lower level. cint's everywhere, errors are returned as cints rather than "Sdl_return" enum..
15:58:53cremIs there maybe a centralized location of all `nim doc`-generated docs for all published packages? :)
16:01:32FromGitter<stisa> crem I believe https://nimble.directory builds the docs of the packages it indexes
16:04:17*JappleAck quit (Ping timeout: 248 seconds)
16:04:51cremThanks! Everything is so hidden and secret in nim.
16:07:05dom96Suggestions on how to make things less hidden welcome :)
16:07:23dom96I guess it's about time to point packages.nim-lang.org to nimble.directory
16:08:55federico3dom96: perhaps #6492 could help - I could take a stab at it but I need some pointers on where to add the right directives
16:12:11dom96Araq will have to help here.
16:16:44dom96miran: only if the iterator is a closure I think
16:17:34miranok, how to get one (next) value then? any special syntax for it?
16:21:38*JappleAck joined #nim
16:29:27*ofelas joined #nim
16:30:44*xkapastel joined #nim
16:42:47dom96https://nim-lang.org/docs/manual.html#iterators-and-the-for-statement-first-class-iterators
16:44:11*Amrykid2 quit (Ping timeout: 258 seconds)
16:44:19mirani've read that but couldn't find what i was looking for
16:46:47dom96See the while loop examples
16:47:02dom96You instantiate the iterator
16:47:11dom96and then call the instantiation
16:47:39miranok, i'll try to implement that
16:48:46federico3ohh, what is this https://github.com/nim-lang/needed-libraries/issues/79 - using sphinx to generate Nim docs
16:50:30FromGitter<mratsim> Feel free to use Karax for Sphinx like docs ;)
16:51:28FromGitter<mratsim> Sphinx seemed like the low-hanging fruits.
16:54:08mirandom96: i managed to do it! thanks!
17:00:19*ofelas quit (Ping timeout: 250 seconds)
17:04:12*ofelas joined #nim
17:10:52*ofelas quit (Ping timeout: 260 seconds)
17:13:05cremIs it possible to pass addr to a temporary object during the call in one line? e.g. fillRect(addr(Rect(x,y,h,w))) (fillRect happened to accept ptr Rect).
17:14:18cremhold on, I have a problem elsewhere.
17:14:35cremSeems that Rect(x,y,h,w) is incorrect syntax.
17:15:59federico3mratsim: the generated doc is better that docgen and can be hosted by readthedocs. Quite handy. I wonder if there's an easy way to extract docstrigs and so on from Nim code.
17:18:19cremasking again with corrected syntax:
17:18:31cremIs it possible to pass addr to a temporary object during the call in one line? e.g. fillRect(addr(Rect(x:0,y:0,h:0,w:0))) (fillRect happened to accept ptr Rect).
17:18:49cremExpected answer is -no- though..
17:24:14*ofelas joined #nim
17:28:10*mwbrown quit (Quit: Exiting)
17:31:06cremWhen I run package using `nimble build -r`, it doesn't output program's stdout to console. Any way to see it?
17:32:06*MJCaley joined #nim
17:35:41FromGitter<mratsim> @crem, does your object live long enough?
17:36:53FromGitter<mratsim> try unsafeAddr in your second example
17:38:47cremThat object is only needed during the call. Thanks, will try.
17:39:11FromGitter<nitely> Araq: would implementing items/pairs for closure iterator be a good idea? There was a conversation about creating an "iterable" type that would include iterators+openarray but I don't think that's possible
17:39:43cremNo it says "object has no address" for temporary objects.
17:42:53FromGitter<mratsim> Then you need to assign it to a variable. (Nim constructs the temp directly in the addr call but since it’s done like this it has no address)
17:46:08*mwbrown joined #nim
17:46:54FromGitter<mratsim> You would have the same issue in C, or C++ (met that a lot while wrapping Nvidia libraries)
17:51:31*nsf joined #nim
17:52:37FromGitter<mratsim> @dom96, doAssert done https://github.com/nim-lang/Nim/pull/6807
17:53:31FromGitter<mratsim> I’m not really sure how to doAssert an iterator though
17:56:57dom96mratsim: create another flattened list above, add a counter and use `doAssert flatitems(s)[i] == flattenedResult[i]`. I dunno, maybe that's too far :)
17:58:14FromGitter<mratsim> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a19af36541a6f0337124054]
18:00:05*chemist69 quit (Ping timeout: 258 seconds)
18:04:26FromGitter<mratsim> updated.
18:05:27*JappleAck quit (Quit: Leaving)
18:09:40*ofelas quit (Ping timeout: 258 seconds)
18:10:01dom96crem: does that actually run a package?
18:10:15FromGitter<mratsim> So Ethereum needs a new programming language: https://github.com/ethereum/viper
18:11:27dom96are they just re-modelling Python?
18:13:40*chemist69 joined #nim
18:15:51FromGitter<mratsim> vote for me: https://www.reddit.com/r/ethereum/comments/7fddey/is_there_any_reason_ethereum_cant_use_an_existing/dqbpqgx/
18:18:27dom96Done :)
18:20:57FromGitter<Yardanico> dom96: hi, just a lot of school/preparing for exams, so not a lot of time for games and programming :P but anyway I generally looked at a lot of new Nim PRs/commits
18:21:20dom96Yardanico: Ahh, that's what I thought, hope it's going well for you
18:23:42cremdom96: yes it does, just stdin is not forwarded.
18:28:42*couven92 joined #nim
18:31:00dom96crem: hrm, you mean stdout?
18:31:12dom96Try using the --verbose or --debug
18:31:13cremyes
18:31:14dom96flag
18:31:30cremI did use --verbose, will try --debug
18:31:44alexdayhow can I have a Table type in nim
18:32:05couven92import tables
18:32:20couven92or strtabs for specialized string tables
18:33:16alexdayI did import tables. but when I do Request = type object name: string, config: Table it complained saying Table is not a conncrete type. This type system is a little new
18:33:18alexdayto me
18:33:49couven92https://nim-lang.org/docs/tables.html see for examples
18:33:54alexdaymaybe its like Table[string, string]
18:33:56alexdayoh ok
18:33:58alexdaychecking
18:44:04alexdayone more question. so the key value pairs that I will get from the api request can be like config: { name: 'a' } or say config: { id: 1 }. in this case to say something like Table[string, myType] . will this myType will be a variant kind of thing? like https://github.com/nim-lang/Nim/wiki/Common-Criticisms#sum-types-are-weird
18:46:58FromGitter<mratsim> If your API is json you can use JSON directly: https://nim-lang.org/docs/json.html otherwise indeed you will need sum types (or inheritance but for int and strings it’s not worth it).
18:51:30alexdayI am trying to use `to` of the json module to a type. So if I don't want to get into the Table and sum kind, what can I say the type of config in my object definition?
18:52:00dom96Don't use `to`, just do: parseJson(json)["name"].getStr()
18:52:11dom96or parseJson(json)["id"].getInt()
18:52:32alexdayok. yeah I can do that I guess. skip the type conversion.
18:52:51alexdayit just complicates things a little bit
18:53:31dom96the `to` macro needs improvements
18:53:48dom96it can't handle optional fields
18:54:19alexdayyeh faced that problem :P
19:10:08FromGitter<alehander42> I had some weird problems with ref objects and `to` too
19:10:33FromGitter<alehander42> so I had to write manually an additional convertion function
19:10:53FromGitter<alehander42> sometimes you *have* to convert your json to full objects, so `to` is important
19:22:25dom96please submit issues for these cases
19:23:35*demi- quit (Quit: Server shutdown in 3... 2... 1...)
19:23:49Araqalehander42: yeah we know it's a pretty important feature that needs more love
19:24:16FromGitter<Varriount> Araq: Does nimsuggest still have that TCP issue where it closes the connection after a single command?
19:24:50FromGitter<alehander42> yep, I'll submit repro-s on monday
19:27:51Araqvarriount: I think so but EPC is now the preferred interface, I guess
19:30:50dom96We should get LSP
19:30:59FromGitter<Varriount> LSP?
19:31:14dom96https://langserver.org/
19:33:33FromGitter<Varriount> And of course it was written by web developers.
19:33:37FromGitter<Varriount> -_-
19:33:52federico3urgh
19:35:05*nsf quit (Quit: WeeChat 1.9.1)
19:35:39AraqLSP doesn't really fit Nim
19:35:54AraqNim has plenty of symbol kinds that LSP has no clue about
19:38:24dom96okay, we should at least write a proxy
19:38:41Araqit's also not obvious why it tries to model classes, methods and enums to begin with, it should focus on the autocompletion aspect ffs
19:39:28FromGitter<Varriount> dom96: A proxy for nimsuggest? Translating one connection method to another connection method?
19:40:27dom96sure
19:40:42AraqEPC came first and should have got the adoption
19:40:52Araqbut *shrug* PRs are welcome
19:41:10FromGitter<Varriount> Araq: It's probably so a correct list of symbols can be gathered. There's no need to get symbols representing variables if you know you will be needing a method or attribute.
19:41:17dom96I can't even google for EPC
19:41:59FromGitter<Varriount> The only reason EPC is used is because it's halfway friendly/efficient.
19:42:36FromGitter<Varriount> stdin has the weird formatting meant for interactive use, and tcp has the "lets only send one command per connection" idea.
19:43:45Araqstdin with --debug is simple to parse, the nimsuggest tester uses it
19:43:47dom96where can I find the spec for EPC?
19:44:46dom96Argh, no. I need to stop myself from making more projects :)
19:46:09Araqdom96, good point, I can't find it either
19:46:11FromGitter<Varriount> dom96: Does your json-rpc module implement the actual JSON-rpc spec?
19:46:23dom96Varriount: nope
19:46:28FromGitter<Varriount> Darn.
19:46:30Araqdoes any stdlib module actually implement the spec?
19:46:42dom96or maybe it does
19:46:47dom96I actually can't remember :)
19:46:57Araqspecs are too hard to implement
19:47:13dom96Araq: All of them do?
19:47:41Araqthey all implement "useful" subsets of the specs
19:51:11FromGitter<Varriount> Well the first part of implementing this language server would be to modify the compiler to support accepting a graph of modules already in memory.
19:52:04Araqwhy? huh?
19:52:35FromGitter<Varriount> Because reading from dirty files is inefficient.
19:52:55FromGitter<Varriount> The editor sends the server changesinsteads
19:53:00FromGitter<Varriount> *changes instead
19:58:43Araqjust ignore that part of the spec, it's stupid
20:00:04Araqno compiler really has support for this, that's not how compilers work
20:06:22FromGitter<mratsim> (https://files.gitter.im/nim-lang/Nim/xFxo/2017-11-25_21-06-12.png)
20:08:06FromGitter<Varriount> Araq: That's because compilers aren't language servers
20:08:30Araqmratsim: that's a GC in action. turning bugs into leaks instead of crashes.
20:08:57Araq(until it crashes with OOM, that is)
20:08:59*Jesin quit (Quit: Leaving)
20:10:13Araqvarriount: if you don't want to use a compiler to serve these suggestions, what is the point of this protocol?
20:10:16FromGitter<Varriount> Araq: Language servers don't need to generate C code or do exhaustive semantic analysis. All they need to do is get a list of symbols.
20:12:09FromGitter<Varriount> Well, and find references/definitions of symbols
20:12:51Araqwell if you want state-of-the-art quality, it involves all the frontend aspects of a real compiler
20:13:40FromGitter<Varriount> Which might include submitting a graph of in-memory modules?
20:14:47*Vladar quit (Quit: Leaving)
20:15:26Araqthe last time I checked the protocol submits file diffs
20:16:37*MJCaley quit (Quit: MJCaley)
20:16:43Araqthat's not useful for a language frontend at all, frontends cannot use this text diff to produce an AST diff, that would be a ridiculously fragile process
20:17:01Araqinstead they reparse the file from top to bottom.
20:17:50*MJCaley joined #nim
20:17:57FromGitter<Varriount> So the language server portion maintains in-memory versions of the files, applies the diff, and submits them to the compiler
20:19:28FromGitter<Varriount> All the current editors using nimsuggest do that, albeit inefficiently. Nimsuggest requires files to be present in the filesystem
20:19:35Araqyeah, and you know what is simpler? temporary files
20:19:45FromGitter<Varriount> It's also much slower
20:20:27Araqyou never gave any numbers.
20:21:09Araqit's not like you need to write it to disk, it's virtual memory management, files can be in RAM
20:21:21cremThere's no syntax for ref objects similar to MyObj(myfield: 1), is there? Something like new(MyObj, myfield:1) or I don't know.
20:21:43Araqcrem, MyObj(field: 1) works if MyObj is a ref object
20:21:54cremAh, thanks!
20:21:56Araqor you can use (ref MyObj)(field: 1)
20:22:28cremMyObj is indeed ref object, just it's not obvious that there's implicit new. Thanks.
20:23:40FromGitter<data-man> @Varriount: Try nim ctags <file.nim>
20:24:05FromGitter<Varriount> @data-man What is that?
20:24:19FromGitter<data-man> New command
20:24:28FromGitter<data-man> In devel
20:24:31Araqdata-man: is that in the changelog?
20:26:15FromGitter<data-man> @Araq: No. You applied a changes :)
20:27:33FromGitter<data-man> https://github.com/nim-lang/Nim/pull/6654
20:31:00cremIs there anywhere to read why I might be getting Warning: not GC-safe?
20:32:13FromGitter<Varriount> Araq: What would you consider a relevant benchmark? Editing and the then reading from a graph of strings vs editing and reading from a file handle?
20:33:20Araqrelevant benchmark: "saving this file to /tmp takes more than 10ms which is humanly noticable"
20:33:37Araqextra points if the file is not 4GB in size.
20:34:01FromGitter<Varriount> Yes, but then you have to read the file back in.
20:34:22*jsgrant_ quit (Ping timeout: 240 seconds)
20:34:46Araqer ... and you think that is a bottleneck for running the Nim compiler over a file?
20:35:04Araqfile IO never shows up in the profiles.
20:35:23FromGitter<Varriount> Versus having the compiler read the file contents directly from memory?
20:35:54Araqif you optimize what is in the noise, what do you think happens? nothing.
20:37:17Araqsorry, but we're talking about feelings here. you feel the lag is too long (and it might be!) and just conclude it has to be because of IO.
20:39:49cremHm, where those warnings come from. nim c -w:on filename.nim doesn't show any warnings, but nimlime shows them when I save a file.
20:40:11Araqcrem, nimline uses verbosity:2 iirc
20:40:43cremIndeed, thanks.
20:41:13cremNow trying to understand where "GcUnsafe" comes from..
20:46:52Araqhttps://gist.github.com/Araq/56b1d263eda728ce7269c5cc7ba5f921
20:47:15Araqsystem.nim has 4000 lines of code, which is realistic
20:47:26nivhello
20:47:27Araqon my machine (no SSD) it takes 3ms
20:47:34Araqsometimes 4ms
20:49:08Araqif you can notice that you're some professional Broodwar player
20:49:28*mr_yogurt joined #nim
20:50:19cremAlso lib/system.nim(2701, 5) Warning: shadowed identifier: 'e' [ShadowIdent] (0.17.2)
20:51:49Araqstill 4 times shorter than a single frame in an 60FPS shooter
20:51:49cremProbably it shadowed my var.. as newException is a template.
20:52:17cremindeed. Sorry for noise.
20:57:43cremPutting {.gcsafe.} to a random place seems to fix the issue. What does it really mean?
20:58:46cremThere is a doc. Reading.
21:10:22cremIs there an analog to C++'s gtl::optional in nim? Basically "object or null" but without additional level of indirection like it would be with ref object.
21:10:29cremoops
21:10:36cremI mean boost::optional
21:11:50cremProbably doable with case valid: bool
21:12:56cremIndeed. Would be nice to have a template for that in stdlib!
21:13:50cremIf MyObjPtr is ptr type, is it possible to get original non-ptr type from it?
21:16:08FromGitter<Varriount> There's an option type
21:17:06*jsgrant_ joined #nim
21:19:25cremIndeed! Typed too many letters in search. Thanks.
21:19:57cremSorry, too many questions today which could be looked up in docs.
21:20:47*MJCaley quit (Quit: MJCaley)
21:22:29*jsgrant_ quit (Remote host closed the connection)
21:22:53*jsgrant_ joined #nim
21:28:27*MJCaley joined #nim
21:29:40FromGitter<mratsim> @crem dereference operator is yourvar[]
21:30:36*claudiuinberlin quit (Quit: Textual IRC Client: www.textualapp.com)
21:38:33*MJCaley quit (Quit: MJCaley)
21:46:26cremI need type, not object.
21:46:41*miran quit (Ping timeout: 240 seconds)
21:47:00cremneeded. Not anymore, but still would be knice to know.
21:47:04crems/knice/nice
21:48:07cremtype X = ref object; type Y = ref object x: "unref" X
22:00:23FromGitter<mratsim> no idea. I’m sure we can create a ugly hack like: ⏎ ⏎ ```type ugly_unref[T] = concept x ⏎ x is ref[T]``` ⏎ ⏎ And get the T from the concept. Other ideas include getType/getTypeInst and try to get something useful from the AST. [https://gitter.im/nim-lang/Nim?at=5a19e7f66b5080350f2e1568]
22:07:25FromGitter<mratsim> There is one killer thing that Nim has and few other langs do in my opinion: ⏎ ⏎ 1) refactoring speed ⏎ ⏎ Python syntax: I don’t look at hundreds of brackets, and I don’t have the Java indirection hell as well. ... [https://gitter.im/nim-lang/Nim?at=5a19e99ddf09362e67523236]
22:07:34FromGitter<mratsim> Forgot: fast compilation time
22:13:57*zolk3ri left #nim (#nim)
22:16:59*endragor quit (Remote host closed the connection)
22:40:15*mr_yogurt quit (Ping timeout: 260 seconds)
22:46:35*noonien joined #nim
23:11:03*jsgrant_ quit (Ping timeout: 268 seconds)
23:21:33*jjido joined #nim
23:34:52*jsgrant_ joined #nim
23:38:40*jjido quit (Ping timeout: 248 seconds)
23:46:03*MJCaley joined #nim
23:48:55*vivus joined #nim
23:58:14FromGitter<brentp> @mratsim I like all those things too, but I found refactoring in go was very good due to tooling support. For example, I could rename a struct member and a tool would propagate it through the code-base. The tooling combined with nice editor (vim) integration is the only thing I really miss from go after mostly moving to nim.