00:01:10 | * | Jjp137 quit (Quit: Leaving) |
00:01:37 | * | Jjp137 joined #nim |
00:06:49 | * | oddp quit (Ping timeout: 264 seconds) |
00:36:11 | * | audiophile joined #nim |
00:36:53 | * | krux02 joined #nim |
00:39:58 | * | BlameTheRoomba quit (Ping timeout: 256 seconds) |
00:40:05 | * | audiophile is now known as BlameTheRoomba |
00:46:59 | * | lritter quit (Ping timeout: 240 seconds) |
01:05:34 | * | enthus1ast quit (Ping timeout: 256 seconds) |
01:07:05 | * | RaycatWhoDat joined #nim |
01:08:33 | RaycatWhoDat | Hello. I'm trying to make Nim my go-to language but I'm having some trouble with certain analogues between the language I'm translating from. Are there any idiomatic Nim examples for the following: |
01:10:03 | RaycatWhoDat | foreach loop with an index, a variadic zip that can be used with the given for loop construct (I've looked at zero_functional and loopfusion; they seem to have issues when used in the for loop) |
01:11:01 | RaycatWhoDat | Actually, I think that's about it. |
01:11:06 | RaycatWhoDat | Thanks in advance. |
01:18:59 | * | enthus1ast joined #nim |
01:19:16 | shashlick | Isn't there a foreach package? |
01:20:09 | * | NimBot joined #nim |
01:20:13 | shashlick | https://github.com/disruptek/foreach |
01:20:27 | RaycatWhoDat | Lemme give that a try, brb |
01:24:08 | RaycatWhoDat | Ah, I think it works but I was passing in an iterator that doesn't return a tuple to destructure |
01:24:40 | * | vicfred quit (Quit: Leaving) |
01:24:42 | RaycatWhoDat | For context, I'm trying to read a file by lines and get the index variable at the same time |
01:26:14 | RaycatWhoDat | Oh, that's another thing I wanted to know |
01:26:51 | RaycatWhoDat | Is there an equivalent to Raku subsets in Nim? |
01:27:02 | disruptek | foreach is for asserting type as part of the loop. |
01:27:23 | RaycatWhoDat | Oh |
01:27:24 | disruptek | pairs() yields the index when run on an openArray|seq|array |
01:27:47 | * | apahl quit (Ping timeout: 260 seconds) |
01:27:48 | RaycatWhoDat | Is there an easy way to convert an iterator to an array? |
01:27:49 | disruptek | other iterators... use toSeq to turn them into seq or just keep track of the index yourself. |
01:28:02 | disruptek | toSeq is in the sequtils module. |
01:28:09 | RaycatWhoDat | Ah. Gotcha. Thank you! |
01:28:27 | disruptek | np |
01:29:00 | disruptek | i'm surprised loopfusion doesn't do what you want. |
01:29:20 | * | apahl joined #nim |
01:29:28 | RaycatWhoDat | That's fair. I'll try it again. |
01:31:21 | RaycatWhoDat | As an aside, are templates exempt from UFCS? |
01:31:49 | RaycatWhoDat | "MOCK_DATA.csv".lines.toSeq seems to break compilation |
01:32:29 | RaycatWhoDat | ...ooorr not. |
01:33:29 | RaycatWhoDat | I swear I was running into these problems a while back but I guess I just made a mistake. |
01:49:07 | * | silvernode joined #nim |
01:51:00 | RaycatWhoDat | Ah. Okay. I found the issue I was running into. |
01:51:56 | RaycatWhoDat | If you do "filename".lines.toSeq in a var/let assignment, Nim says there's an undeclared field called "lines" |
01:52:21 | RaycatWhoDat | But if you put it in the loop, it works |
02:10:50 | * | BlameTheRoomba quit (Quit: Default Quit Message) |
02:11:58 | disruptek | UFCS is a little funky with templates. |
02:13:23 | disruptek | it's actually a pretty subtle bug and one that Clyybber recently looked it. it might be solved in devel. |
02:19:48 | * | muffindrake quit (Ping timeout: 256 seconds) |
02:21:40 | * | muffindrake joined #nim |
02:26:05 | * | krux02 quit (Remote host closed the connection) |
02:37:15 | * | ForumUpdaterBot quit (Remote host closed the connection) |
02:37:22 | * | ForumUpdaterBot joined #nim |
02:39:32 | * | nikita_ joined #nim |
02:40:03 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
02:41:49 | * | nikita` quit (Ping timeout: 246 seconds) |
02:51:19 | ForumUpdaterBot | New thread by Iffy1: A localization/internationalization library (same purpose as gettext, but with some improvements), see https://forum.nim-lang.org/t/6553 |
02:51:51 | * | narimiran joined #nim |
03:12:29 | * | vicfred joined #nim |
03:33:08 | * | canen quit (Ping timeout: 256 seconds) |
03:49:16 | skrylar[m] | i wish i could use the forums some days <_< |
03:50:01 | skrylar[m] | my account is glitched or something; password resets don't work and i get ignored 100% of the time i try to prod support about it |
03:50:06 | skrylar[m] | for like 1-2 years now |
03:52:34 | leorize | ping narimiran or dom96 |
03:52:41 | leorize | I think they're forum mods |
03:53:04 | narimiran | pong |
03:53:29 | narimiran | skrylar[m]: what's your forum username? |
04:03:22 | skrylar[m] | skrylar |
04:03:36 | skrylar[m] | @leorize i've told dom multiple times and he refuses to do anything about it |
04:03:54 | skrylar[m] | there was a fight about this |
04:04:36 | leorize[m] | well narimiran is offering to help there :P |
04:04:41 | narimiran | so what exactly is the problem? |
04:05:08 | skrylar[m] | i can reset the password, get a token in e-mail, use that to generate a new password, and then logging in with the new password fails |
04:05:10 | narimiran | (and be quick, i'm going offline in 5min) |
04:06:02 | narimiran | so, if i send you password reset, it won't help? |
04:06:02 | * | supakeen quit (Quit: WeeChat 2.8) |
04:06:38 | * | supakeen joined #nim |
04:06:39 | narimiran | *password reset email |
04:07:30 | skrylar[m] | it hasn't, no. the link works, i put the new password in, it says ok go log in, and then says the password is invalid |
04:08:34 | narimiran | do you put your username with a capital `S`? |
04:09:13 | skrylar[m] | i don't remember anymore |
04:09:19 | skrylar[m] | i tried with upper and lower S |
04:09:23 | narimiran | it is upper |
04:11:26 | narimiran | good luck, i'm off now |
04:15:58 | * | narimiran quit (Ping timeout: 246 seconds) |
04:32:23 | * | bung joined #nim |
04:35:04 | bung | hi , am building web assets preprocessors tool, now work with nim-sass,any other resources recommanded? |
04:36:06 | bung | eg for fonts or images optimation |
04:56:39 | * | Zectbumo joined #nim |
05:11:49 | * | solitudesf joined #nim |
05:22:46 | * | B4s1l3 joined #nim |
05:22:55 | * | B4s1l3 is now known as opDispatch |
05:51:21 | leorize[m] | I wonder if we should expose some type reflection tools from the compiler internals to macros |
05:51:54 | leorize[m] | I'd love something to let me match a generic with a constraint pulled from a `bindSym` symbol :p |
05:56:00 | * | theelous3 quit (Read error: Connection reset by peer) |
06:18:45 | * | marnix joined #nim |
06:23:07 | * | icyphox is now known as icy |
06:32:22 | * | marnix quit (Ping timeout: 258 seconds) |
06:32:37 | FromGitter | <kayabaNerve> What's up with the ObservableStores warning? |
06:33:00 | FromGitter | <kayabaNerve> I've had LockLevel for... years? But this one seems to be new to 1.2.2/1.2.4. I've never found meaningful info about either. |
06:33:01 | * | marnix joined #nim |
06:33:16 | Yardanico | https://github.com/nim-lang/RFCs/issues/230 |
06:33:17 | disbot | β₯ Nim's NRVO is C++'s inplace construction (placement new) ; snippet at 12https://play.nim-lang.org/#ix=2oor |
06:37:14 | * | marnix quit (Ping timeout: 240 seconds) |
06:37:26 | * | marnix joined #nim |
06:41:57 | FromGitter | <kayabaNerve> Thanks |
06:57:50 | * | mbuchel quit (Quit: WeeChat 2.8) |
07:15:39 | * | narimiran joined #nim |
07:15:42 | * | superbia joined #nim |
07:18:06 | superbia | does anyone have a link to document with Nim in action differences in code for the newest version of nim |
07:22:15 | superbia | edit: found it https://deepakg.github.io/nim/2019/09/28/nim-in-action-errata.html |
07:24:50 | * | nikita_ is now known as nikita` |
07:40:40 | * | tane joined #nim |
07:52:19 | * | maier joined #nim |
08:02:01 | * | maier quit (Ping timeout: 264 seconds) |
08:02:02 | * | marnix quit (Read error: Connection reset by peer) |
08:02:17 | * | marnix joined #nim |
08:04:21 | * | fanta1 joined #nim |
08:16:26 | * | oculux joined #nim |
08:28:08 | * | arecaceae quit (Remote host closed the connection) |
08:28:54 | * | arecaceae joined #nim |
08:32:55 | * | oddp joined #nim |
08:39:58 | * | waleee-cl joined #nim |
09:00:13 | * | Zectbumo quit (Remote host closed the connection) |
09:08:33 | * | superbia quit (Quit: WeeChat 2.4) |
09:17:06 | * | marnix quit (Ping timeout: 256 seconds) |
09:31:34 | * | marnix joined #nim |
09:34:14 | * | Trustable joined #nim |
09:39:04 | * | NimBot joined #nim |
09:49:01 | * | synshroud_ joined #nim |
09:51:23 | * | synshroud quit (Ping timeout: 240 seconds) |
09:56:26 | * | FromDiscord quit (Remote host closed the connection) |
09:56:43 | * | FromDiscord joined #nim |
10:02:21 | ForumUpdaterBot | New thread by Oyster: Embed DLL into EXE?, see https://forum.nim-lang.org/t/6554 |
10:03:49 | * | fredrikhr joined #nim |
10:04:48 | FromDiscord | <dom96> ahh, well, there isn't much I can personally do. We need to fix the password resets. |
10:07:56 | FromDiscord | <dom96> (And the performance regression so that we can deploy the new forum) |
10:10:49 | * | Vladar joined #nim |
10:22:16 | * | marnix quit (Ping timeout: 256 seconds) |
10:23:34 | * | dddddd quit (Ping timeout: 240 seconds) |
10:25:58 | * | marnix joined #nim |
10:47:09 | * | krux02 joined #nim |
10:52:46 | * | couven92 joined #nim |
10:52:52 | * | marnix quit (Ping timeout: 256 seconds) |
10:53:01 | * | fredrikhr quit (Disconnected by services) |
10:53:02 | * | marnix joined #nim |
10:53:10 | * | couven92 is now known as fredrikhr |
10:53:29 | * | couven92 joined #nim |
11:00:15 | * | marnix quit (Read error: Connection reset by peer) |
11:00:45 | * | marnix joined #nim |
11:10:02 | * | neceve quit (Quit: Idle for 30+ days) |
11:11:43 | * | sendell quit (Quit: Idle for 30+ days) |
11:12:43 | * | Trustable quit (Remote host closed the connection) |
11:25:12 | * | nikita` quit (Quit: leaving) |
11:25:30 | * | nikita` joined #nim |
11:30:34 | * | marnix quit (Ping timeout: 240 seconds) |
11:32:00 | * | synshroud_ quit (Quit: ZNC 1.7.5 - https://znc.in) |
11:39:30 | FromDiscord | <Kiloneie> Is echoing an object directly(no fields) an error because of information hidding(works with tupples) ? Haven't played with objects much yet. |
11:43:32 | * | silvernode quit (Ping timeout: 256 seconds) |
11:52:11 | * | oddp quit (Ping timeout: 240 seconds) |
12:02:59 | * | marnix joined #nim |
12:04:24 | FromDiscord | <Yardanico> You can print an object, it's just that for ref objects your need to reference then soon |
12:05:00 | * | marnix quit (Read error: Connection reset by peer) |
12:05:05 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> Okay, how would i implement strings in my lang now? Would i just find the pair? And if theres `\` behind it, find the next pair? |
12:05:09 | * | marnix joined #nim |
12:06:02 | * | supakeen quit (Quit: WeeChat 2.8) |
12:06:16 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> (edit) 'it,' => 'it (to escape the string),' |
12:06:32 | FromDiscord | <Kiloneie> As much as i could find online, making an object non reference, e.g.. Person = object, is for simple small objects ?... Whats the point of them compared to tuples ? |
12:06:36 | FromDiscord | <lqdev> @Technisha Circuit (LGBTQIAP+) find the first ", iterate over characters until you hit \ or ". if it's \, interpret it as an escape sequence, if it's ", end parsing the string |
12:06:41 | * | supakeen joined #nim |
12:06:51 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> Thanks! |
12:06:54 | FromDiscord | <lqdev> (edit) '\,' => '\\,' |
12:07:27 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> How would i turn a string into a sequence of characters? :p |
12:07:45 | FromDiscord | <Kiloneie> split maybe ? |
12:07:58 | FromDiscord | <impbox> `let charSeq = cast[seq[char]](myString)` ? |
12:08:23 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> Thanks ;P |
12:09:05 | FromDiscord | <lqdev> ^ this works, but personally i'd just create a newSeq[char](str.len) and copyMem(mySeq[0].addr, str[0].unsafeAddr, str.len) |
12:09:32 | FromDiscord | <lqdev> because it's safer and doesn't depend on the implementation details |
12:09:37 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> Oh okay |
12:09:59 | FromDiscord | <impbox> but does do a memcopy, so if it's a really big string the cast might be better depending on your needs |
12:10:10 | FromDiscord | <impbox> but is there a reason you need a seq[char] instead of a string? |
12:10:37 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> So i can iterate through the characters until i find a pair of a certain character |
12:10:45 | FromDiscord | <impbox> you can iterate through a string |
12:11:12 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> Oh |
12:11:24 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> So with `for in in string:` should work? |
12:11:32 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> (edit) 'in' => 'i' |
12:11:33 | FromDiscord | <impbox> for c in myString: |
12:11:33 | FromDiscord | <lqdev> for char in string, yes |
12:11:38 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> Thanks |
12:11:42 | FromDiscord | <lqdev> or for i, char in string |
12:11:48 | FromDiscord | <impbox> https://play.nim-lang.org/#ix=2rXP |
12:12:02 | FromDiscord | <lqdev> though if you're doing parsing i'd recommend using a while loop |
12:12:11 | * | oculux quit (K-Lined) |
12:12:18 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> Oh? |
12:12:30 | FromDiscord | <lqdev> because the i in a pairs() loop is immutable |
12:12:36 | FromDiscord | <lqdev> so you can't do backtracking |
12:12:48 | FromDiscord | <impbox> @Technisha Circuit (LGBTQIAP+) you should probably use https://nim-lang.org/docs/unicode.html and use `for c in myString.runes:` |
12:12:55 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> Oh okay |
12:12:55 | FromDiscord | <lqdev> or better yet, write a lexer that outputs tokens, and parse the tokens |
12:13:01 | FromDiscord | <lqdev> into some AST |
12:13:10 | FromDiscord | <Technisha Circuit (LGBTQIAP+)> Thanks |
12:13:11 | FromDiscord | <impbox> since a character might be more than one byte |
12:14:30 | FromDiscord | <impbox> https://play.nim-lang.org/#ix=2rXQ |
12:14:52 | FromDiscord | <impbox> the first example can't deal with the unicode chars, but the `runes` one does |
12:24:24 | * | maier joined #nim |
12:27:23 | icy | is there a built-in function in the stdlib that strips out the URI and PORT from a given URL, and returns only the host? |
12:28:43 | FromDiscord | <impbox> icy, not exactly but uri.parseUri could split it up for you |
12:29:26 | icy | ah sick, that's what i was looking for |
12:29:46 | * | maier quit (Ping timeout: 256 seconds) |
12:29:57 | FromDiscord | <impbox> https://play.nim-lang.org/#ix=2rXW |
12:30:34 | * | fredrikhr quit (Quit: Client disconnecting) |
12:30:43 | icy | thanks! |
12:40:02 | * | couven92 is now known as fredrikhr |
12:43:06 | * | tane quit (Quit: Leaving) |
12:48:54 | * | marnix quit (Ping timeout: 240 seconds) |
12:49:04 | * | marnix joined #nim |
12:53:35 | * | oddp joined #nim |
13:05:06 | FromGitter | <alehander92> oi |
13:05:12 | FromGitter | <alehander92> let's talk |
13:05:31 | FromGitter | <alehander92> about dsl-s |
13:08:45 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
13:18:07 | Zevv | Yes, talk to me baby |
13:18:10 | Zevv | about dsl-s |
13:22:11 | * | marnix quit (Ping timeout: 240 seconds) |
13:22:27 | FromGitter | <sheerluck> no Nim developer wants to write Haskell coz in Haskell every library feels like it is written in different dsl |
13:22:47 | * | marnix joined #nim |
13:24:03 | * | rockcavera quit (Remote host closed the connection) |
13:26:36 | FromGitter | <alehander92> dude |
13:26:42 | FromGitter | <alehander92> i was just thuinking of haskell these days |
13:26:47 | FromGitter | <alehander92> because i am trying to land a job |
13:26:51 | FromGitter | <alehander92> with a haskell place |
13:27:57 | FromGitter | <alehander92> i feel language extensions might not be such a problem if that's what you mean, if you mean that they just invent their own operators etc, then this might be solvable by just having a β more "simple-api" |
13:28:05 | FromGitter | <alehander92> group of libs |
13:28:26 | FromGitter | <alehander92> something like boost for "libs with simpler haskell api" |
13:28:39 | FromDiscord | <Clyybber> alehander92: Do you know formality? |
13:28:41 | FromDiscord | <Clyybber> https://github.com/moonad/Formality |
13:29:06 | Zevv | "the entire language desugars to a 500 lines core type-theory." |
13:29:52 | FromGitter | <alehander92> it seems i have starred it |
13:29:56 | Zevv | but why |
13:30:01 | FromGitter | <alehander92> but i can't remember much, probably you linked it before |
13:30:02 | Zevv | does one write this in javascript |
13:30:18 | FromGitter | <alehander92> i did write |
13:30:25 | FromGitter | <alehander92> a lot of stuff in python before |
13:30:32 | FromGitter | <alehander92> even a hindley milner based python to c thing |
13:30:42 | FromGitter | <alehander92> (very low quality probably) |
13:31:00 | Zevv | but then again - you wanted to talk about dsl-s |
13:31:02 | FromGitter | <alehander92> i think when one knows a language well, it's just easier to go and keep using it for stuff |
13:31:11 | FromGitter | <alehander92> formality seems probably nice but |
13:31:13 | FromGitter | <alehander92> what i dont get is |
13:31:26 | FromGitter | <alehander92> this is good, the simple proving thing |
13:31:37 | FromGitter | <alehander92> but why dont we have big libs of most basic stuff prooved |
13:31:47 | FromGitter | <alehander92> so we can more easily write complex system proofs |
13:31:50 | FromGitter | <alehander92> is it that hard to compose |
13:31:59 | FromGitter | <alehander92> zevv eh i wanted to mostly bikeshed |
13:32:18 | Zevv | dude I bikeshed 40 hours per week, don't give me that in the week ends |
13:32:25 | FromGitter | <alehander92> i am at sea |
13:32:48 | FromGitter | <alehander92> i am even more week-endy |
13:33:01 | Zevv | and here you are, bikeshedding away on irc |
13:33:15 | FromGitter | <alehander92> my wife doesn't even notice |
13:33:30 | FromGitter | <alehander92> yeah i tried to do it in offtopic |
13:33:40 | FromGitter | <alehander92> but no one answered |
13:33:50 | Zevv | everybody is at sea I guess |
13:34:20 | FromGitter | <alehander92> i think it's not the most crowded season |
13:34:23 | FromGitter | <alehander92> but i might be wrong |
13:34:31 | FromGitter | <alehander92> not many people with masks man |
13:34:39 | FromGitter | <alehander92> zevv i plan on writing monads in nim |
13:34:44 | FromGitter | <alehander92> tell me why this is a bad idea |
13:35:07 | Zevv | I think one should write monads and a y combinator in every new language one learns |
13:35:10 | Zevv | just once |
13:35:16 | Zevv | and then throw it out and never look back |
13:35:33 | FromGitter | <alehander92> even in haskell? |
13:35:39 | Zevv | The only think I really like about haskell is Simpon Peyton Jones |
13:35:56 | FromGitter | <alehander92> i've heard of him |
13:36:02 | FromGitter | <alehander92> is he like jon skeet |
13:36:04 | FromGitter | <alehander92> of haskell |
13:36:34 | Zevv | I don't know jon skeet, so couldn't tell :) |
13:36:43 | FromGitter | <alehander92> the guy who answers super much on SO |
13:37:08 | FromGitter | <alehander92> he is the top guy |
13:37:18 | Zevv | ah ok |
13:37:25 | FromGitter | <alehander92> fun thing is the 5th guy ever writes he is from sofia |
13:37:30 | FromGitter | <alehander92> and i don't even know who that is |
13:37:45 | Zevv | hehe |
13:39:02 | FromGitter | <alehander92> what are you up to in #nim |
13:39:10 | Zevv | not much, lately |
13:39:29 | FromGitter | <alehander92> wow `#` autocompletes with issues in gitter |
13:39:31 | Zevv | I don't think I typed a single line of nim over the last few weeks |
13:39:39 | FromGitter | <alehander92> i feel you |
13:39:49 | FromGitter | <alehander92> i mostly code for interviews and learning now |
13:40:47 | Zevv | both good reasons |
13:41:26 | FromGitter | <alehander92> i am happy! |
13:41:32 | Zevv | so you're also doing it for fun, right |
13:41:44 | FromGitter | <alehander92> yeah, especially the haskell thing |
13:41:52 | Zevv | it bends your mind |
13:41:58 | FromGitter | <alehander92> i still think i would prefer ocaml |
13:42:04 | FromGitter | <alehander92> but it's like perl6 |
13:42:15 | FromGitter | <alehander92> it's useful to just know what those guys with glasses are up to |
13:42:36 | Zevv | If you like this kind of thing, I'd recommend going through http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/ |
13:42:40 | FromGitter | <alehander92> this glasgow type seamen |
13:42:43 | FromGitter | <alehander92> these* |
13:43:01 | FromGitter | <alehander92> ah, very disturbing pictures |
13:43:11 | Zevv | it's really one of these *wow* things where it all unfolds before your eyes |
13:43:25 | FromDiscord | <KingDarBoja> alehander92: So you writing Haskell? |
13:43:36 | FromDiscord | <KingDarBoja> Be aware of lazy evaluation π |
13:43:49 | FromGitter | <alehander92> zevv hmm |
13:43:54 | FromGitter | <alehander92> i want more type theory, sorry |
13:44:01 | FromGitter | <alehander92> i think i went through parts of sicp in the past |
13:44:20 | FromGitter | <alehander92> kingdarboja eh .. writing is a strong word |
13:44:26 | FromGitter | <alehander92> but i think i realized |
13:44:31 | FromGitter | <alehander92> why burritos are like monads |
13:44:37 | FromGitter | <alehander92> it's like |
13:45:31 | FromGitter | <alehander92> laziness yeah, i assume it might be hard : i read i should treat haskell prorgams as recipes which are ran after their construction (the whole code) |
13:45:38 | FromGitter | <alehander92> but this might be more about IO / effects |
13:47:20 | FromDiscord | <KingDarBoja> Why burritos are like monads? wtf? |
13:47:44 | FromGitter | <alehander92> well it's a famous .. i guess thing? meme/? |
13:47:56 | FromDiscord | <KingDarBoja> π€ |
13:47:59 | FromGitter | <alehander92> they try to explain monads in many tutorials so probably |
13:48:04 | FromGitter | <sheerluck> @alehander92 https://idris2.readthedocs.io/en/latest/tutorial/index.html |
13:48:06 | FromGitter | <alehander92> the burrito comparison was like a |
13:48:17 | FromGitter | <alehander92> good example of what people try |
13:48:25 | FromGitter | <alehander92> and how hard it is |
13:48:27 | FromGitter | <alehander92> to explain it |
13:48:41 | FromGitter | <alehander92> thanks @sheerluck i need to learn haskell a bit first |
13:48:50 | FromGitter | <alehander92> but i am interested in idris2 |
13:51:22 | FromDiscord | <KingDarBoja> https://github.com/zjhmale/vscode-idris/blob/master/package.json |
13:51:30 | FromDiscord | <KingDarBoja> Oh yeah, another icon to do now |
13:52:44 | FromDiscord | <KingDarBoja> But their website needs some style π |
13:53:06 | FromDiscord | <KingDarBoja> Ah lmao, it is already supported (the icon) |
13:59:57 | FromDiscord | <tomck> Hello |
14:00:15 | icy | does anyone have experience with treeform's ws package? |
14:00:16 | FromDiscord | <tomck> Can someone give me a rundown of nim's by value / by ref semantics when passing to functions? |
14:00:57 | FromDiscord | <tomck> seems most examples taket hings by value, is it assumed that the nim compiler will optimise to pass by ref when necessary, or does passing by value always copy? |
14:01:42 | FromDiscord | <tomck> If i have an object which contains a `seq[T]` and want to create a method which will get the last item of that `seq`, what does it return? `ptr T` or just `T`? |
14:02:50 | FromDiscord | <lqdev> the passes all objects whose size < 3 * sizeof(pointer) by value. all other objects are passed by ref |
14:03:12 | FromDiscord | <lqdev> return values are always copied afaik, unless you annotate them with `lent T` |
14:03:23 | FromDiscord | <tomck> what if it's `var T`? |
14:03:32 | FromDiscord | <lqdev> `var T` is always passing by reference |
14:03:46 | FromDiscord | <tomck> ok what's `lent T`, did nim catch the rust bug |
14:04:08 | FromDiscord | <tomck> oh is nim abandoning its gc? |
14:04:19 | FromDiscord | <lqdev> kind of |
14:04:30 | FromDiscord | <lqdev> `lent T` is related to the new memory management model, ARC |
14:04:36 | FromDiscord | <lqdev> which uses refcounting |
14:04:47 | FromDiscord | <lqdev> hold on, let me find the post |
14:05:00 | FromDiscord | <tomck> crazy, this is a huge change for a lang after 1.0 no? |
14:05:20 | FromDiscord | <tomck> is this available in the latest build? |
14:05:25 | FromDiscord | <lqdev> all old code is still functional |
14:05:31 | FromDiscord | <lqdev> you can enable it using --gc:arc |
14:05:33 | FromDiscord | <lqdev> when compiling |
14:05:36 | FromDiscord | <lqdev> read more here https://forum.nim-lang.org/t/5734 |
14:05:54 | FromDiscord | <tomck> will gc:arc break old code? |
14:06:15 | FromDiscord | <lqdev> afaict a little bit. you may have to annotate some closures with {.nosink.} |
14:06:22 | FromDiscord | <lqdev> in my experience, at least |
14:06:37 | FromDiscord | <lqdev> but keep in mind that ARC is still a work in progress |
14:06:43 | FromDiscord | <tomck> is it recommended to convert to arc? i've been using GC stuff so far, i think it'd break a lot of code to swtich |
14:06:49 | FromDiscord | <tomck> ah ok |
14:06:50 | * | marnix quit (Read error: Connection reset by peer) |
14:07:05 | FromDiscord | <lqdev> you don't need to use ARC if you aren't doing hard realtime stuff |
14:07:09 | FromDiscord | <lqdev> like audio |
14:07:16 | FromDiscord | <tomck> so, in GC land, what's the recommended way to return here? `ptr T`? |
14:07:22 | FromDiscord | <tomck> yeah i'm not currently |
14:07:22 | FromDiscord | <lqdev> `lent T` |
14:07:26 | FromDiscord | <lqdev> if you're indexing a seq |
14:07:34 | FromDiscord | <tomck> what, even with using the GC |
14:07:36 | FromDiscord | <tomck> (edit) 'GC' => 'GC?' |
14:07:49 | FromGitter | <alehander92> tomck it's not really 1.0 change |
14:07:54 | FromDiscord | <tomck> can `lent T` be nil? i'm getting an error trying to return nil |
14:07:55 | FromGitter | <alehander92> it is still kind of a gc i think |
14:08:03 | FromGitter | <alehander92> and big changes can still happen in 2.0 |
14:08:13 | FromDiscord | <tomck> I see |
14:08:51 | FromGitter | <alehander92> @sheerluck do you have experience with coq/lean |
14:08:53 | FromGitter | <alehander92> or similar |
14:09:04 | FromGitter | <sheerluck> @alehander92 no I'm just a python dev |
14:09:11 | FromDiscord | <tomck> Ok so how do i make a nil-able `lent T`? |
14:09:17 | FromDiscord | <exelotl> @tomck you want to return a mutable reference to the last element in a seq that was passed in as an argument? |
14:09:43 | FromDiscord | <tomck> err the seq is inside an object which is passed in, butyes @exelotl |
14:09:56 | FromDiscord | <tomck> Also another function for a non-mutable ref |
14:10:41 | FromGitter | <alehander92> sheerluck that's not an issue for checking out stuff like that |
14:12:16 | Oddmonger | i see i can have ordinal value of an enum |
14:12:26 | FromGitter | <alehander92> `.int` |
14:12:43 | Oddmonger | var Compass = enum n=2,s=4,e=8,o=16 |
14:12:52 | Oddmonger | so ord(n) returns 2 |
14:12:58 | FromGitter | <alehander92> hm `.ord` yeah |
14:13:14 | Oddmonger | but how to iterate the whole enum ? |
14:13:21 | FromGitter | <alehander92> `.low` and `.high` |
14:13:27 | FromGitter | <alehander92> but .. i think there was a thing |
14:13:33 | FromGitter | <alehander92> to directly do in `Enum` ? |
14:13:47 | * | sagax quit (Ping timeout: 246 seconds) |
14:13:55 | * | canen joined #nim |
14:14:02 | FromGitter | <alehander92> but if not you can |
14:14:21 | Oddmonger | yes, but there are Β«holesΒ» in my enum, for i in Compass witll iterate from 2 to 16 (with error due to the holes) |
14:14:38 | FromGitter | <alehander92> sorry |
14:14:54 | Oddmonger | i tried succ() and pred(), but seem cannot be use on enums |
14:15:08 | FromGitter | <alehander92> hey |
14:15:40 | * | canen quit (Remote host closed the connection) |
14:15:49 | bung | have you tried .fields ? |
14:15:57 | Oddmonger | not yet |
14:15:59 | alehander92_ | yeaaah |
14:16:05 | alehander92_ | it seems directly in enum |
14:16:08 | alehander92_ | works for Ordinal |
14:16:13 | alehander92_ | but enums with holes are not ordinal |
14:16:15 | Zevv | holes in your enum |
14:16:17 | Zevv | all bets are off |
14:16:18 | alehander92_ | i really dont like holes |
14:16:56 | disruptek | you need to make a macro. items() on enums with holes is no longer a thing. |
14:17:07 | disruptek | or a compile-time var, at least. |
14:18:19 | alehander92_ | disruptek |
14:18:20 | disruptek | tomck: there's no such thing as immutable ref, really. |
14:18:35 | Oddmonger | fields is for tuple (if i understand well the error msg) |
14:18:36 | alehander92_ | what do you think about haskell |
14:18:36 | FromDiscord | <exelotl> @tomck here's a thing I found you can do, not sure if it helps: https://play.nim-lang.org/#ix=2rYj |
14:19:03 | disruptek | i'm in favor of it. |
14:19:53 | FromDiscord | <tomck> disruptek: so how do i return the last item in a seq by reference |
14:20:07 | disruptek | ^1 |
14:20:35 | FromGitter | <sheerluck> what lang is best for writing DSLs? |
14:20:38 | FromDiscord | <exelotl> returning a var basically gives you an "L-value" which is probably preferable over returning a `ptr`, but you still have to take the address of it if you want to put it in a variable by reference |
14:20:57 | FromDiscord | <tomck> I just want to return the last value in an array without copying |
14:21:02 | FromDiscord | <tomck> b/c it will probably be large |
14:21:15 | alehander92_ | https://usercontent.irccloud-cdn.com/file/kWw6bXxv/Screenshot%20from%202020-07-18%2017-20-48.png |
14:21:20 | alehander92_ | do we need something like that for nim |
14:21:23 | alehander92_ | https://wiki.haskell.org/wikiupload/8/85/TMR-Issue13.pdf |
14:21:38 | FromDiscord | <lqdev> @tomck if the element is large it might be worth making the type `ref` |
14:21:38 | leorize[m] | @tomck it will not copy, Nim has return value optimization |
14:21:49 | FromDiscord | <lqdev> oh cool |
14:21:53 | FromDiscord | <lqdev> didn't know about that |
14:22:04 | FromDiscord | <lqdev> another element to add to my list of cool Nim features |
14:22:10 | disruptek | it doesn't sound like a design that makes sense. |
14:22:37 | FromDiscord | <tomck> RVO isn't going to make it not copy out of the array, it just makes it not copy from one stack frame to another @lqdev , unless i'm misunderstanding? |
14:23:30 | FromDiscord | <tomck> Ref means 2 indirections + an allocation per item in the list though - which is not too much of an issue, but i thought the selling point of nim was close to C super-speed, might as well use Java |
14:23:38 | FromGitter | <sheerluck> so Nim lang is the best lang for writing DSLs |
14:23:39 | alehander92_ | sheerluck i think languages with metaprogramming |
14:23:43 | disruptek | alehander: it's kinda neat looking, i guess. |
14:24:19 | RaycatWhoDat | sheerluck: Nim is very good at it but, by no means, is it the best. |
14:24:22 | * | BlameTheRoomba joined #nim |
14:24:28 | leorize[m] | @tomck you can return a lent T, then it'll be referenced |
14:25:05 | alehander92_ | sheerluck i have some ideas but i guess languages already did em |
14:25:31 | alehander92_ | disruptek i wonder if modelling those in imperative languages is useful |
14:25:34 | disruptek | tomck: what are these large values that you have that are not refs? |
14:26:42 | * | marnix joined #nim |
14:26:44 | FromDiscord | <tomck> leorize: what are the semantics of a `lent T` though? Apparently it does some borrow checking - but without lifetime annotations, how can it know what lifetime my `lent T` depends on? |
14:26:59 | disruptek | magic compiler pixie dust. |
14:27:04 | FromDiscord | <dom96> ugh, why does koch use the Nim in my PATH? |
14:27:13 | FromDiscord | <tomck> disruptek: A function scope, i'm writing an interpreter |
14:27:16 | leorize[m] | ~destructors |
14:27:16 | disbot | no footnotes for `destructors`. π |
14:27:19 | FromDiscord | <dom96> or rather, why does testament |
14:27:25 | disruptek | ~arc |
14:27:25 | disbot | arc: 11a new memory manager for Nim; see https://forum.nim-lang.org/t/5734 -- disruptek |
14:27:26 | FromDiscord | <Vindaar> Oddmonger: I wrote a macro for that: https://github.com/jovoy/AxionElectronLimit/blob/master/readOpacityFile.nim#L70-L79 |
14:27:26 | leorize[m] | ~destructor |
14:27:26 | disbot | destructor: 11https://nim-lang.org/docs/destructors.html |
14:27:46 | disruptek | dom96: pr submitted, stalled. |
14:28:03 | leorize[m] | https://nim-lang.org/docs/destructors.html#lent-type @tomck |
14:28:20 | FromDiscord | <tomck> So does my function need to take *in* a `lent seq[T]` then output a `lent T`? |
14:28:34 | alehander92_ | soo category |
14:28:45 | FromDiscord | <tomck> or, `lent Foo` where foo contains a `seq[T]` |
14:28:54 | disruptek | the seq owns the items; you just lent it in rvalue. |
14:29:09 | FromDiscord | <tomck> so, i just take in a `seq[T]` and that won't copy? |
14:29:14 | FromDiscord | <dom96> > dom96: pr submitted, stalled.β΅@disruptek[IRC]#0000 oh bah, I just created an issue for this |
14:29:20 | FromDiscord | <dom96> oh well, maybe that'll move it along |
14:29:42 | FromDiscord | <tomck> Ah okay, so `lent T` is *only* ever for return values |
14:29:52 | disruptek | dom96: it's one of these things that i don't care about. you can argue that the current behavior is correct. |
14:30:08 | FromDiscord | <dom96> It's currently wasting my time, so I do care |
14:30:09 | disruptek | tomck: rtfm, arc is awesome. you will like it. |
14:30:19 | leorize[m] | @tomck yea, Nim's parameters won't copy if the size is bigger than 3x float |
14:30:21 | disruptek | it does what you want. |
14:30:48 | alehander92_ | and arrows really confuse me |
14:30:50 | FromDiscord | <tomck> I was speaking to someone earlier who said I needed to pass `--gc:arc` as a flag though, which can break non-arc code (which my codebase currently is) |
14:31:02 | FromDiscord | <tomck> does `lent T` work alongside the normal GC? |
14:31:07 | leorize[m] | use --gc:orc |
14:31:12 | leorize[m] | yes it does |
14:31:33 | leorize[m] | destructors work with any gc, arc is just a gc built on top of it |
14:31:47 | leorize[m] | orc is basically arc but aware of cycles |
14:31:54 | disruptek | if it breaks arc, it's a bug that will have priority to get fixed. it won't be a blocker for you. |
14:32:39 | disruptek | the goal is for arc to become the default gc. |
14:33:03 | leorize[m] | orc will be default first though :p |
14:33:19 | FromDiscord | <tomck> lol ok so let me get this straightβ΅* `ref T` interacts with the GCβ΅* `lent T` is a 'reference' which doesn't interact with the GC |
14:33:20 | disruptek | dom96: feel free to take over my pr, whatever that means. π |
14:33:52 | leorize[m] | @tomck yea, it's like a const reference in C++ |
14:33:55 | FromDiscord | <tomck> `arc` is refcounting / RAII a la C++ |
14:34:13 | FromDiscord | <tomck> `orc` is `arc` but with some extra bullshit to make it work with old nim code |
14:34:19 | FromDiscord | <tomck> (edit) '`orc` is `arc` but with some extra bullshit to make it work with old nim code ... ' => '`orc` is `arc` but with some extra bullshit to make it work with old nim code(and free cycles properly)' |
14:34:23 | FromDiscord | <dom96> I'm quite surprised nobody ran into this before https://github.com/nim-lang/Nim/pull/15012 |
14:34:25 | disbot | β₯ [Backport] Fixes callbacks being dropped on Linux/macOS/BSD. ; snippet at 12https://play.nim-lang.org/#ix=2rYn |
14:34:27 | FromDiscord | <dom96> Pretty big bug |
14:34:31 | disruptek | well, orc is arc with some bs to break cycles. |
14:35:03 | leorize[m] | it's not some bs, it's pretty damn good |
14:35:52 | leorize[m] | comparable to arc performance and can handle cycles without you needing to care |
14:36:22 | disruptek | i wouldn't say orc is "pretty damn good", or particularly performant. |
14:36:30 | disruptek | but it doesn't matter. |
14:36:46 | leorize[m] | @dom96 might be the same bug that I found developing asyncstdin for @iffy |
14:36:47 | disruptek | the arc tech is superior for myriad reasons. |
14:37:08 | FromDiscord | <tomck> I'm struggling to understand why I need to specify gc:arc or gc:orc, surely this whole sink/lent stuff with refcounting should work alongside the GC just fine? Or does `gc:arc` effectively make `ref T` a shared pointer |
14:37:39 | disruptek | arc is impl as code transformations. |
14:37:46 | leorize[m] | I need to know your problem first, can you elaborate on what you're trying to do? |
14:38:07 | FromDiscord | <tomck> basically, why would I ever use the default GC if `orc` is apparently superior? |
14:38:10 | * | sagax joined #nim |
14:38:20 | disruptek | tomck: the default gc is better-tested. |
14:38:33 | leorize[m] | it's unstable and is only usable on devel atm |
14:38:35 | * | Guest94576 joined #nim |
14:38:45 | leorize[m] | it will be the default for 1.4, hopefully |
14:38:55 | leorize[m] | wouldn't hold my breath for that though |
14:39:05 | FromDiscord | <tomck> Ok cool so I'd rather stick with default if that's the case, BUT does that change some of the semantics of `lent T` / `ref T` or are the semantics the same? |
14:39:21 | disruptek | in some cases, arc has not been optimized sufficiently; there may be a corner case that is significantly slower. |
14:39:28 | disruptek | semantics don't change. |
14:39:40 | FromDiscord | <tomck> I can use `lent T` in the normal GC just fine, as long as I'm not touching `ref T` then the GC will never actually be called? |
14:39:46 | leorize[m] | so... what are you trying to do again? |
14:39:48 | disruptek | arc is like someone went through and added memory management on your behalf, because that's exactly what it is. |
14:40:16 | * | Guest94576 quit (Client Quit) |
14:40:36 | FromDiscord | <tomck> i have an object type, and i want to add a proc to return a ref to an element in a seq thta the object owns |
14:40:53 | leorize[m] | have you considered just using a template? |
14:40:54 | FromDiscord | <Recruit_main707> > I can use `lent T` in the normal GC just fine, as long as I'm not touching `ref T` then the GC will never actually be called?β΅@tomck no, if you compile with gc:none, it will show you a qarning of everything that uses gced memory |
14:41:46 | FromGitter | <sheerluck> @dom96 It would be nice if "Packages CI" was not only ubuntu-18.04 + macos-10.15 but also ubuntu-20.04 + linuxmint-20 + archlinux + gentoo |
14:42:05 | leorize[m] | the template can inline the seq access for you and you won't have to think about all this lent stuff |
14:42:11 | FromDiscord | <tomck> sent a code paste, see https://play.nim-lang.org/#ix=2rYo |
14:42:17 | FromDiscord | <tomck> Does this work ^ |
14:42:18 | FromDiscord | <dom96> sheerluck: why? |
14:42:28 | FromDiscord | <Recruit_main707> That includes strings sequences, and slices between others iirc |
14:42:55 | leorize[m] | @tomck nope, option[t] is a container |
14:43:03 | leorize[m] | you can just raise an exception... |
14:43:08 | FromGitter | <sheerluck> to spread Nim everywhere |
14:43:38 | disruptek | does gitnim not work on your platform? |
14:43:43 | FromDiscord | <tomck> sent a code paste, see https://play.nim-lang.org/#ix=2rYp |
14:44:06 | leorize[m] | use "^1" as the index |
14:44:17 | FromDiscord | <Recruit_main707> ^ |
14:44:35 | leorize[m] | and yes that would work |
14:44:36 | FromDiscord | <tomck> ok regardless of that lol, the `lent T` part, what are the semantics of this |
14:44:47 | leorize[m] | you can also just make it a template and don't have to care anymore |
14:44:55 | leorize[m] | no stackframes, no nothing |
14:45:01 | FromDiscord | <Recruit_main707> There is no generic param though, eouls it? |
14:45:06 | FromDiscord | <Recruit_main707> would* |
14:45:39 | FromDiscord | <tomck> sent a code paste, see https://play.nim-lang.org/#ix=2rYq |
14:45:53 | leorize[m] | no |
14:46:09 | FromDiscord | <tomck> ok so what is `lent T` |
14:46:15 | FromDiscord | <tomck> just `T` without a copy? |
14:46:27 | FromDiscord | <tomck> If `my_foo` is freed and I use `last_foo_val`, that'll segfault, correct? |
14:46:31 | leorize[m] | "var T" but not mutable |
14:46:49 | leorize[m] | the compiler have some analysis to error out when that happens |
14:46:51 | FromDiscord | <Recruit_main707> Essentially a raw pointer then? |
14:47:02 | leorize[m] | you can try it yourself |
14:47:31 | FromDiscord | <tomck> but can it segfault |
14:47:56 | FromDiscord | <tomck> it's hard to test this, b/c often little test programs won't segfault |
14:47:57 | leorize[m] | you can just try :p |
14:48:04 | leorize[m] | we have a playground for this :p |
14:48:12 | FromDiscord | <Recruit_main707> Why do you need a ref to qn index though |
14:48:32 | FromDiscord | <Recruit_main707> (item of seq) |
14:48:41 | FromDiscord | <tomck> you can't make a test, then if it doesn't segfault, say 'oh this'll be fine for sure' |
14:48:56 | FromDiscord | <lqdev> because the item might be really big and he wants to avoid copying it @Recruit_main707 |
14:49:01 | FromDiscord | <tomck> b/c at a later date I might not have it be a seq,it might be a table |
14:49:05 | FromDiscord | <tomck> also that ^ |
14:49:14 | leorize[m] | use a template |
14:49:21 | leorize[m] | then you don't have to care |
14:49:39 | FromDiscord | <tomck> template == macro? |
14:49:46 | leorize[m] | nope |
14:49:53 | * | Vladar quit (Quit: Leaving) |
14:50:00 | leorize[m] | you can also look at the generated C code if you're concerned |
14:50:53 | leorize[m] | I'm pretty we got some extra analysis for "lent T" to prevent issues like this, but ofc testing is always the best way to check |
14:51:10 | FromDiscord | <tomck> idc if it does segfault,i just need to know whether those are the semantics of `lent T` |
14:51:14 | leorize[m] | I'd read the C code for you but I'm on phone rn :p |
14:51:22 | leorize[m] | ~destructor |
14:51:23 | disbot | destructor: 11https://nim-lang.org/docs/destructors.html |
14:51:35 | leorize[m] | ^ semantics are written in there |
14:51:57 | FromDiscord | <tomck> > It is proven by the compiler that the pointer does not outlive its origin |
14:51:59 | leorize[m] | you can also just ping Araq and ask him :p |
14:52:21 | FromDiscord | <tomck> so the compiler *will* make sure that `last_foo_val` outlives `my_foo`? |
14:52:35 | FromDiscord | <tomck> in which case how tf is it doing that w/out lifetime annots? |
14:52:46 | leorize[m] | magic |
14:52:57 | leorize[m] | ask Araq and/or @Clyybber |
14:53:05 | leorize[m] | they wrote most of the analysis logic |
14:53:35 | FromDiscord | <tomck> i mean it's possible, but has implications for linking to other nim code if you don't have access toit |
14:54:18 | leorize[m] | not really, but again I'd defer the answer to the experts |
14:54:28 | FromDiscord | <tomck> if you know what the function is you can analyse it to figure it out,β΅but if all you have is a compiled binary + some nim declarations for the types, it's not possible, regardless of how they implemented it |
14:55:00 | FromDiscord | <tomck> or does everything have to be an FFI decl if you're linking across multiple libs? |
14:55:11 | FromDiscord | <tomck> That would work well i suppose |
14:59:55 | FromGitter | <deech> Is Gara currently the most mature pattern matching library? |
15:03:24 | bung | I think patty more popular, about "mature" idk |
15:04:34 | alehander92_ | true |
15:04:45 | alehander92_ | you can try them both |
15:05:00 | alehander92_ | but patty is more used maybe |
15:07:29 | FromGitter | <deech> alehander92_, oh hey since you're on can you help me with gara? How does the `~` work? I'm trying to destructure a variant object. |
15:14:53 | disruptek | tomck: if you pass a pointer to ffi code, all bets are off. |
15:15:02 | bung | any image optimization lib in nim ? |
15:15:33 | disruptek | tomck: arc is for refs; managed pointers. you can pass them around and they won't get collected as long as you increment the ref counter manually. |
15:15:35 | federico3 | can I simply include a file in c? |
15:15:41 | disruptek | sure. |
15:19:02 | federico3 | how? |
15:19:05 | FromDiscord | <Shucks> Might repeat but who knows: Did anyone got completions / suggestions with vim and nimlsp working? |
15:19:17 | FromDiscord | <Shucks> nvim* |
15:19:19 | federico3 | it it just importc? |
15:26:45 | * | lritter joined #nim |
15:31:01 | icy | can the `result` variable only store strings? |
15:31:25 | FromDiscord | <treeform> icy, "does anyone have experience with treeform's ws package?" well I do... |
15:31:32 | icy | ayy |
15:31:40 | icy | great pkg btw |
15:31:46 | FromDiscord | <treeform> thanks |
15:31:57 | icy | wait, lemme pastebin my code and ask my q |
15:32:41 | icy | treeform: https://termbin.com/5tgs |
15:33:01 | icy | so i'm trying to do this -- but it says 'type mismatch: got <Future[system.string]> but expected 'string'' |
15:34:54 | icy | and when i use `return` instead, i get https://termbin.com/g013 |
15:38:07 | FromDiscord | <treeform> you need to `result = await ws.receiveStrPacket()` |
15:38:21 | FromDiscord | <treeform> just like you `await ws.send(...)` |
15:38:25 | FromDiscord | <treeform> they are all async calls |
15:38:43 | icy | yeah that doesn't work either... |
15:38:50 | icy | lemme paste the error |
15:39:02 | FromDiscord | <treeform> When you see `Future[..]` it means it wants `await` in front of it. |
15:39:30 | FromDiscord | <treeform> you can think of as `await` unwraps futures by waiting in time... |
15:40:04 | icy | yeah but that won't return a Future will it? |
15:40:15 | icy | it'll return the type after the Future resolves -- `string` in this case |
15:40:30 | icy | https://termbin.com/nd3r |
15:40:40 | icy | besides, when i await it like you mentioned i get this ^ |
15:42:52 | FromDiscord | <treeform> If you want to return a future ... (I would not do that) ... you would need to remove the {.async.} |
15:43:04 | FromDiscord | <treeform> {.async.} also unwraps the future some how |
15:43:40 | icy | oh... |
15:43:41 | icy | hmmm |
15:43:54 | icy | guess i'll have to rework it so as to not return a Future heh |
15:44:52 | icy | treeform: however, if i put {.async.} against a proc, doesn't it /have/ to return a Future? |
15:44:52 | FromDiscord | <treeform> I just tried this: https://play.nim-lang.org/#ix=2rYA |
15:44:54 | FromDiscord | <treeform> works great |
15:45:17 | icy | wow |
15:45:19 | icy | weird |
15:45:52 | FromDiscord | <treeform> are you on nim 1.0.0+ ? |
15:45:58 | icy | yeah, 1.2 |
15:46:01 | icy | on OpenBSD |
15:46:02 | icy | if that matters |
15:46:05 | FromDiscord | <treeform> it should work then |
15:46:11 | FromDiscord | <treeform> does that 5 line file compiles? |
15:46:27 | icy | let me try it standalone |
15:46:49 | icy | yep it compiles on its own |
15:46:54 | icy | ok so something else is causing issues then |
15:47:01 | FromDiscord | <treeform> it seems to |
15:48:04 | icy | thanks btw |
15:48:12 | FromDiscord | <treeform> no problem |
16:00:51 | alehander92_ | deech sorry not often online until |
16:00:57 | alehander92_ | next week] |
16:01:48 | alehander92_ | i dont think there is `~` currently? |
16:04:12 | * | marnix quit (Read error: Connection reset by peer) |
16:06:44 | FromGitter | <deech> alehander92_, enjoy your offline time. I'll file an issue. :) |
16:09:18 | alehander92_ | awesome, thank you |
16:18:21 | * | marnix joined #nim |
16:21:30 | * | waleee-cl joined #nim |
16:29:18 | FromDiscord | <tomck> I have a variant struct, how can i have one of the variant not have any data associated with it? |
16:30:28 | FromDiscord | <tomck> sent a code paste, see https://play.nim-lang.org/#ix=2rYL |
16:33:08 | FromDiscord | <tomck> Oh i can just use `discard` instead of `pass` here |
16:45:03 | disruptek | yep. |
16:49:09 | * | idf31 joined #nim |
16:51:43 | FromDiscord | <tomck> so, just quickly back to this whole sink/lend thingβ΅I'm using the default GCβ΅If a function is taking ownership of something, can I just mark that type as 'sink' and that'll all work & provide me a nice bonus performance benefit if the compiler can figure it out? |
16:52:06 | FromDiscord | <tomck> or at least warn me of unneccesary copies or something? |
16:59:30 | FromDiscord | <tomck> Okay hang on, now i'm strugglingβ΅β΅So, to allocate a traced object you use `new` and that'll initialise an object to its default values on the heap somewhere, tracked by the GCβ΅What if that object is a variant? If i use `new` then try and change the `kind` of the variant, it (rightfully) complains with `assignment to discriminant changes object branch` |
17:05:40 | FromDiscord | <tomck> ohhhhhhh hang on, you don't need `new` to allocate, you just crreate the struct & nim will allocate in the background if you're creating a `ref Foo`? that's cool |
17:05:43 | FromDiscord | <tomck> mb! |
17:07:55 | FromDiscord | <lqdev> yeah using an object constructor with ref objects is automatically translated to `new(x)` |
17:08:06 | FromDiscord | <lqdev> and doesn't trigger case transition warnings |
17:10:53 | * | theelous3 joined #nim |
17:13:40 | FromDiscord | <KingDarBoja> https://forum.nim-lang.org/t/3124#38670 I was searching for some kind of optional parameter on a proc using `options` module BUT without having to write `some()` everytime I want to use that argument on proc call and found this comment on the forums, do you recommend that converter approach? |
17:22:39 | Prestige | I'm attempting to write a proc that takes any proc as an argument. Is there a way to do this, or do I just need to go a different route with a template/macro? |
17:23:14 | * | narimiran quit (Ping timeout: 240 seconds) |
17:23:55 | FromDiscord | <KingDarBoja> Also searching for some kind of `readonly` for type fields, but looks like it isn't implemented (yet) on the lang: https://github.com/nim-lang/RFCs/issues/100 |
17:23:55 | disbot | β₯ Allow exporting object fields as read-only without requiring custom accesors |
17:25:19 | * | Vladar joined #nim |
17:25:28 | Prestige | My overall goal is to get a seq of all types of the arguments of an arbitrary proc (at compile time) |
17:26:24 | Prestige | Maybe I do only need a macro |
17:26:31 | FromDiscord | <KingDarBoja> Example Prestige? |
17:26:54 | Prestige | I'll write one up, just a moment |
17:27:38 | * | Vladar quit (Client Quit) |
17:30:02 | FromDiscord | <KingDarBoja> What you explained sounds a lot like: https://flow.org/en/docs/types/utilities/#toc-objmap (which I am reading right now) |
17:31:06 | Prestige | Yeah I'll just need a macro |
17:31:15 | Prestige | Anyway, essentially this: https://play.nim-lang.org/#ix=2rZ1 |
17:35:23 | FromDiscord | <KingDarBoja> π |
17:35:55 | * | Trustable joined #nim |
17:40:02 | * | Vladar joined #nim |
17:41:26 | Prestige | Really need to find a good macro tutorial |
17:50:39 | disruptek | why? |
17:51:21 | Prestige | Struggling to figure out how to pass a proc to a macro and be able to look at/manipulate the AST |
17:52:05 | disruptek | proc bar() {.foo.} = ...; macro foo(n: untyped): untyped = ...manipulations... |
17:53:19 | FromDiscord | <Yardanico> @tomck just FYI - it is actually save to change the discriminator for object variant kind with newruntime |
17:53:39 | FromDiscord | <Yardanico> Because default destructor for casw objects makes sure that it's safe |
17:53:48 | FromDiscord | <Yardanico> (edit) 'casw' => 'case' |
17:53:48 | disruptek | just don't. |
18:04:11 | Prestige | Hm so there's no way to have the argument of the macro to be a proc, it's just untyped and I have to manually validate what was passed in? |
18:04:50 | disruptek | make it `typed` if you want. you can `foo bar`, too. |
18:05:06 | disruptek | i'm not sure what you mean by "manually validate." |
18:05:15 | * | lo0p joined #nim |
18:05:32 | * | bung quit (Quit: Lost terminal) |
18:05:41 | Prestige | I want the user to be passing in a proc, not any arbitrary thing |
18:05:58 | disruptek | see `expectKind` |
18:13:19 | * | BlameTheRoomba quit (Remote host closed the connection) |
18:13:50 | Prestige | Oh so this is interesting: https://play.nim-lang.org/#ix=2rZb the treeRepr is Ident "callback", so I guess it only refers to what is literally in the parens? I'm trying to evaluate the actual callback proc on line 8 |
18:14:07 | Prestige | glad I finally found treeRepr lol |
18:14:41 | disruptek | see macros.params |
18:15:21 | disruptek | you cannot get types at runtime, though; they are a purely compile-time animal. |
18:16:04 | Prestige | Right |
18:16:53 | FromDiscord | <lqdev> Prestige: also, getImpl |
18:17:46 | Prestige | Oh neat, thanks |
18:18:13 | Zevv | types and macros is sooo much fun |
18:18:38 | Zevv | My all time favorite: https://github.com/nim-lang/RFCs/issues/44 |
18:18:38 | disbot | β₯ [RFC] Working with types in macro is difficult. |
18:18:50 | Prestige | Been hard pressed to find a good source to learn them |
18:19:28 | Zevv | I found the only way to learn is bumping your nose until the blood is everywhere |
18:22:16 | * | marnix quit (Ping timeout: 246 seconds) |
18:23:13 | * | marnix joined #nim |
18:24:11 | FromDiscord | <juan_carlos> I found `macros.parseStmt` really easy to work with, is just a string you can `echo`, then switching to `quote do:`. |
18:24:34 | FromDiscord | <juan_carlos> But yeah kinda advanced feature of the lang. |
18:24:46 | Zevv | I recently threw out all the "do's" after my quotes. Stuff still works. |
18:24:56 | disruptek | i'm not very sophisticated; i prefer to just do everything by hand. fewer surprises, i guess. |
18:25:19 | disruptek | !mem |
18:25:19 | disbot | total: 24469504; free: 3670016; owned: 18891248; max: 24469504 |
18:26:30 | * | lo0p quit (Quit: WeeChat 2.8) |
18:28:37 | Prestige | getImpl is exactly what I needed to know |
18:30:46 | disruptek | Zevv: dude. |
18:31:45 | disruptek | am i missing something or is there really no way to disambiguate between selector registrations by fd? |
18:32:06 | disruptek | do they clobber each other? |
18:33:49 | * | Zectbumo joined #nim |
18:37:48 | * | endragor quit (Remote host closed the connection) |
18:38:30 | * | endragor joined #nim |
18:42:55 | * | endragor quit (Ping timeout: 246 seconds) |
18:48:26 | Prestige | I've gotten this far https://play.nim-lang.org/#ix=2rZi not sure why nothing prints on the playground, though |
18:49:05 | Prestige | I have my Sym nodes, just need to transform them into a seq[typedesc] somehow |
18:51:11 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
18:56:43 | FromDiscord | <KingDarBoja> How I would do something like this:β΅> $ObjMap<O, F> takes an object type `T` and a function `F` and returns an object whose keys are the keys of the object T and each value is the return type of calling the function for each object value. |
18:57:21 | FromGitter | <awr1> i forget, how do you index a raw pointer |
18:57:23 | FromGitter | <awr1> in nim |
18:57:36 | FromGitter | <awr1> do I have to convert it to UncheckedArray or something |
18:59:27 | FromDiscord | <Yardanico> Yeah |
18:59:55 | FromDiscord | <Yardanico> cast[ptr UncheckedArray[mytype]](mypointer) |
19:02:15 | FromGitter | <awr1> oh cool nim has `toOpenArray` for that now |
19:02:20 | disruptek | Prestige: types are a thing that you only have at compile-time. |
19:02:59 | disruptek | i dunno how to state this more clearly. |
19:06:22 | * | fanta1 quit (Quit: fanta1) |
19:09:20 | Prestige | This is compile time disruptek |
19:09:42 | disruptek | how do you figure? |
19:12:12 | Prestige | Well it's a macro which runs during compilation and is printing out the types of the args of my callback |
19:12:26 | disruptek | so what's the problem? |
19:12:57 | Prestige | Idk how to put those types into a seq in the macro |
19:13:13 | disruptek | firstly, a seq can contain items of only one type. |
19:13:42 | Prestige | Right, I wanted that to be typedesc |
19:13:49 | disruptek | if you want a compile-time seq of compile-time values, such as ast symbols, simply `var s: NimNode; s.add someSym` |
19:14:03 | disruptek | er, var s: seq[NimNode] ... |
19:16:53 | Prestige | So I'm not sure how to transform e.g. Ident "int" into a typedesc - I also seem to be getting an error when I set the macro's return type to seq[typedesc] |
19:21:44 | * | Jesin joined #nim |
19:21:50 | disruptek | i'm not sure what you expect to happen. |
19:22:05 | FromDiscord | <Vindaar> you simply don't transform it. Just use the `Ident "int"` |
19:22:27 | disruptek | what are you trying to accomplish? |
19:22:53 | disruptek | maybe he wants $ident? |
19:25:22 | Prestige | I'm writing an ECS framework and I have a table of hashed typedescs to seqs of components, I need to get the typedescs of the callback params to access the appropriate seqs of components |
19:25:53 | disruptek | sounds like you need a seq of hashes, not a seq of typedescs. |
19:26:02 | disruptek | a typedesc is a funky form of typeclass. |
19:26:12 | Zevv | "Golang picking [] instead of <> for Generics" |
19:26:35 | Prestige | It's a table with hashes as the keys |
19:27:33 | FromDiscord | <lqdev> Zevv: at least they used their brains for once and did something sensible |
19:27:36 | Prestige | I want to transform the Ident "MyType" into a typedesc |
19:27:51 | * | disruptek sighs. |
19:32:34 | * | marnix quit (Ping timeout: 256 seconds) |
19:33:22 | * | marnix joined #nim |
19:36:58 | alehander92_ | [] is good |
19:37:17 | alehander92_ | go are ok man |
19:38:24 | Prestige | How do I construct a seq in a macro to return it? |
19:38:34 | alehander92_ | you can use compile time functions |
19:38:38 | alehander92_ | and it's better to do so imho |
19:38:52 | alehander92_ | but the macro itself should return just a node |
19:38:57 | alehander92_ | you can use stmt list |
19:39:03 | alehander92_ | if you want many |
19:39:05 | alehander92_ | !! |
19:39:39 | * | silvernode joined #nim |
19:39:53 | FromDiscord | <lqdev> Prestige: the AST would be `nnkPrefix(ident"@", nnkBracket(valuesGoHere))` |
19:40:27 | FromDiscord | <lqdev> because, if you haven't realized it, `@[]` is simply the @ operator applied on an array |
19:41:35 | Prestige | Yeah, just trying to figure out macros lol. I have a for loop getting values from the AST, trying to put them all in a seq and return it |
19:41:43 | FromDiscord | <Vindaar> he wants a compile time seq, I believe. You just create a seq in a compile time constant and add to it, just like you would at run time |
19:42:06 | FromDiscord | <Vindaar> but a `seq[typedesc]` is simply not valid |
19:42:19 | Prestige | oh really? dang |
19:42:22 | FromDiscord | <Vindaar> use a `seq[NimNode]` |
19:42:31 | FromDiscord | <Vindaar> each node represents one type |
19:42:54 | FromDiscord | <Vindaar> (simply as an ident) |
19:43:17 | Prestige | ahh thanks! I thought I had to convert it first to something |
19:43:17 | FromDiscord | <Vindaar> still possible that what you're trying isn't possible though |
19:43:25 | FromDiscord | <Vindaar> nope |
19:44:05 | * | silvernode_ joined #nim |
19:44:24 | * | silvernode quit (Ping timeout: 256 seconds) |
19:45:34 | FromGitter | <Lecale> Is there an async version of something like execProcess(blah.exe) from osproc ? I've never tried async in nim before |
19:45:43 | disruptek | !repo asynctools |
19:45:43 | disbot | https://github.com/cheatfate/asynctools -- 9asynctools: 11Various asynchronous tools for Nim language 15 58β 20π΄ |
19:45:44 | * | Senketsu joined #nim |
19:47:06 | Prestige | @Vindaar I am attempting this: https://play.nim-lang.org/#ix=2rZJ |
19:47:43 | Prestige | oh I need to change the initial result |
19:48:11 | alehander92_ | ahh sorry |
19:48:12 | FromGitter | <Lecale> what a useful bot, although your conversation is a bit limited |
19:48:24 | alehander92_ | !repo ? |
19:48:25 | disbot | no results π’ |
19:50:57 | * | azed joined #nim |
19:53:24 | * | alehander92_ is now known as alexander92 |
19:53:51 | * | alexander92 is now known as alehander92 |
19:59:06 | Prestige | So I need to init result as a newStmtList, add the @ prefix and bracket, then somehow add the nodes to it, then close the bracket? All the examples I'm seeing have everything in-lined, like nnkBracket(nnkIntLit(1), nnkIntLit(2), nnkIntLit(3)). I think that's actually just a printed treeRepr, I'm not seeing anything on adding new nodes to the result in the manual |
20:00:12 | Yardanico | Another (somewhat interesting) programming language - https://vale.dev/ |
20:00:21 | Yardanico | they have UFCS and "Ownership, move semantics, and deterministic destruction." :P |
20:01:15 | FromDiscord | <Vindaar> @Prestige the thing you have to be aware is that you cannot return types (you can of course have a macro that in the end only results in a single type as an expression) or have types in a seq at runtime. You need to use your types for something at compile time. |
20:01:49 | skrylar[m] | Yardanico: hm. neat but .. meh |
20:01:55 | FromDiscord | <Vindaar> so the question is what do you want to use those types your macro will return for |
20:01:58 | Yardanico | well yeah, I'm not saying it's good or not, just shared it |
20:02:16 | skrylar[m] | i could have sworn nim once had region pointers |
20:02:16 | FromDiscord | <Vindaar> but I'm gonna be afk for ~1 hour now |
20:02:25 | Yardanico | skrylar[m]: there's --gc:regions if you mean that |
20:02:47 | skrylar[m] | no it was something you could subtype pointers with |
20:02:51 | skrylar[m] | for arenas |
20:03:02 | skrylar[m] | i may be remembering that which never existed again |
20:03:10 | Prestige | I have a lookup table of hashed types. I just have no idea how to return these values I have from my macro |
20:03:56 | skrylar[m] | hmm. i should finish the tlsf module |
20:04:01 | skrylar[m] | i was admiring how small that algorithm actually is |
20:04:02 | Yardanico | I just shared Vale in case Nim can get some ideas from it :P |
20:04:48 | Yardanico | although I have to say - the syntax in https://vale.dev/ref/regions (first example) is far from readable for me :P |
20:04:49 | * | marnix quit (Read error: Connection reset by peer) |
20:05:03 | Yardanico | fn biggestShipName<'a ro>(ships 'a &List<Ship>) Str { |
20:05:30 | skrylar[m] | i think nim is mostly fine, although it could maybe do with a compiler overhaul, but eh. |
20:05:34 | * | marnix joined #nim |
20:05:40 | Yardanico | the compiler overhaul will eventually happen anyway |
20:05:50 | Yardanico | but not soon :) |
20:05:51 | skrylar[m] | i have some ideas but i don't feel like it right now |
20:06:26 | skrylar[m] | basically what i wanted to do was have a webasm or muvm (i like Mu because it has tracing pointers) shell, and then basically run the whole thing like lisp/smalltalk does |
20:06:36 | skrylar[m] | so you just like |
20:06:59 | skrylar[m] | parse the module and dump the images |
20:07:58 | skrylar[m] | but theres a lot of experimental shit involved and i uh, have to work on stuff that pays right now ^^; |
20:11:13 | * | lmariscal joined #nim |
20:11:55 | Prestige | @Vindaar did what I said sound correct in what I'd have to do to return a seq at least? I'm lost at how I should return some value, or transform the result into a seq. |
20:19:55 | Prestige | Think I'm getting close https://play.nim-lang.org/#ix=2s0Z |
20:20:38 | Prestige | https://play.nim-lang.org/#ix=2s15 * |
20:23:57 | * | Vladar quit (Quit: Leaving) |
20:27:09 | FromDiscord | <Varriount> Anyone know if C2Nim can translate enums? |
20:27:35 | FromDiscord | <Varriount> Also, wasn't there an alternative/complementary tool to C2Nim? |
20:27:42 | Yardanico | nimterop? |
20:27:48 | Yardanico | but it's separate from c2nim :P |
20:27:54 | Yardanico | and I think it can translate enums |
20:28:20 | FromDiscord | <lqdev> @Varriount nimgen? |
20:28:36 | FromDiscord | <lqdev> that's the complementary tool |
20:29:11 | FromDiscord | <Varriount> I don't think Nimterop is it, unless it can help extract definitions from C files |
20:30:37 | FromDiscord | <Varriount> I'm processing many large header files with complex type definitions |
20:31:28 | Yardanico | nimterop can help with that exactly |
20:31:36 | Yardanico | It's made for more automatic process with less manual work |
20:32:14 | * | azed quit (Ping timeout: 256 seconds) |
20:32:57 | FromDiscord | <Varriount> Yardanico: How does it parse header files? |
20:33:01 | Yardanico | with toast |
20:33:24 | Yardanico | it uses treesitter |
20:33:49 | Yardanico | but of course has a lot of it's own processing stuff too |
20:34:00 | Yardanico | see https://github.com/nimterop/nimterop/blob/master/nimterop/toastlib/ast2.nim |
20:34:18 | Yardanico | @shashlick can explain better :P |
20:35:09 | FromDiscord | <Varriount> Oh, neat. |
20:35:11 | * | silvernode_ quit (Quit: Konversation terminated!) |
20:38:00 | * | idf31 quit (Ping timeout: 258 seconds) |
20:41:35 | FromDiscord | <Varriount> Yardanico: my biggest pain point right now is that C2Nim can only process simple type definitions. |
20:41:46 | Yardanico | nimterop is more advanced in that regard I think |
20:41:55 | Yardanico | there's quite a lot of wrappers you can look at |
20:42:22 | FromDiscord | <Varriount> It chokes on definitions of the form `typedef def alias1, alias2, ... ` |
20:43:10 | * | narimiran joined #nim |
20:43:28 | * | azed joined #nim |
20:43:47 | * | marnix quit (Ping timeout: 240 seconds) |
20:49:10 | FromDiscord | <Varriount> @shashlick If I pass toast multiple files, does it simply output the translation of all of them to stdout, or is there a way to have it write to multiple files? |
20:52:20 | Yardanico | why won't you use nimterop itself? |
20:52:27 | Yardanico | using toast directly isn't the best idea I think |
20:52:32 | disruptek | it makes my teeth hurt. |
20:52:47 | shashlick | Should be doable to use toast directly |
20:52:54 | shashlick | Except when you need to override something |
20:53:15 | shashlick | You can pass multiple files, output will be one |
20:53:42 | shashlick | Best to see some existing wrappers |
20:54:02 | shashlick | And the readme and docs |
20:54:41 | shashlick | Happy to answer questions in a couple hours |
20:54:44 | shashlick | What you wrapping |
20:55:20 | FromDiscord | <Varriount> Yardanico: If Nimterop can successfully parse and emit sensible Nim code from Windows SDK files, I will personally donate at least $50 to @shashlick |
21:00:02 | FromDiscord | <Varriount> (I'm being serious) |
21:04:39 | * | NimBot joined #nim |
21:07:53 | FromDiscord | <Varriount> Ok... is it @shashlick Does treesitter use any pragmas to modify the C compiler flags? |
21:08:04 | FromDiscord | <Varriount> (edit) removed 'Ok... is it' |
21:08:38 | FromDiscord | <Varriount> Because Clang is choking on arguments passed to it because the paths contain spaces (My use directory) |
21:13:10 | Prestige | This is driving me nuts |
21:21:27 | FromDiscord | <Vindaar> @Prestige back now.β΅I still don't quite understand why you want to return a seq here or rather in what context that macro is supposed to be used |
21:23:16 | Prestige | I have a table with the keys as hashed typedescs, just still trying to figure out how to create and return a seq from a macro (in general) |
21:23:45 | Yardanico | you don't return "a seq" from a macro directly |
21:23:49 | Yardanico | you return an AST representing a seq, yes |
21:24:08 | Prestige | right, idk how to do that |
21:24:14 | FromDiscord | <Vindaar> this is what I was typing right now (still typing preettyy slow over here...): you mention you have a lookup table of hashes of types. where do those come from? I assume this macro is supposed to extract the type of the callback and... |
21:24:44 | Yardanico | Prestige: uhh it's just simple AST construction, you can use dumpAstGen to see |
21:24:54 | * | narimiran quit (Ping timeout: 240 seconds) |
21:25:01 | FromDiscord | <Vindaar> the problem is: you can construct a `nnkBracket` with idents of types |
21:25:16 | Prestige | Yeah, I've done that to see what I need to construct, I'm stuck on the how |
21:25:38 | FromDiscord | <Vindaar> however, those "cannot survive" compile time, because at run time that isn't allowed |
21:26:12 | Prestige | They will be hashed at complie time |
21:26:25 | FromDiscord | <Vindaar> then give me a sec |
21:26:28 | Prestige | compile* |
21:27:04 | Yardanico | Prestige: simplest seq construction is https://play.nim-lang.org/#ix=2s1p |
21:27:11 | Yardanico | but really can you share more context and code? |
21:28:28 | FromGitter | <awr1> is there a way you can get `offsetof` from every field in a field through the `fields` iterator |
21:28:33 | Prestige | ah thank you - I'll copy paste my explanation from earlier |
21:31:53 | FromDiscord | <Vindaar> here you go: https://play.nim-lang.org/#ix=2s1r |
21:32:09 | * | solitudesf quit (Ping timeout: 256 seconds) |
21:32:47 | Yardanico | also https://github.com/PMunch/macroutils might help |
21:32:58 | Yardanico | it contains a lot of useful stuff for working with macros ;) |
21:33:02 | Prestige | or not, I can't find it. I'm writing an ECS framework, and need to look up a seq of components based on their type. Since typedescs aren't available at runtime, I hashed the typedescs and use them as the keys for the table. The code I'm writing now is so the user can provide a callback with multiple components as params, I get the type descs, hash them, and get the respective component seqs |
21:33:42 | Prestige | Thanks all |
21:33:49 | FromDiscord | <Vindaar> of course you don't necessarily have to do stuff in that macro (you can have a compile time global table to store NimNodes and use those from some other macro for instance) |
21:35:37 | FromDiscord | <Vindaar> @Prestige can you share the rest of the code? |
21:36:03 | FromDiscord | <KingDarBoja> I forgot how to initialize some fields on a Type object... Was like calling the object type right? |
21:36:13 | Prestige | sure 1 min |
21:36:36 | Prestige | https://github.com/avahe-kellenberger/EasyECS |
21:36:43 | Prestige | Not much there yet |
21:36:48 | Yardanico | @KingDarBoja what's a Type object? |
21:37:00 | Yardanico | if you mean object construction, it's Foo(bar: 1, baz: "hello") |
21:37:13 | Prestige | registry.nim has the important bits |
21:37:25 | FromDiscord | <KingDarBoja> sent a code paste, see https://play.nim-lang.org/#ix=2s1s |
21:37:36 | Yardanico | Something(fieldB: "hi") |
21:37:46 | FromDiscord | <KingDarBoja> Thanks π |
21:38:13 | FromGitter | <awr1> managed to do it with a macro |
21:41:47 | * | Senketsu quit (Read error: Connection reset by peer) |
21:43:31 | FromDiscord | <Vindaar> @Prestige I'm trying to wrap my head around how your macro will fit in there. |
21:46:10 | Prestige | It's going to be a helper function to a public/exposed function (maybe a template) which invokes the callback with the appropriate values from the table |
21:47:49 | Prestige | I'm not sure what the error is here: https://play.nim-lang.org/#ix=2s1u |
21:48:05 | Yardanico | you can't have arrays of typedescs at runtime |
21:48:15 | Yardanico | they're compile-time only :) |
21:48:23 | Prestige | Yeah |
21:48:38 | Prestige | Maybe I just need to do the hashing inside the macro |
21:48:55 | ForumUpdaterBot | New thread by Aviator: Printing Nim AST as Nim code?, see https://forum.nim-lang.org/t/6555 |
21:49:47 | skrylar[m] | there was an API for that |
21:51:44 | * | azed quit (Quit: WeeChat 2.8) |
21:56:25 | * | endragor joined #nim |
21:58:07 | FromDiscord | <Vindaar> @Avahe an example that might put you on the right track: https://play.nim-lang.org/#ix=2s1x |
21:59:33 | FromDiscord | <Vindaar> as you see, I build code that constructs a _runtime_ (!) sequence, with hardcoded types, extracted from the callbacks arguments |
21:59:52 | * | Trustable quit (Remote host closed the connection) |
22:00:08 | FromDiscord | <Vindaar> * call of hardcoded types to `getTypeId` that should read |
22:00:24 | Prestige | thanks, I was trying to figure out exactly how to invoke getTypeId! |
22:01:12 | * | endragor quit (Ping timeout: 256 seconds) |
22:25:20 | * | laqq3_ joined #nim |
22:32:37 | Prestige | Is there a reason getCallbackArgTypes can't be called from a template? |
22:33:23 | * | azed joined #nim |
22:35:02 | * | waleee-cl joined #nim |
22:37:02 | FromDiscord | <Varriount> @shashlick I was able to compile nimterop. I'll make a PR with the changes I had to make in order to get things to work. |
22:37:31 | FromDiscord | <Varriount> It might be tricky though, since you have to sort between using clang+windows sdk, and clang/gcc+mingw |
22:42:21 | Prestige | @Vindaar https://0x0.st/ivgv.png does this not make sense? It's wanting the callback to be passed into getCallbackArgTypes as a NimNode |
22:42:35 | FromDiscord | <Varriount> It essentially amounted to using quotes around filenames passed via passC, and doing `{.passC: "-Dfdopen=_fdopen".} |
22:44:04 | Yardanico | can't you do that with nimterop itself? |
22:44:22 | FromDiscord | <Varriount> Yardanico: Not when it's Nimterop that's not compiling |
22:44:28 | Yardanico | oh |
22:44:30 | FromDiscord | <Vindaar> no, because the code in a template will be inserted as is (thus the resulting code exists at runtime) |
22:53:10 | Prestige | Hmm I'm confused as to why this is an issue, I thought it would resolve the template calling the macro at compile time. It seemed like the problem was I needed to convert the proc to a different type or something |
22:56:13 | Prestige | I found another Nim ECS framework that does what I'm trying to do @Vindaar but I'm not 100% on how its macros work yet (if you're curious): https://github.com/yglukhov/ecs/blob/master/ecs.nim#L73 |
22:56:39 | Prestige | That's pretty much the function I'm trying to make ^ |
23:08:20 | * | azed quit (Quit: WeeChat 2.8) |
23:10:03 | * | sentreen quit (Quit: sentreen) |
23:15:05 | * | sentreen joined #nim |
23:17:11 | * | krux02_ joined #nim |
23:18:52 | shashlick | @varriount so using clang on windows? |
23:19:20 | shashlick | What was the issue you faced |
23:20:04 | * | krux02 quit (Ping timeout: 256 seconds) |
23:22:23 | shashlick | Isn't windows sdk c++? |
23:25:00 | * | bozaloshtsh_ quit (Quit: ZNC 1.7.5 - https://znc.in) |
23:25:36 | FromDiscord | <impbox> Prestige i tried to do something very similar to you, but ran into the issue that I couldn't access a compile time seq at runtime |
23:25:45 | FromDiscord | <impbox> I'll find the issue number |
23:25:59 | Prestige | Thanks |
23:26:46 | FromDiscord | <Elegant Beef> What're we trying to do? |
23:27:17 | FromDiscord | <impbox> https://github.com/nim-lang/Nim/issues/13375 |
23:27:18 | disbot | β₯ Accessing compileTime variable at runtime returns zeroed data. ; snippet at 12https://play.nim-lang.org/#ix=2bba |
23:27:55 | * | bozaloshtsh joined #nim |
23:27:55 | * | bozaloshtsh quit (Changing host) |
23:27:55 | * | bozaloshtsh joined #nim |
23:28:25 | Yardanico | @impbox you can easily workaround it though |
23:28:31 | Yardanico | just do "let procs = nameToProc" and use procs at runtime |
23:30:09 | Prestige | Beef: essentially this https://github.com/yglukhov/ecs/blob/master/ecs.nim#L73 |
23:30:23 | FromDiscord | <Elegant Beef> I mean use english please |
23:30:24 | FromDiscord | <Elegant Beef> π |
23:30:49 | * | laqq3_ quit (Ping timeout: 264 seconds) |
23:31:53 | FromDiscord | <impbox> Yardanico does that actually work? I'm pretty sure I tried that at the time but it didn't work, though maybe it's fixed since. I'll give it a test tonight |
23:31:58 | Yardanico | yes I just tested |
23:32:07 | Yardanico | https://play.nim-lang.org/#ix=2s1D |
23:32:09 | FromDiscord | <Elegant Beef> https://github.com/beef331/nico-helper/blob/master/src/levelmanager.nim#L37 |
23:32:13 | FromDiscord | <Elegant Beef> I mean works for me |
23:32:27 | FromDiscord | <Elegant Beef> Oh |
23:32:30 | FromDiscord | <Elegant Beef> That |
23:32:37 | FromDiscord | <Elegant Beef> Good to no yard |
23:32:40 | FromDiscord | <Elegant Beef> Danke |
23:32:45 | FromDiscord | <Elegant Beef> know* |
23:32:54 | Yardanico | nice 5 messages :P |
23:32:59 | FromDiscord | <Elegant Beef> No problem |
23:33:09 | FromDiscord | <Elegant Beef> Use a better speech platform π |
23:33:10 | FromDiscord | <impbox> Cool |
23:33:15 | FromDiscord | <impbox> Thanks |
23:33:24 | Yardanico | @Elegant even on discord 5 messages in a row takes quite a lot of space :) |
23:33:27 | Yardanico | irc is no different in that regard |
23:33:34 | FromDiscord | <Elegant Beef> Eh i have it a portrait monitor |
23:33:37 | FromDiscord | <Elegant Beef> Point nullified π |
23:34:06 | Yardanico | "Oh, that? Good to know yardanico" is much smaller than 5 lines though :P |
23:34:31 | FromDiscord | <Elegant Beef> It indeed is, but i already hit enter, so i couldnt take it back |
23:35:04 | FromDiscord | <impbox> Need to enable slowmode |
23:35:10 | Yardanico | is it there for discord? |
23:35:14 | Yardanico | or need bots or something? |
23:35:19 | FromDiscord | <Elegant Beef> Nah slowmode is a thing |
23:35:23 | FromDiscord | <impbox> It's a discord thing |
23:35:31 | FromDiscord | <Elegant Beef> I dont think slowmode is really needed, just people that arent inept |
23:35:45 | FromDiscord | <impbox> Clientside slowmode |
23:35:49 | Yardanico | oh that |
23:35:53 | Yardanico | i thought server-side |
23:39:07 | * | tyler569 quit (Quit: WeeChat 2.3) |
23:39:42 | FromDiscord | <Rika> > @Elegant Beef even on discord 5 messages in a row takes quite a lot of space :)β΅doesnt need 5 messages if you edit |
23:39:47 | FromDiscord | <Rika> oops, pinged beef |
23:39:59 | skrylar[m] | you know. i should get off my butt and test zulip. the chat streams are supposed to be nice. |
23:40:27 | Yardanico | @Rika well, he didn't edit :P |
23:41:04 | FromDiscord | <Rika> well prolly because we're used to not edit stuff because of the old bridge |
23:41:36 | Yardanico | I don't think Beef really was there before the new bridge :) |
23:41:57 | FromDiscord | <Rika> really? |
23:42:09 | FromDiscord | <Rika> my head only has 4 kb of storage, sorry |
23:42:40 | Yardanico | btw my invite to this discord server has been used 1707 times |
23:42:45 | Yardanico | and we have 1071 members :P |
23:43:34 | FromDiscord | <Elegant Beef> I mean i was |
23:43:41 | FromDiscord | <Elegant Beef> I've been here for like 4-6 months |
23:44:00 | Yardanico | well true |
23:44:01 | FromDiscord | <Rika> i dont know how long ive been here |
23:44:19 | Yardanico | @RIka since 20/09/2019 |
23:44:22 | FromDiscord | <Rika> 10 months |
23:44:27 | FromDiscord | <Rika> ish |
23:44:38 | FromDiscord | <Elegant Beef> The way i see it is you made your arguement about 5 messages when you complaining resulted in more than 5 messages π |
23:44:46 | FromDiscord | <Yardanico> https://discordapp.com/channels/371759389889003530/371759389889003532/371762716940959755 |
23:44:48 | FromDiscord | <Rika> big brain |
23:45:17 | FromDiscord | <Rika> I CANT BELIEVE THE FIRST BRIDGE WAS IN GO |
23:45:22 | FromDiscord | <Rika> I FEEL BETRAYED |
23:45:25 | Yardanico | I didn't write it |
23:45:27 | Yardanico | I used matterbridge |
23:47:25 | Yardanico | btw if you actually check I have less messages on the discord server than, for example, Beef |
23:48:17 | Yardanico | LOL |
23:48:49 | Yardanico | apparently this server is 1001 days old today |
23:48:54 | Yardanico | so it was 1000 days old yesterday |
23:49:08 | Yardanico | from 2017-10-22 to 2020-07-19 |
23:49:54 | FromDiscord | <XeroOl> hello |
23:50:11 | FromDiscord | <XeroOl> does anybody know how to cast an array into a pointer? |
23:50:24 | Yardanico | cast[pointer](myarr[0].addr) |
23:50:29 | Yardanico | ah actually |
23:50:33 | Yardanico | just myarr[0].addr |
23:50:40 | Yardanico | you take the address of the first element of the array |
23:50:44 | Yardanico | works for seqs too |
23:52:21 | FromDiscord | <XeroOl> it says `expression has no address, maybe use "unsafeAddr"` |
23:52:39 | Yardanico | can you show the code? |
23:52:47 | Yardanico | ah right |
23:52:50 | FromDiscord | <XeroOl> let vertices = [0.0f, 0.5, 0.5, -0.5, -0.5, -0.5] |
23:52:52 | Yardanico | you need to declare your array with "var" |
23:52:52 | FromDiscord | <XeroOl> discard addr(vertices[0]) |
23:53:09 | FromDiscord | <XeroOl> ahh, that makes sense |
23:53:23 | Yardanico | I mean it'll probably work with let + unsafeAddr too, but it's better to just use var :) |
23:53:33 | FromDiscord | <XeroOl> var is definitely what I want |
23:53:45 | FromDiscord | <XeroOl> thank you very much |
23:56:59 | Yardanico | I guess I should also (for fun of course) sort users by message count for all messages in IRC (since all logs are there) |
23:57:30 | FromDiscord | <Varriount> Yardanico @shashlick toast seems to be giving me problems - all I get when attempting to run it with a file is:β΅```Error: unhandled exception: C:\Users\Clay Sweetser\Documents\Repositories\nimterop\nimterop\toastlib\tshelp.nim(15, 12) `gState.code.nBl` Empty code or preprocessor error [AssertionError]``` |
23:58:29 | shashlick | Are you on the command line or cimport |
23:58:35 | FromDiscord | <Varriount> command line |
23:58:40 | shashlick | Add -d to get debug output |
23:58:56 | shashlick | Will tell you what it is trying to parse |
23:59:13 | shashlick | Also make sure you use -p |
23:59:25 | shashlick | Preprocess is crucial for non trivial wrappers |
23:59:42 | FromDiscord | <Varriount> Nope, same error |