00:03:34 | FromGitter | <tweenietomatoes> zachary carter im your biggest fan |
00:14:38 | * | Ven`` joined #nim |
00:19:12 | FromGitter | <kayabaNerve> @tweenietomatoes Fight me, I definitely weigh more than you /s |
00:21:17 | FromGitter | <tweenietomatoes> you mean 125 kg? |
00:21:42 | FromGitter | <kayabaNerve> I'm lbs so I win |
00:21:58 | FromGitter | <tweenietomatoes> 275 lbs? |
00:22:30 | FromGitter | <tweenietomatoes> pls someone teach me how to make extremely good tcp listener |
00:22:41 | FromGitter | <kayabaNerve> lbs > kg and you're kg so I win /s |
00:22:59 | FromGitter | <tweenietomatoes> 1) 2 lbs is 1 kg |
00:23:09 | FromGitter | <kayabaNerve> Nahhhh |
00:23:29 | FromGitter | <tweenietomatoes> ok open a repository |
00:23:36 | FromGitter | <tweenietomatoes> and write a comparasion script |
00:23:38 | FromGitter | <tweenietomatoes> with Nim |
00:23:51 | FromGitter | <tweenietomatoes> Nim LukeParker Fighter SuperbApp |
00:25:05 | FromGitter | <tweenietomatoes> last quarter of 2018 we started ember cryptocurrency |
00:42:08 | FromGitter | <zacharycarter> lol @tweenietomatoes - why is that? I didn't realize I had any fans :P |
00:42:22 | FromGitter | <zacharycarter> I appreciate it though! hahaha |
00:42:27 | FromGitter | <kayabaNerve> What about Ember? I started that in Q2 IIRC |
00:57:26 | * | steve1 joined #nim |
00:59:56 | * | vlad1777d joined #nim |
01:00:25 | * | wildlander_ joined #nim |
01:01:11 | * | wildlander quit (Ping timeout: 258 seconds) |
01:01:52 | * | steve1 quit (Ping timeout: 246 seconds) |
01:04:39 | * | shpx quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
01:05:14 | * | Ven`` quit (Ping timeout: 246 seconds) |
01:05:27 | FromGitter | <zetashift> @zacharycarter quick question concerning that composition question: if my `Fighter` object also has a property like `hp` or `damage` how would I initiate it? e.g. whenever I make a new monster on the map I pass in it's maxHP, damage and power but I don't know how to pass those things along in my `newEntity` proc as it expects an `entityType` which is an enum |
01:06:24 | FromGitter | <zacharycarter> you'd check to see the kind property on it |
01:06:30 | FromGitter | <zacharycarter> let me expand the example - one moment |
01:06:38 | * | shpx joined #nim |
01:07:40 | FromGitter | <zetashift> so `newEntity` gets in an `entityType` based on that it sets the properties of an `Fighter` object I also supply? |
01:10:05 | * | shpx quit (Client Quit) |
01:10:21 | FromGitter | <zacharycarter> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c3be17d39596c372bd92b80] |
01:10:48 | FromGitter | <zacharycarter> this isn't very flexible though... you could handle it in a number of ways |
01:11:25 | FromGitter | <zacharycarter> generics might be a better way to solve this |
01:11:57 | * | ng0 quit (Quit: Alexa, when is the end of world?) |
01:12:20 | FromGitter | <zacharycarter> with inheritance |
01:13:14 | FromGitter | <zacharycarter> you don't need multiple dispatch - you can probably model this with single dispatch and generics + inheritance |
01:18:49 | * | wildlander_ quit (Quit: Konversation terminated!) |
01:19:04 | * | rockcavera joined #nim |
01:24:46 | FromGitter | <zetashift> the thing is before this I was making a Fighter type outside of a `newEntity` proc and then passing it to the entity |
01:24:59 | FromGitter | <zetashift> so hp/mana etc where set outside of it |
01:25:23 | FromGitter | <zetashift> I could do it with inheritance with that approach I guess |
01:50:35 | * | dcefram joined #nim |
01:50:50 | * | dcefram is now known as dcefram_ |
01:50:51 | * | dcefram_ is now known as dcefram__ |
01:50:52 | * | dcefram__ is now known as dcefram |
01:51:21 | * | dcefram quit (Client Quit) |
02:08:06 | * | skellock joined #nim |
02:11:52 | * | theelous3 quit (Ping timeout: 246 seconds) |
02:21:48 | FromGitter | <zetashift> @zacharycarter whatchu think about this? https://hastebin.com/ulitijunuv.cs |
02:23:40 | FromGitter | <zetashift> and then I just make `newMob` and `newItem` procs |
02:25:45 | * | dddddd quit (Remote host closed the connection) |
02:26:53 | FromGitter | <zacharycarter> yeah - you can do `newMobT (...): T = ...` |
02:27:12 | FromGitter | <zacharycarter> looks workable to me |
02:30:23 | FromGitter | <zetashift> Huh I was thinking more along the lines that `newMob` get's an entity frame and than a fighter parameter and returns a `Mob` |
02:31:27 | * | Tyresc quit (Quit: WeeChat 2.4-dev) |
02:34:57 | FromGitter | <zacharycarter> it's one way - but I generally like to try to follow - https://nim-lang.org/docs/tut2.html#generics |
02:35:03 | FromGitter | <zacharycarter> when possible anyway |
02:37:29 | FromGitter | <zetashift> I'm not sure how I would implement newMob like this based on the [T] it get's it spawns a new mob, e.g. if T = Orc it would spawn an orc with all the correct hp/attack values? |
02:46:16 | FromGitter | <zacharycarter> @zetashift - |
02:46:20 | FromGitter | <zacharycarter> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c3bf7fcc45b986d11585097] |
02:46:32 | FromGitter | <zacharycarter> not sure if that pattern will work for you or not... |
02:47:38 | FromGitter | <zacharycarter> and if you need more specific new procedures - you can create them |
02:48:12 | FromGitter | <zacharycarter> so you could still have - ⏎ `proc newOrc(): Orc = ...` if you wanted |
02:55:47 | FromGitter | <zetashift> Thanks alot! this is much better |
02:58:06 | * | rockcavera quit (Remote host closed the connection) |
03:00:35 | * | banc quit (Quit: Bye) |
03:07:03 | FromGitter | <timotheecour> is there an environment variable to override `~/.nimble` ? it causes otherwise major pain when user has multiple concurrent Nim folders |
03:07:36 | FromGitter | <timotheecour> @dom96 if you’re seeing this ^ |
03:08:29 | leorize | NIMBLE_DIR |
03:09:58 | * | vlad1777d quit (Ping timeout: 246 seconds) |
03:12:25 | FromGitter | <timotheecour> thanks! shd definitely be mentioned in `https://github.com/nim-lang/nimble` readme and in `nimble —help`; it in neither :( |
03:15:54 | * | banc joined #nim |
03:24:53 | shashlick | @timotheecour: nimble has a --nimbleDir flag (so does choosenim) so you can have a custom path for |
03:25:07 | shashlick | i plan on leveraging that internally to allow local package dir |
03:27:18 | shashlick | looks like there's https://github.com/nim-lang/nimble#compile-with-nim-after-changing-the-nimble-directory as well |
03:34:56 | FromGitter | <timotheecour> ya unfortunately ` —nimbleDir` doesn’t help unless u’re directly calling nimble ; eg: u can’t pass it to `./koch tests` so if you’re working on 2 nim repos (and have a compiler pkg in ~/.nimble/pkgs) then tests will use the wrong repo |
03:38:38 | shashlick | you can set it in nim.cfg so nim will know where to look |
03:39:46 | FromGitter | <timotheecour> ya except it’s at the root, which bad as including `—path:pathto/Nim` puts everything in scope |
03:40:08 | FromGitter | <timotheecour> Instead we shd do this: `mv compiler lib/compiler` in Nim repo |
03:41:43 | FromGitter | <timotheecour> that way we can add: `—path:lib` and it would prevent any module clash (eg wouldn’t bring koch.nim in scope just bc u did `—path:pathto/Nim/lib` |
03:42:07 | FromGitter | <m4d3bug> `` |
03:42:32 | FromGitter | <m4d3bug> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c3c052835350772cf298dd4] |
03:43:10 | FromGitter | <m4d3bug> Looks like the database connection error? |
03:43:16 | FromGitter | <timotheecour> @sha also, note that simply adding `—path:pathto/Nim/lib` is stil lnot ideal |
03:43:58 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
03:44:37 | FromGitter | <m4d3bug> But I tried mysql -u [email protected] -p |
03:44:50 | FromGitter | <timotheecour> because it still brings existing `~/.nimble/pkgs/compiler#head/foo/bar.nim` in scope in case it’s not in ur 2ndary Nim repo under `Nim_secondary/compiler/foo/bar.nim` ; do u see what i mean @shashlick ? |
03:45:00 | FromGitter | <m4d3bug> the connect is ok |
03:45:36 | FromGitter | <m4d3bug> Is there any problem with the method I verified? |
03:46:04 | FromGitter | <m4d3bug> Is there any problem with the method I verified? |
03:50:24 | * | lritter quit (Ping timeout: 250 seconds) |
03:51:06 | * | lritter joined #nim |
03:52:06 | leorize | timotheecour: I think you would want `--noNimblePath`? |
03:52:20 | leorize | to pass it to koch tests, just pass it as the last argument |
03:53:49 | FromGitter | <timotheecour> so that shd probably be added to `Nim/tests/nim.cfg` |
03:55:08 | FromGitter | <timotheecour> other comment i wrote above still holds though; it brings every path in scope including things that aren’t intended to be added in scope; but that’s an issue we can deal w independently |
03:56:42 | FromGitter | <timotheecour> we’have:Nim/tests/nim.cfg ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c3c087a39596c372bda08da] |
04:04:10 | * | nsf joined #nim |
04:08:20 | FromGitter | <matrixbot> `curioussav` When I run nimble build does it build with the release flag by default? Readme for nimble didn’t seem to say last I checked. |
04:08:47 | FromGitter | <timotheecour> use ` —verbose` |
04:14:30 | * | itschin joined #nim |
04:28:00 | Tanger | m4d3bug: How are you connecting to the db in your code? |
04:48:30 | FromGitter | <matrixbot> `curioussav` With nimble 0.9.0 I get “git hash: couldn’t determine git hash” tried nimble build —verbose it only includes two lines in the output about the stdlib prefix and path. |
04:56:10 | shashlick | sorry @timotheecour - not sure i get it, don't have the full context |
04:59:20 | * | steve1 joined #nim |
05:02:45 | * | shpx joined #nim |
05:03:27 | * | steve1 quit (Ping timeout: 240 seconds) |
05:24:05 | * | shpx quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
05:24:37 | * | shpx joined #nim |
05:40:33 | * | BigEpsilon joined #nim |
05:41:13 | * | sheerluck joined #nim |
05:43:51 | * | shpx quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
05:45:01 | * | shpx joined #nim |
05:53:11 | * | shpx quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
05:56:01 | * | narimiran joined #nim |
05:56:02 | FromGitter | <adrianperreault> Question: how can I export a proc that was generated by a macro? |
05:56:41 | FromGitter | <timotheecour> The `*` can be generated by the macro itself (infix/post fix i forgot) |
05:56:53 | FromGitter | <timotheecour> or, `export foo` shd work too |
06:02:08 | * | skellock quit (Ping timeout: 250 seconds) |
06:04:09 | FromGitter | <adrianperreault> Beauty! Thanks @timotheecour ! |
06:04:28 | FromGitter | <timotheecour> Np :) |
06:15:08 | * | skellock joined #nim |
06:42:00 | * | BigEpsilon quit (Ping timeout: 250 seconds) |
07:00:57 | * | krux02 joined #nim |
07:08:35 | krux02 | good morning people |
07:12:11 | * | Vladar joined #nim |
07:13:44 | skellock | good mornin |
07:14:55 | * | Vladar quit (Remote host closed the connection) |
07:15:17 | * | Vladar joined #nim |
07:30:27 | * | skellock quit (Quit: WeeChat 2.3) |
07:34:24 | * | BigEpsilon joined #nim |
07:47:11 | Araq | https://www.twitch.tv/araq4k daily scrum |
07:51:08 | * | absolutejam_phon joined #nim |
08:09:27 | * | absolutejam_phon quit (Ping timeout: 240 seconds) |
08:13:43 | * | absolutejam_phon joined #nim |
08:14:52 | * | absolutejam joined #nim |
08:15:22 | Zevv | In a tempate I'd like to add a prefix to an identifier. I can convert the identifier to a string with astToStr(), concat my prefix, but can I change this back into an identifier? |
08:18:24 | * | absolutejam_phon quit (Ping timeout: 252 seconds) |
08:20:37 | leorize | no, but there's a simpler way to do that |
08:20:58 | Zevv | tell me about it :) |
08:21:13 | leorize | see https://nim-lang.org/docs/manual.html#templates-identifier-construction |
08:21:45 | Zevv | backticks to the rescue. *so* much in the manual that I once read, and just forgot about |
08:22:32 | Zevv | reading stuff usually makes much more sense when you actually need it at the moment you read the docs. I read the whole manual twice, but some things just don't stick around |
08:22:36 | Zevv | thanks |
08:23:29 | leorize | same here, whenever I need any features I just look it up in the manual first :) |
08:23:50 | Zevv | Yeah, I checked for 'stringification', 'concatenation', but not for 'identifier construction' |
08:24:09 | Zevv | everybody loves noise on the irc channel, right? |
08:27:59 | leorize | yep, it's usually empty at this time :) |
08:35:58 | Araq | I know what to do with 'ref' for --gc:none :P |
08:38:46 | * | kapil____ joined #nim |
08:53:18 | * | lritter quit (Ping timeout: 250 seconds) |
08:57:21 | absolutejam | Is there a convention for importing modules in a folder? In python i would have a foo/ folder and then an __init__.py which contained imports to filed and allowed me to import foo |
08:57:42 | absolutejam | Also, what an god awful system |
08:57:58 | leorize | `import foo/bar`? |
08:58:22 | leorize | you just need bar.nim in foo/ |
08:58:46 | leorize | Araq: what do you have in mind? :P |
08:58:58 | absolutejam | I mean without naming each file |
08:59:26 | absolutejam | Eg. Import foo/_ and foo/_.nim contains imports to other files |
09:00:34 | absolutejam | Or would that affect the namespacing? |
09:00:44 | leorize | yes, it would |
09:00:52 | leorize | make a foo.nim |
09:01:08 | leorize | import foo, bar, foobar |
09:01:13 | leorize | export foo, bar, foobar |
09:01:27 | leorize | with that two lines it should work |
09:01:32 | absolutejam | There's an export? |
09:01:32 | * | steve1 joined #nim |
09:01:49 | absolutejam | I did search for it but couldnt find reference of it |
09:02:08 | leorize | https://nim-lang.org/docs/manual.html#modules-export-statement |
09:04:24 | absolutejam | Thanks |
09:05:44 | Araq | leorize, I won't spoil it, should write an article instead |
09:05:47 | * | steve1 quit (Ping timeout: 246 seconds) |
09:06:23 | leorize | ;) |
09:06:41 | leorize | your quirky exceptions article doesn't seem to be shared anywhere however :P |
09:08:26 | Araq | that's ok, it only was a holiday project |
09:08:57 | narimiran | leorize, Araq: i was planning on doing that today :) |
09:09:34 | narimiran | well, Araq should do it on our forum (as he's the author), and i plan on doing it on reddit and HN |
09:12:50 | Araq | hmm I thought about changing its conclusions :P |
09:14:10 | Araq | oh well, these were my conclusions when I worked on it |
09:14:47 | * | floppydh joined #nim |
09:16:03 | narimiran | i can wait :) |
09:29:29 | * | stefanos82 joined #nim |
09:31:01 | * | enow joined #nim |
09:31:35 | enow | Hi, guys! |
09:32:29 | enow | I want to create artificial keystrokes and send into the OS, from JSON based commands sent from a websocket connection |
09:33:26 | enow | I'm thinking low level so I want to do the systems stuff with C, but to do the json handling in C is just to error prone |
09:33:36 | enow | that'd make nim the language for me right? |
09:36:47 | Araq | enow, right except that you can be as low level as C with minimal effort (maybe c2nim the required declarations) |
09:42:12 | enow | Araq: I have a winapi program in C that I can use, how do I go about to interface it to nim. |
09:42:19 | enow | Araq: do I convert the code to nim |
09:42:29 | absolutejam | Is there a fast and dirty way to turn an iterator into a seq/list? |
09:42:40 | FromGitter | <timotheecour> toSeq |
09:42:48 | absolutejam | Iterators are only usable in for loops right? |
09:42:52 | absolutejam | Oh |
09:43:13 | FromGitter | <timotheecour> 1st class iters, ya, only in for loops |
09:43:25 | FromGitter | <timotheecour> 2nd class iters can be forwarded |
09:43:43 | enow | Araq: do you know if there are any readily available Winapi / xlib bindings for nim |
09:43:46 | FromGitter | <timotheecour> (Well u can also use `finished(myiter)`) |
09:44:34 | narimiran | enow: https://github.com/nim-lang/oldwinapi ? |
09:45:14 | Araq | 'nimble search windows' brings up winim among others |
09:45:16 | enow | narimiran: nice do you have any experience with it |
09:45:42 | Araq | nimble search x11 |
09:45:53 | Araq | turns up our official x11. |
09:45:55 | Araq | wrapper. |
09:46:28 | Araq | sadly, "official" doesn't mean well supported, but at least it's not dead ;-) |
09:46:29 | enow | Araq: would you know if it has support for the XTest extension of the bat? |
09:47:01 | Araq | no idea what XTest is |
09:47:12 | Araq | if it's old, we probably have wrapped it |
09:47:27 | narimiran | enow: no experience with it. btw, you can use https://nimble.directory/ for searching for packages |
09:47:31 | enow | Araq: it's used to create fake keypresses mouse presses |
09:48:18 | leorize | are you trying to create a copy of xdotool? |
09:48:40 | enow | leorize: hehe I'm trying to figure out a way to code from my couch with a playstation controller |
09:49:43 | * | itschin quit (Read error: Connection reset by peer) |
09:50:05 | enow | or sort of investigating input methods in general |
09:50:10 | leorize | found this for X11: https://nimble.directory/pkg/xdo |
09:50:59 | enow | leorize: might do the trick, t.y |
09:51:24 | leorize | and this for windows :) https://nimble.directory/pkg/autome |
09:51:51 | enow | leorize: ah so maybe I don't need the basic winapi |
09:52:22 | enow | okay so I have two options |
09:52:39 | enow | bear in mind that as this is a keyboard I can't be very wasteful with resources right |
09:53:16 | enow | A) I rip out the C interface code that I already have and create a nim interface somehow |
09:53:41 | enow | B) I test the other libraries |
09:53:59 | Araq | A) is what you will end up with |
09:54:04 | leorize | xdo requires an external program :P |
09:54:20 | enow | leorize: ah a no go |
09:54:21 | Araq | use .compile: "myfoo.c" and c2nim on the header file |
09:54:41 | enow | Araq: ah that simple and it figures it out from the header file |
09:54:56 | leorize | autome seems to be winapi-based |
09:55:07 | Araq | and only c2nim what you really need, nobody needs typedef unsigned int maAwesomeOwnIntBecauseIts1970; |
09:55:46 | enow | bare minimum right |
09:55:57 | enow | oh such good advice guys! |
09:56:23 | enow | On the other side of my project I started out prototyping with HTML5 + js + canvas stuff |
09:57:02 | enow | This I would like to port to nim so that I can compile it either for A) html5 canvas for demos B) C + low level API for local usage |
09:58:02 | enow | I know from experience that picking the wrong graphics library early in the project and then having to switch mess around with it takes forever |
09:58:19 | enow | again I have quite high requirements on window management here. |
09:58:41 | enow | For example being able to have the keyboard on top, transparent and to be able to move it is crucial |
09:59:13 | enow | miss one detail and the user experience is totally wrecked |
09:59:22 | Araq | you're in a world of fun |
09:59:31 | enow | Araq: tell me about it :D |
09:59:39 | enow | Araq: been possesed by this for years now |
10:02:24 | enow | https://www.youtube.com/watch?v=QlrzNmeh650 |
10:02:43 | enow | To give you an idea of what it looks like graphically and what kind of things I might need |
10:10:17 | Araq | I'd probably only develop the windows version and use Wine on Linux :P |
10:13:18 | enow | Araq: hm really I'm sorta doing the opposite |
10:13:41 | enow | Araq: namely running in linux and developing the windows version via wine |
10:14:11 | enow | figured that if it works in wine I'm not doing anything to exotic when it comes to support |
10:14:51 | enow | seriously though need a new SSD but broke as fuck, well well that's what you get from doing OS software full time |
10:15:47 | enow | oh syntax higligting for vim what's the best approach |
10:17:33 | Zevv | //github.com/baabelfish/nvim-nim |
10:19:04 | Zevv | "best": ymmv |
10:19:24 | Zevv | autoindenting is a bit flakey when you do stuff with colons |
10:19:33 | Zevv | things tend to go all over the place |
10:20:15 | leorize | you can write your own indent script :) |
10:20:56 | Zevv | There's always this tradeoff between accepting the annoyance of something, or having to spend the time to fix it yourself :) |
10:21:31 | leorize | I actually wrote one :P |
10:22:08 | leorize | an entire neovim plugin, that is |
10:22:21 | leorize | now I just have to figure out the "project file" logic for it :P |
10:26:11 | enow | Zevv: thank you! |
10:26:17 | enow | leorize: care to share? |
10:26:55 | leorize | it's unfinished, the other plugins currently have better syntax highlighting |
10:27:07 | leorize | I've to figure out how to properly hook up nimsuggest |
10:27:19 | enow | leorize: fair enough |
10:27:55 | enow | hm I've decided on taking my own websocket implementation and interfacing it with nim instead of the ready made libraries |
10:27:58 | enow | see what happens |
10:28:08 | enow | it's only the subset that I need |
10:28:56 | enow | but perhaps someone else might have an interest in a minimal websocket C implementation at some point |
10:35:58 | absolutejam | Im getting a random 'invalid indentation' error on a line with no issue |
10:36:11 | absolutejam | Can i dig depeer as to why tbis is happening? |
10:36:22 | absolutejam | More verbose output |
10:44:35 | FromGitter | <alehander42> make sure you use an editor where you can see whitespace/set it up to use only spaces |
10:44:51 | FromGitter | <alehander42> e.g. in sublime, if you select the line, you can see spaces/tabs |
10:45:13 | FromGitter | <timotheecour> could be previous line is missing a `=` |
10:45:28 | FromGitter | <alehander42> or `:` |
10:45:49 | absolutejam | Sedm |
10:45:50 | FromGitter | <alehander42> hm, no, the error for `:` is better |
10:45:51 | FromGitter | <timotheecour> see https://github.com/nim-lang/Nim/issues/10229 ; and yes we shd fix that issue; it shouldn’t be hard |
10:46:01 | livcd | is there anything wrong with flycheck-nimsuggest ? |
10:46:16 | livcd | My emacs chokes on opening a nim file |
10:46:29 | absolutejam | Seems to have been resolved but no idea how. Like you said, maybe a syntax error earlier |
10:56:06 | * | PMunch joined #nim |
11:19:49 | * | ng0 joined #nim |
11:19:59 | * | rockcavera joined #nim |
11:31:55 | * | dddddd_ joined #nim |
11:32:34 | * | dddddd_ is now known as dddddd |
11:50:43 | * | theelous3 joined #nim |
11:51:02 | * | theelous3 quit (Remote host closed the connection) |
12:00:27 | * | ghost64 quit (Quit: See you!) |
12:05:44 | * | ghost64 joined #nim |
12:07:47 | * | kapil____ quit (Quit: Connection closed for inactivity) |
12:18:42 | enow | hm I don't get this c2nim stuff. I manage to generate a nim file from the header but how do i link against the C file? |
12:19:00 | enow | do I just pass it along like nim c -r main.nim test.nim test.c or what |
12:19:16 | leorize | add {.compile: "file.c".} to your nim file |
12:19:29 | leorize | to the test.nim file, that is |
12:21:58 | enow | leorize: ah!! |
12:22:54 | enow | leorize: is it possible to make this happen automatically? |
12:25:37 | leorize | no, sadly |
12:25:50 | leorize | but {.compile.} can take wildcards :) |
12:26:14 | * | Cthalupa quit (Ping timeout: 268 seconds) |
12:26:55 | * | Cthalupa joined #nim |
12:28:17 | enow | leorize: hm I probably can script something together |
12:28:36 | enow | that's bindings for you I suspect |
12:28:48 | enow | do I pass along the test.nim to nim or does import take care of it |
12:35:53 | * | Ven`` joined #nim |
12:40:31 | * | Snircle joined #nim |
12:43:38 | shashlick | Check out nimgen |
12:44:15 | shashlick | Import will take care of it - just compile your top level Nim file |
12:46:19 | enow | shashlick: thx |
12:47:26 | enow | I'm feeling a bit stupid as of now why can't I make it work |
12:47:29 | enow | I do |
12:47:31 | enow | c2nim test.h |
12:47:48 | enow | add {.compile "test.c".} at the start of test.nim |
12:48:45 | enow | and when I run nim c -r nimlisten.c I still gety |
12:48:47 | enow | test.nim(4, 6) Error: implementation of 'test.close()[declared in test.nim(4, 5)]' expected |
12:55:15 | * | aguspiza joined #nim |
12:58:18 | FromGitter | <alehander42> Araq |
12:58:26 | FromGitter | <alehander42> why does `cast` produce a nimCopy ? |
12:58:28 | FromGitter | <alehander42> in js backend |
12:58:54 | FromGitter | <Clyybber> enow How does test.close in test.nim look? |
12:59:21 | FromGitter | <Clyybber> I have a feeling its missing a `{.cdecl.}` |
12:59:52 | enow | shashlick: ok nimgen was a good tip but I run into troubles wirth that one as well |
13:00:14 | enow | shashlick: first of all it refers to a path for the header file (.h) without a . and / so that gcc crashes |
13:02:07 | * | ng0 quit (Remote host closed the connection) |
13:03:08 | * | ng0 joined #nim |
13:03:36 | * | steve1 joined #nim |
13:03:37 | enow | Is it stupid for me to interface a single C file at a time, would it make more sense to generate .so / .dll files and work against those instead? |
13:04:42 | FromGitter | <Clyybber> enow I think your proc declarations are missing cdecl or importc |
13:05:40 | enow | FromGitter: oh didn't see you hm wait a second |
13:05:41 | FromGitter | enow, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/nim-lang/Nim |
13:06:30 | enow | which one do you want from c2nim or nimgen |
13:06:52 | FromGitter | <Clyybber> c2nim |
13:06:54 | enow | personally I feel nimgen would be overkill at this point, since we're only taking a subset of the API implemented |
13:06:57 | enow | sec |
13:07:00 | FromGitter | <Clyybber> Nimgen uses c2nim internally AKAIK |
13:07:25 | * | aguspiza quit (Ping timeout: 246 seconds) |
13:08:15 | * | steve1 quit (Ping timeout: 252 seconds) |
13:09:05 | enow | {.compile: "test.c".} |
13:09:05 | enow | proc init*(a1: cint) |
13:09:05 | enow | proc close*() |
13:10:04 | enow | init() and close is basically hello world functions |
13:10:12 | enow | using printf might that be the issue? |
13:10:27 | FromGitter | <Clyybber> Hmm, is that thw whole test.nim file? |
13:10:46 | enow | jup |
13:10:54 | FromGitter | <Clyybber> There are no {.cdecl.} or importc statements there |
13:11:04 | enow | it's what c2nim gave me |
13:11:13 | FromGitter | <Clyybber> Huh, thats weird |
13:11:17 | enow | the header file is just two functions |
13:11:20 | FromGitter | <Clyybber> How does test.c look? |
13:11:24 | FromGitter | <Clyybber> Ah ok |
13:11:40 | enow | I just started out with this |
13:12:09 | FromGitter | <Clyybber> Try changing `proc close*()` to `proc close*() {.cdecl.}` and see if it works |
13:12:28 | enow | hm maybe I should have the header |
13:13:29 | enow | nope |
13:13:37 | FromGitter | <Clyybber> Sry forgot something `proc close*() {.cdecl, importc.}` |
13:13:43 | FromGitter | <Clyybber> this is how it should work |
13:14:26 | enow | found it ! |
13:14:32 | * | seni joined #nim |
13:14:34 | enow | proc close*() {.stdcall, importc: "close" } |
13:14:37 | enow | did the trick |
13:14:58 | FromGitter | <Clyybber> Ah yes cdecl is only needed if you want to use it as a callback somehow |
13:15:21 | FromGitter | <Clyybber> @enow Does it not work without stdcall? |
13:16:27 | enow | yeah I need stdcall |
13:16:31 | enow | and header |
13:16:36 | enow | which leads me to the next problem |
13:18:31 | enow | how to tell it where the test.h file is |
13:18:32 | leorize | enow: you can try {.noconv.} if the header doesn't specify a specific convention |
13:21:03 | enow | how do I send -I options to gcc? |
13:21:55 | enow | hm I |
13:23:37 | * | shpx joined #nim |
13:23:53 | FromGitter | <Clyybber> --passL |
13:24:42 | shashlick | Yes for one file nimgen is excessive but good to know for wrapper folk |
13:24:56 | shashlick | In fact nimterop merges nimgen and c2nim |
13:25:12 | enow | yeah I'd use it for sure had I needed to bind something bigger |
13:25:15 | leorize | enow: "--passC:" |
13:25:22 | enow | hm I feel that I'm quite closer |
13:25:31 | leorize | there's also the {.passC.} pragma |
13:26:00 | enow | I think the issue is that when the test.nim file is compiled it doesn't now where the C .h header file is |
13:28:13 | enow | just to be sure the test.c code isn't translated into nim code by doing this |
13:31:22 | * | Cthalupa quit (Ping timeout: 258 seconds) |
13:31:45 | * | Cthalupa joined #nim |
13:38:39 | * | Vladar quit (Remote host closed the connection) |
13:41:32 | shashlick | No it is compiled in by gcc |
13:42:00 | shashlick | You need to provide a relative path |
13:44:18 | leorize | enow: put {.passC: "-Isomething".} to your nim file |
13:44:37 | leorize | something here is obviously the include path :p |
13:45:10 | enow | leorize: yes but I tried adding that one with header |
13:45:31 | Araq | don't use -I and don't use .header, use .compile |
13:46:00 | Araq | proc foo() {.cdecl, importc: "foo".} is the best way to do it |
13:46:27 | enow | Araq: aha I'll try that out! |
13:46:29 | Araq | .header crap will never work with the LLVM backend |
13:49:26 | enow | {.compile: "test.c".} |
13:49:26 | enow | proc init*(port: cint) {.cdecl, importc: "init".} |
13:49:36 | enow | so this is where I am at |
13:52:17 | enow | ha |
13:52:19 | enow | I made it!! |
13:53:16 | enow | I did a manual gcc -c on test.c to provide for a test.o file, then I changed the .compile directive in test.nim to {.link: "/absolute/path/test.o"} |
13:55:53 | enow | And I have a bugreport I think !?! |
13:55:53 | leorize | you should use .compile actually :P |
13:55:58 | enow | leorize: now I do |
13:56:04 | leorize | bugreport? |
13:56:14 | enow | but it only works after I change the name of the test.nim to testi.nim |
13:56:42 | enow | if the test.nim file has the same name as the test.c file the gcc command argument contains two test.c.o |
13:56:52 | leorize | that deserves a bug report then |
13:57:11 | enow | leorize: where and how? |
13:57:22 | leorize | github.com/nim-lang/Nim/issues |
13:57:45 | * | vlad1777d joined #nim |
13:57:54 | leorize | please provide a reproducible sample as well |
13:58:33 | enow | leorize: yeah I'll put it on github with one working commit and one broken |
13:58:35 | enow | seems ok? |
13:58:54 | enow | what is the {.compile } thingy refereed to as in nim lingo? |
13:59:06 | leorize | "compile" pragma |
13:59:21 | * | Cthalupa quit (Ping timeout: 258 seconds) |
14:00:25 | shashlick | You can generate a unique o file with compile |
14:00:49 | enow | shashlick: how? |
14:01:12 | shashlick | https://github.com/genotrance/nimgen/blob/master/src/nimgen/gencore.nim |
14:01:17 | shashlick | See the compile proc |
14:01:42 | * | Ven`` quit (Ping timeout: 252 seconds) |
14:02:05 | * | Cthalupa joined #nim |
14:03:09 | shashlick | An issue will be nice though - if Nim knows the o file will overwrite then it should adjust automatically |
14:03:43 | shashlick | Araq can decide if it is warranted or if this compile syntax is sufficient |
14:04:00 | shashlick | At least a warning is worthwhile |
14:04:05 | enow | shashlick: it's one it's way |
14:05:51 | Araq | seems to me you should have a .nimble file |
14:06:06 | Araq | but sure, we can fix it, cannot be hard... |
14:06:45 | enow | Araq: yes! I think I saw someone else with the same problem |
14:06:54 | enow | enow: ah yeah a nimble file is on it's way |
14:10:09 | enow | Araq: https://github.com/richard-jansson/nimlisten/commit/cc12c5c48dc79f50bcf444b2370efe8c89501e12 |
14:10:14 | enow | Araq: the broken code |
14:10:44 | Araq | stop poking me |
14:12:12 | shashlick | Alternative is to not use the same name |
14:12:32 | shashlick | But that's harder when working on wrapping C libraries written by others |
14:12:32 | enow | https://github.com/nim-lang/Nim/issues/10299 |
14:13:30 | shashlick | It also breaks when you have the same file name but in different directories since nimcache is a flat directory |
14:16:21 | enow | woops sorry for interrupting you I'm sure you're busy! |
14:16:27 | enow | s |
14:17:58 | enow | might be https://github.com/nim-lang/Nim/issues/3072 a duplicate |
14:18:00 | enow | not sure |
14:18:19 | enow | thought it be helpful to have it for the record |
14:18:53 | * | Ven`` joined #nim |
14:19:41 | FromGitter | <alehander42> enow: thanks: I agree this is not perfect, but I think the workaround to use different filenames might be ok at least to unblock you on this |
14:21:16 | * | Vladar joined #nim |
14:21:49 | enow | ah sure for me it's not a problem |
14:21:54 | shashlick | Looks like the same issue to me |
14:22:40 | enow | you could argue that it's a conceptual issue, as the nim file is compiled to a c file as well it sorta makes sense when you think of it |
14:23:22 | enow | instead of thinking of the test.nim as a meta header file, if my wording makes any sense to you. It should be thought of as an equivalent to the C file |
14:23:52 | enow | so it's nitpicking really |
14:27:07 | absolutejam | Can i use typeinfo to access object/enum fields programatically, eg with a string value? |
14:29:18 | shashlick | https://nim-lang.org/docs/strutils.html#parseEnum%2Cstring |
14:31:07 | shashlick | https://forum.nim-lang.org/t/2017 helps with objects |
14:33:08 | FromGitter | <alehander42> absolutejam, doesnt `[]` with Any arg work |
14:35:05 | * | shpx quit (Quit: Textual IRC Client: www.textualapp.com) |
14:35:55 | FromGitter | <alehander42> e.g. if A has int field; var a = A(); echo a.toAny["a"].getInt |
14:39:20 | absolutejam | Oooh |
14:46:33 | * | nsf quit (Quit: WeeChat 2.3) |
14:47:09 | absolutejam | Ill play with that ty alehandler |
14:47:17 | absolutejam | And ty shashlik |
14:55:30 | * | steve1 joined #nim |
14:55:32 | FromGitter | <zacharycarter> every time I look at gitter these days, I'm seeing a new name |
14:55:43 | FromGitter | <zacharycarter> good stuff |
14:55:50 | shashlick | alehander42: do we already have a lib that implements the python dict style data structure? |
14:55:59 | shashlick | looks like that can be offered with Any |
14:56:13 | shashlick | or seq even |
14:56:50 | shashlick | was thinking that will be useful to transition folks who don't care about performance as much but want to do Python style stuff |
14:57:43 | leorize | it's called json :p |
14:58:21 | * | steve1 is now known as skellock |
15:03:27 | FromGitter | <alehander42> shashlick: yeah, it's better to let them use jsonnodes or similar variant-based "dynamic" value |
15:03:28 | shashlick | sounds fair |
15:03:33 | FromGitter | <alehander42> Any is very unsafe |
15:03:39 | FromGitter | <alehander42> it shouldn't be used in normal code |
15:04:16 | FromGitter | <alehander42> and it's good for them to embrace variant objects/more static guarantees sooner or later after all |
15:04:20 | FromGitter | <alehander42> imo |
15:04:21 | shashlick | just not the first thing that would come to a Python guy's mind but makes sense |
15:04:42 | FromGitter | <alehander42> well, after all each language has its own patterns |
15:04:56 | shashlick | i agree - it's lazy and quick though so I appreciate it for quick and dirty work |
15:05:20 | FromGitter | <alehander42> maybe it would be a good idea to add more examples / gotchas / patterns to a Nim for Python programmers tutorial |
15:05:27 | shashlick | i agree |
15:07:52 | livcd | anyone else has an issue with flycheck-nimsuggest ? |
15:09:06 | shashlick | livcd: most folks using emacs disable nimsuggest since it doesn't work |
15:09:08 | FromGitter | <alehander42> hm, I can directly change the wiki |
15:09:17 | FromGitter | <alehander42> it would be good to have some kind of review |
15:10:24 | shashlick | sure - i can check once you are done |
15:12:36 | FromGitter | <alehander42> @narimiran, do you have any plans for the nim for <lang> programmers tutorials? i'd add some stuff to the python one(i can also do a ruby one), do we want them to remain in the wiki, or to be linked in the tutorial? |
15:12:47 | FromGitter | <alehander42> hm, they're linked in `learn` |
15:13:48 | narimiran | @alehander42 at first i would like (if somebody else can ;)) update and enrich the existing ...C and ...python versions |
15:14:13 | FromGitter | <alehander42> yes, that's what I meant about the python version |
15:14:24 | narimiran | after that, if there's an interested to make similar stuff for other languages — be my guest, i would gladly share that on the `learn` page |
15:15:04 | narimiran | or more broadly: wiki needs some love |
15:15:37 | narimiran | every contribution which makes wiki better, more useful, updated, etc. is very welcome |
15:15:40 | FromGitter | <alehander42> well, a ruby one would be relatively similar to the python one, but still very useful |
15:16:23 | FromGitter | <alehander42> i think even a `go` one would make sense, as nim is an ok fit for some stuff that people use it for |
15:16:32 | narimiran | go for it :) |
15:16:35 | narimiran | (pun intended) |
15:16:43 | FromGitter | <alehander42> haha |
15:17:08 | narimiran | 2019 is the year of nim documentation |
15:17:15 | FromGitter | <alehander42> i hope to see more nim-related talks/stuff in python/ruby confs in the next years |
15:17:26 | FromGitter | <alehander42> elixir , rust , crystal have those |
15:17:39 | FromGitter | <alehander42> and it's an easy way to get some mindshare |
15:18:09 | narimiran | i had nice success with https://narimiran.github.io/2018/05/10/python-numpy-nim.html on r/python |
15:18:44 | narimiran | and stuff like this (in various fields) should be easy to do, and we should encourage it |
15:19:19 | narimiran | if you look at HN, every few day there is a new (and popular) post "how i rewrote X in Rust" |
15:20:02 | narimiran | or "show HN: XYZ, new library for Foo, written completely in Rust" |
15:21:02 | FromGitter | <alehander42> yes, libs/rewrites result in maybe the biggest source of interest |
15:21:35 | FromGitter | <alehander42> language changes/news dont happen so often, and `project in X` is more relevant to most readers |
15:25:47 | narimiran | but back to the original question: |
15:26:08 | narimiran | * should there be "nim for rust/go/ruby/etc. programmers"? yes |
15:26:25 | narimiran | * should our wiki be generally updated and populated? yes |
15:30:44 | FromGitter | <alehander42> i dont like wiki-s too much, people don't generally update it when something changes |
15:31:11 | FromGitter | <alehander42> but its useful to have one i guess |
15:35:22 | * | Ven`` quit (Ping timeout: 272 seconds) |
15:39:17 | * | absolutejam quit (Remote host closed the connection) |
15:41:40 | * | absolutejam joined #nim |
15:47:45 | * | stefanos82 quit (Ping timeout: 252 seconds) |
15:56:09 | * | absolutejam_phon joined #nim |
15:56:09 | * | absolutejam quit (Read error: Connection reset by peer) |
16:00:08 | * | absolutejam_phon quit (Read error: Connection reset by peer) |
16:00:25 | * | absolutejam_phon joined #nim |
16:01:57 | FromGitter | <mratsim> ArchWiki is well maintained |
16:01:57 | * | absolutejam_phon quit (Read error: Connection reset by peer) |
16:02:13 | FromGitter | <mratsim> but you need to kickstart it |
16:11:48 | * | Vladar quit (Remote host closed the connection) |
16:12:48 | * | absolutejam_phon joined #nim |
16:29:13 | * | BigEpsilon quit (Ping timeout: 245 seconds) |
16:32:16 | enow | hm perhaps not the best way of starting to know nim, but I want to make callback functions to nim functions from C code, is this doable in any sane way? |
16:37:15 | * | absolutejam_phon quit (Ping timeout: 252 seconds) |
16:38:24 | leorize | the typical way is to have a {.cdecl.} proc in Nim that calls your nim proc with the necessary parameters |
16:38:26 | FromGitter | <alehander42> nim functions do compile to c functions after all |
16:42:20 | FromDiscord_ | <dias.nurbergen> Best Casino Online > http://gambldiscord.bestoffersx.com |
16:43:44 | enow | leorize: aha so I inline C code into nim? |
16:44:29 | leorize | no, you write nim code, just that it'd be compatible w C calling convention |
16:45:12 | leorize | proc callback(data: ptr Data) {.cdecl.} = myProc(data.arg1, data.arg2) |
16:45:21 | leorize | ^ something like that |
16:46:05 | enow | leorize: pweh sounds much more reasonable |
16:52:51 | * | nsf joined #nim |
16:54:52 | * | BigEpsilon joined #nim |
16:57:35 | narimiran | nim trivia: we have just passed 14,500 commits |
17:02:21 | * | Trustable joined #nim |
17:02:38 | skellock | \o/ |
17:08:48 | * | absolutejam_phon joined #nim |
17:09:08 | * | aguspiza joined #nim |
17:10:42 | enow | leorize: so what happens if the callback is called from a thread |
17:12:58 | enow | garbage collectors is not my strongest suite to be honest but I have a feeling that something might get messed up |
17:14:26 | Araq | the callback NEEDS to be annotated with .gcsafe |
17:14:46 | Araq | and then it's pretty much ok, I think. |
17:14:48 | leorize | how about calling setupForeignGcThread() at the start of the callback then tearDownForeignThreadGc() at the end :P |
17:15:06 | * | zyklon quit (Ping timeout: 250 seconds) |
17:15:40 | enow | aha I expected to need to use setupForeign and tearDownForeign but perhaps .gcsafe is enough |
17:16:35 | enow | but perhaps I should just play it safe and do setupForeinGcThread |
17:17:38 | enow | hm I got a hint from nim somehow <proc (){.cdecl, gcsafe, locks: 0.}> that this would be the expected format |
17:17:51 | enow | so this is basically how I define the callback function I suppose |
17:18:01 | enow | what about locks is it useful for anything? |
17:23:24 | shashlick | dom96: why does choosenim still load 0.19.0 for stable |
17:32:16 | * | floppydh quit (Quit: WeeChat 2.3) |
17:35:03 | FromGitter | <Clyybber> @nc-x Hi, are you here rn? |
17:36:50 | leorize | enow: I think it's about how many locks does your proc holds |
17:36:57 | leorize | you shouldn't have to care about it |
17:37:14 | leorize | just {.cdecl, gcsafe.} should be fine |
17:44:08 | * | absolutejam_phon quit (Ping timeout: 246 seconds) |
17:44:44 | * | Trustable quit (Remote host closed the connection) |
17:47:19 | * | absolutejam_phon joined #nim |
17:47:51 | enow | neat I hate threads |
17:48:02 | enow | which is why I am a bit interested in channels |
17:48:09 | enow | should I go for that or a more traditional approach |
18:00:48 | shashlick | is unxz available by default on osx? |
18:08:52 | * | absolutejam_phon quit (Read error: Connection reset by peer) |
18:09:42 | * | BigEpsilon quit (Ping timeout: 250 seconds) |
18:15:25 | * | salewski joined #nim |
18:17:37 | salewski | Clyybber, Araq, so does this mean that we should put variables as global inside the macros now? like |
18:17:41 | salewski | macro idleAdd*(): untyped = |
18:17:53 | salewski | var IdleID {.global.} : int |
18:18:55 | Araq | no |
18:19:01 | Araq | you should have used |
18:19:14 | Araq | var idleId {.compileTime.}: int |
18:19:18 | Araq | to begin with, afaict |
18:21:28 | salewski | OK, then I will try that. But my current impression is that global pragma still works, |
18:21:51 | salewski | and 14 days ago it was working fine without compile time pragma as well. |
18:22:05 | * | BigEpsilon joined #nim |
18:23:18 | FromGitter | <Clyybber> @Araq Is it supposed to work without var being a compile time var? |
18:23:59 | FromGitter | <Clyybber> Is inc(IdleID) evaluated at runtime then, or is IdleID implicitly made a compile time value? |
18:24:24 | salewski | Araq you seems to be rigth, global var with compileTime pragma seems to work and That makes sense :-) |
18:25:20 | Araq | it never was supposed to work afaict, macros access .compileTime vars and consts, nothing else |
18:25:37 | salewski | OK thanks, bye. |
18:25:49 | Araq | and only some patterns work with incremental compilation, check out my RFC :P |
18:25:59 | Araq | (yours is fine) |
18:26:34 | * | salewski quit (Quit: WeeChat 2.3) |
18:37:07 | * | BigEpsilon quit (Ping timeout: 246 seconds) |
18:59:04 | FromGitter | <iffy> Can I make a proc accept nil as an argument? I'm taking a user-supplied value (from JSON) which could be a string, int, float or null and I want to call `myProc` on it. I have `myProc(x:string)`, `myProc(x:int)` etc... but how do I make a `myProc(x:nil)`? |
18:59:32 | FromGitter | <iffy> JSON input is just an example -- it might not always be JSON |
19:00:20 | FromGitter | <Clyybber> does `myProc(x: int | nil)` work? |
19:01:27 | FromGitter | <iffy> @Clyybber no `Error: type expected` |
19:01:44 | FromGitter | <iffy> I'm on 0.19.1 if that matters |
19:01:57 | FromGitter | <Clyybber> and `myProc(x: int | type(nil))` ? |
19:02:15 | FromGitter | <Clyybber> @iffy Don't think it matters |
19:03:41 | FromGitter | <iffy> that didn't work (probably the body of my proc in that case) but `myProc(x: type(nil))` seems to work |
19:03:42 | FromGitter | <iffy> Thank you! |
19:04:19 | FromGitter | <iffy> yes `type(nil)` works! |
19:04:25 | FromGitter | <Clyybber> huh, I wonder if you will still be able to pass an int to it then... |
19:05:01 | FromGitter | <Clyybber> maybe you should rather use `Any`, but don't quote me on that since thats kind of unsafe |
19:07:49 | * | sheerluck quit (Quit: Leaving) |
19:08:37 | Araq | JSOn has JNull |
19:08:57 | FromGitter | <iffy> K, this works great: https://gist.github.com/iffy/762c6ab90e73702c48192286316f2483 |
19:11:03 | Araq | hmm yeah, we allowed type(nil) for this reason |
19:11:16 | Araq | note that this is new with 0.19, I think |
19:12:23 | FromGitter | <iffy> Maybe I should explain what I'm actually doing. The stdlib sqlite library doesn't let you bind named parameters, so I've written my own stuff to allow for named parameters using SQLite's binding functions. But the binding function to call depends on the parameter type. I made a Param type which I use to decide how to bind. Having done all that I can then do: |
19:12:57 | FromGitter | <iffy> `db.fetchAll(sql"SELECT $first, $second, $third", @[P("first"), P(23), P(nil)])` |
19:13:29 | FromGitter | <iffy> Before this `type(nil)` help, I had a special `Pnull` const. |
19:14:19 | FromGitter | <iffy> I imagine I can probably even use an openArray to shorten that to `..., "first", 23, nil)` eh? |
19:15:20 | * | kungtotte joined #nim |
19:16:00 | FromGitter | <iffy> err... varargs, not openArray |
19:25:19 | * | dom96_w joined #nim |
19:25:36 | FromGitter | <zetashift> @zacharycarter any idea how to make the newEntity nicer: https://hastebin.com/ufedopewux.cs |
19:30:56 | * | absolutejam_phon joined #nim |
19:33:14 | FromGitter | <zacharycarter> looks good so far to me @zetashift |
19:33:20 | Araq | iffy, bah please improve Ormin instead (selfish, I know) |
19:33:32 | FromGitter | <iffy> What's Ormin? |
19:34:01 | FromGitter | <iffy> Oh, I see |
19:34:54 | FromGitter | <iffy> Araq: You'd prefer patches to Ormin than the stdlib sqlite? |
19:35:22 | Araq | well ideally both, but stdlib is more important |
19:35:33 | Araq | didn't understand that you intend to patch the stdlib |
19:35:36 | FromGitter | <zetashift> Well I'm actually getting an error: `entity.nim(39, 20) Error: attempting to call undeclared routine: 'fighter=' ` |
19:35:52 | FromGitter | <iffy> Araq: I'm building up confidence to attempt it once I'm sure the interface I've made works |
19:38:32 | FromGitter | <iffy> Wow, Ormin looks neat |
19:40:23 | * | absolutejam_phon quit (Read error: Connection reset by peer) |
19:40:43 | * | absolutejam_phon joined #nim |
19:40:59 | Araq | Ormin is in search for a maintainer |
19:41:56 | FromGitter | <iffy> I'm not sure I've got that much in me :) |
19:41:59 | shashlick | i'm looking for sizeof(time_t) at runtime for nimterop - need to translate correctly |
19:42:09 | shashlick | there's CTime in times package but it is not exposedf |
19:42:30 | FromGitter | <zacharycarter> @zetashift - I think you'll need to coerce it into a `Player` object |
19:42:55 | * | aguspiza quit (Ping timeout: 246 seconds) |
19:42:56 | FromGitter | <zacharycarter> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c3ce640cb47ec300042d2d2] |
19:43:32 | shashlick | further, on my linux box, sizeof(time_t) comes to 8 bytes but its defined as clong in https://github.com/nim-lang/Nim/blob/master/lib/posix/posix_linux_amd64.nim#L41 |
19:50:45 | * | NimBot joined #nim |
19:56:24 | FromGitter | <zetashift> @zacharycarter that fixed that error but now I'm getting: ` entity.nim(38, 11) Error: type mismatch: got <Orc> but expected 'Player = ref Player:ObjectType' `yikes |
19:59:46 | rayman22201 | @shashlick why wouldn't it be 8 bytes? it's on a 64bit machine. |
20:00:28 | shashlick | ya i'm saying it is wrong in the nim file - defined to clong = 4 |
20:00:45 | * | nsf quit (Quit: WeeChat 2.3) |
20:01:16 | Araq | clong is 8 bytes |
20:03:22 | shashlick | ok then i'm getting mixed up in nim vs c |
20:03:42 | shashlick | so can we expose CTime in times.nim |
20:04:49 | * | aguspiza joined #nim |
20:07:57 | * | gmpreussner quit (Quit: kthxbye) |
20:08:09 | Araq | we can but why? |
20:08:28 | shashlick | well I need it when wrapping |
20:08:39 | shashlick | if a C lib has time_t, i can just rename it to CTime |
20:13:19 | Araq | meh ok, better than rolling your own I guess |
20:13:26 | Araq | time_t is a mess |
20:14:11 | shashlick | ok thanks |
20:14:26 | shashlick | have just pushed a csize fix |
20:16:42 | * | gmpreussner joined #nim |
20:19:16 | enow | My god it works! My first nim program |
20:37:32 | Zevv | congrats :) |
20:37:40 | FromGitter | <timotheecour> urgent: https://github.com/nim-lang/Nim/issues/10302 the build broke for all PR's |
20:38:41 | * | ng0 quit (Quit: Alexa, when is the end of world?) |
20:39:23 | * | dom96_w quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
20:40:26 | krux02 | timotheecour: tried to verify that |
20:40:38 | krux02 | can't reproduce it localld |
20:49:08 | krux02 | timotheecour: what I do see is that current test suit is spammed with lots of messages like: (msg: "execCmdEx2 failed", command: "tests/stdlib/tunittestexceptiontype", options: {poStdErrToStdOut}) |
20:49:20 | krux02 | and the line of code creating this spam is from your code. |
20:49:22 | FromDiscord_ | <moerm> Hello |
20:50:00 | FromDiscord_ | <j$> sup |
20:50:01 | * | sillibird joined #nim |
20:50:42 | FromDiscord_ | <j$> yo so is anyone able to help with with this macro |
20:50:54 | FromDiscord_ | <j$> https://pastebin.com/raw/6D2tHRkg |
20:51:11 | sillibird | How should I deal with a type that can be different things? Like the equivelant of a Golang interface? |
20:51:58 | FromGitter | <Varriount> j$: I don't quite see what the problem is. Could you explain it a bit more/ |
20:52:47 | FromGitter | <Varriount> sillibird: Either use a ref+inheritance+multimethods, a structure containing procedural types (see the streams module) or object variants. |
20:52:55 | FromDiscord_ | <j$> so if I pass in an enum Id like to access its ordinal value |
20:54:11 | krux02 | sillibird: if ord(c) <= ord(yellow) |
20:55:12 | krux02 | @timotheecour are you there? |
20:56:33 | * | Tyresc joined #nim |
20:56:40 | * | narimiran quit (Quit: Leaving) |
20:56:55 | FromDiscord_ | <j$> the parameter of macros are of NimNode type so I cant just use them as ords as I'd like |
20:58:15 | FromGitter | <timotheecour> @krux02 just got back but have to go somewhere very soon; ya the spam is from me, but shd be unrelated to the CI failure; I’ll look into improving that spam (or disabling it) later, but the urgent stuff is the CI failure |
20:58:52 | FromDiscord_ | <j$> @sillibird https://nim-lang.org/docs/tut2.html#generics |
20:58:59 | FromDiscord_ | <j$> is this what you mean? |
20:59:48 | sillibird | So basically, Im writing a wrapper for a API, and I have a type that gets unmarshalled from an endpoint. One of the values will either end up being nil, or another type |
20:59:50 | FromGitter | <timotheecour> if all PR’s were merged after green, the only thing i can think of is if 2 PRs were merged consecutively wo CI running in between; this has happened recently |
21:01:19 | FromDiscord_ | <j$> @sillibird sounds like generics to me |
21:03:32 | FromDiscord_ | <j$> @krux02 so any idea? |
21:04:17 | sillibird | How does the generic param work, in the example its [T] |
21:04:32 | * | enigmeta_ joined #nim |
21:05:03 | * | noonien_ joined #nim |
21:10:37 | FromDiscord_ | <j$> T is the type and any occurrence of T is that type, it can be any letter |
21:10:41 | FromDiscord_ | <j$> not sure on the case |
21:11:07 | FromDiscord_ | <j$> you can have multiple separated by a comma |
21:11:16 | FromDiscord_ | <j$> [A, B] |
21:11:38 | * | noonien quit (Ping timeout: 268 seconds) |
21:11:39 | * | Shoozza quit (Ping timeout: 268 seconds) |
21:11:41 | * | toofly[m] quit (Ping timeout: 268 seconds) |
21:11:41 | * | zielmicha[m] quit (Ping timeout: 268 seconds) |
21:11:41 | * | spymasterd[m] quit (Ping timeout: 268 seconds) |
21:11:43 | * | enigmeta quit (Ping timeout: 268 seconds) |
21:11:43 | * | vqrs quit (Ping timeout: 268 seconds) |
21:11:44 | * | TheKing[m] quit (Ping timeout: 268 seconds) |
21:11:45 | * | noonien_ is now known as noonien |
21:11:45 | * | enigmeta_ is now known as enigmeta |
21:11:45 | * | Shoozza_ joined #nim |
21:11:46 | FromDiscord_ | <j$> that's p much all I know |
21:11:56 | * | vqrs_ joined #nim |
21:12:41 | * | spymasterd[m] joined #nim |
21:12:44 | * | zielmicha[m] joined #nim |
21:12:49 | * | toofly[m] joined #nim |
21:13:39 | * | TheKing[m] joined #nim |
21:15:37 | Araq | krux02: the build is green now, right? |
21:16:38 | FromGitter | <alehander42> sillibird: if it's either nil or a value, you can just use a nilable type or an Option |
21:17:40 | FromDiscord_ | <j$> yo alehander42 you know how to macro? |
21:17:55 | FromGitter | <alehander42> if you're looking for something more general, you can use a variant object(similar to algebraic types) or e.g. OOP with inheritance & methods |
21:18:54 | FromGitter | <alehander42> `j$` how do you want to use color_test |
21:19:30 | FromGitter | <alehander42> @krux02 helped you with intVal: intVal is only for json, for enums you can use `ord` or `int` |
21:19:35 | FromGitter | <alehander42> e.g. `Color.int` |
21:19:49 | FromGitter | <alehander42> `c.int` * |
21:19:50 | FromGitter | <alehander42> sorry |
21:20:10 | Araq | comparable to Go's empty interface would be 'system.RootRef' |
21:20:23 | FromGitter | <alehander42> also, i guess you want the return type to be `untyped` |
21:20:35 | FromGitter | <alehander42> not really sure when does one actually need `typed` return |
21:24:34 | krux02 | Araq: according to my local tests, the build is green, yes |
21:25:35 | FromGitter | <timotheecour> can we re-trigger the build for devel? it’s green currently but somehow all/most recent PRs fail w similar/same error |
21:26:16 | * | aguspiza quit (Ping timeout: 244 seconds) |
21:27:08 | FromDiscord_ | <moerm> hello Araq |
21:28:49 | krux02 | @timotheecour: can you create a PR that removes the spam in execCmdEx2? |
21:42:21 | Araq | timetheecour: rebase the PRs |
21:42:37 | Araq | moerm: hi |
21:47:29 | * | sillibird quit (Ping timeout: 256 seconds) |
21:54:16 | FromGitter | <iffy> I'm getting sporadic `SIGSEGV: Illegal storage access. (Attempt to read from nil?)` errors in my (way-too-complicated) program. This is an electron app -> node module -> c code produced by nim -> sqlite3 C library. If I see that SIGSEGV, can I be sure that Nim is the one that generated the error? |
21:55:44 | Araq | never but -d:useSysAssert -d:useGcAssert helps in debugging |
21:56:19 | Zevv | "never", hehe |
21:56:40 | FromGitter | <iffy> but Nim is the one that printed out the message and quit, right? |
21:56:47 | Araq | sure |
21:56:50 | FromGitter | <iffy> I'll try those flags |
21:57:23 | FromGitter | <alehander42> @iffy how do you communicate between electron and the c backend-based code? they are running in different processses, it should be possible to at least |
21:57:24 | FromGitter | <alehander42> hm, nvm |
21:57:27 | FromGitter | <alehander42> :D |
21:57:56 | FromGitter | <iffy> @alehander42 I compile the Cpp code into a Node Native Add-on |
21:58:00 | FromGitter | <alehander42> you can also run it under a debugger, if it's easily reproducable |
21:58:06 | FromGitter | <alehander42> ahh, i haven't done that |
21:58:30 | FromGitter | <iffy> Any good recommendation for a debugger for macos? Haven't been this low level since university :) |
21:59:13 | FromGitter | <iffy> bbl |
22:00:29 | FromGitter | <alehander42> no idea, i think people use lldb under macos? :D gdb-based stuff works well on linux, but it seems it has problems on mac |
22:01:15 | krux02 | iffy: when I wrote the gdb integration I din't know that macos broke compatibility with gdb, and gdb seems to be the default debugger on Linux so I went for that. |
22:02:14 | krux02 | Unfortunately, you need a new gdb version for that integration, and afaik a modern version of basically anything open source linux related is not available on macos, so you should install Linux on a VM |
22:02:35 | krux02 | sorry that for the moment there is no better solution. |
22:03:25 | * | lritter joined #nim |
22:11:42 | FromGitter | <iffy> krux02: no apology necessary -- I can get a Linux box |
22:12:17 | krux02 | maybe you can get gdb running as well, but timothee has problems with it |
22:17:56 | FromDiscord_ | <j$> @alehander42 the problem is that parameters of macros are nimnodes not enums |
22:18:11 | FromDiscord_ | <j$> I found a work around |
22:18:21 | FromGitter | <alehander42> you can accept `static[Color]` |
22:18:35 | FromGitter | <alehander42> this way ypu should get the enum value |
22:19:15 | FromGitter | <iffy> Hrm... so where can I read more about useGcAssert and useSysAssert? I'm getting this: ```[GCASSERT] decRef ⏎ No stack traceback available``` |
22:19:33 | FromDiscord_ | <j$> Color being the parameter? |
22:19:49 | FromGitter | <alehander42> color: static[Color] |
22:20:03 | FromGitter | <alehander42> ye |
22:20:56 | * | enow quit (Read error: Connection reset by peer) |
22:21:15 | FromDiscord_ | <j$> okay so this works for inside the macro but now I cant pass in a value |
22:21:55 | FromGitter | <alehander42> ah, so you need to pass variable values |
22:22:24 | FromDiscord_ | <j$> yessir |
22:22:28 | FromGitter | <alehander42> then you just need to do that in the resulting code |
22:22:38 | FromDiscord_ | <j$> let color = parseEnum[Color]($nnc.getImpl) |
22:22:41 | FromGitter | <alehander42> e.g. result = quote: ⏎ if `color`.int .. : ⏎ .. |
22:24:05 | * | Jesin quit (Quit: Leaving) |
22:24:08 | FromDiscord_ | <j$> I dont want to generate the if statement I want to generate code based on the condition |
22:25:02 | FromGitter | <alehander42> well, if its a runtime value |
22:25:10 | FromGitter | <alehander42> you have to generate a runtime condition |
22:25:16 | FromDiscord_ | <j$> ah I see |
22:25:19 | FromDiscord_ | <j$> im dumb |
22:25:24 | FromGitter | <alehander42> there is no way to know it beforehand |
22:25:35 | FromGitter | <alehander42> no , this happens a lot, its hard to get acustomed in the beginning |
22:26:08 | * | dom96_w joined #nim |
22:27:55 | FromGitter | <iffy> How should I return a cstring to C code from a nim proc? I think I'm running into GC problems because I'm returning strings. Although I don't know why SIGSEGV would be sporadic rather than deterministic in this case... |
22:29:56 | * | shpx joined #nim |
22:31:51 | AlexMax | krux02: brew has gcc and friends |
22:32:06 | AlexMax | Can't speak as to how updated they are or how friendly they are with clang-compiled binaries |
22:35:51 | dom96_w | iffy: you need to use gc_ref(yourString) to ensure the GC doesn't deallocate it |
22:36:21 | FromGitter | <iffy> dom96_w: and then how do I later deallocate it? |
22:36:27 | dom96_w | gc_unref :) |
22:37:11 | FromGitter | <iffy> :) I'll have to think a little about what's doing what, I guess |
22:39:02 | krux02 | AlexMax: According to timothee brew has problems with gdb with newest version of macos |
22:40:13 | FromGitter | <iffy> hrm... looks like GC_ref works for strings but not cstrings: https://nim-lang.org/docs/system.html#GC_ref%2Cref.T |
22:40:34 | krux02 | cstring isn't a ref |
22:40:50 | krux02 | cstring is basically just a pointer |
22:40:56 | FromGitter | <iffy> oh |
22:41:02 | FromGitter | <iffy> I thought pointer == ref |
22:41:33 | dom96_w | how did you get the cstring? |
22:41:56 | FromGitter | <iffy> result = $ %* { "some": "json" } |
22:42:03 | FromGitter | <iffy> GC_ref(result) |
22:42:18 | FromGitter | <iffy> but the return type of the proc is cstring |
22:42:49 | dom96_w | okay, so do: var res = ...; gc_ref(res); result = addr res[0] |
22:43:11 | dom96_w | (result = res might work too) |
22:45:03 | * | Jesin joined #nim |
22:52:05 | * | zachcart1r joined #nim |
22:54:48 | PMunch | Hmm, why aren't inline objects considered var.. |
22:54:57 | AlexMax | krux02: noted |
22:55:37 | PMunch | If I do someproc(MyObject(field: 100)) and someproc takes a var MyObject |
22:55:56 | PMunch | I obviously don't care what happens to the object I made there as I'm only passing it in to someproc |
22:57:26 | Araq | nothing obvious here, MyObject() is not a materialization |
22:57:46 | Araq | might as well argue that takesVar(3) should work |
22:57:57 | PMunch | Sure |
22:58:02 | PMunch | Why wouldn't it? |
22:58:59 | PMunch | var is used to signify to the programmer that this argument can be changed by the procedure, so if you care about what was there you need to keep a copy. I obviously don't care what happens to the 3 or MyObject, so it should just work.. |
23:00:50 | Araq | I know of no language where you can pass non-locations to byref parameters. |
23:01:44 | Araq | there is nothing obvious about "not caring" about a computation's result. Enforced 'discard' comes to mind. |
23:02:38 | Araq | Sound more to me that your 'someproc' is misdesigned. |
23:02:45 | PMunch | Yeah.. |
23:10:30 | Araq | template varof(x): untyped = (var v = x; v) |
23:10:38 | Araq | would be a workaround |
23:15:35 | * | skellock quit (Quit: WeeChat 2.3) |
23:16:39 | * | dom96_w quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
23:18:24 | * | absolutejam_phon quit (Ping timeout: 246 seconds) |
23:37:44 | * | shpx quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
23:41:01 | PMunch | Huh, this is the strangest bug.. |
23:41:32 | PMunch | I have declared a simple proc, if the declaration is there my program just echoes something in an endless loop. Otherwise it works fine.. |
23:41:39 | PMunch | It's never called though.. |
23:42:16 | PMunch | And it doesn't matter what I put in the proc or what I name it.. |
23:43:01 | PMunch | It does matter where in the main scope I declare it though.. |
23:47:35 | * | PMunch quit (Remote host closed the connection) |
23:47:55 | * | shpx joined #nim |
23:49:11 | * | krux02 quit (Remote host closed the connection) |
23:52:18 | * | sillibird joined #nim |
23:52:58 | sillibird | How can I make a type nillable? |
23:55:26 | * | leorize quit (Ping timeout: 258 seconds) |
23:57:57 | FromGitter | <timotheecour> @ krux02 regarding PR removing spam: ya will send it today |