00:03:37 | FromDiscord | <huantian> It'll only compile if a is a value between 0 and 1 |
00:06:07 | * | tk quit (Quit: Well, this is unexpected.) |
00:06:24 | FromDiscord | <Alea> interesting |
00:06:31 | * | tk joined #nim |
00:08:39 | FromDiscord | <Elegantbeef> It also has runtime checks to ensure it's only 0..1 |
00:08:39 | FromDiscord | <Elegantbeef> You can use subrange types everywhere so dont think it's just a procedure thing! |
00:09:41 | FromDiscord | <auxym> yeah was about to say it can also crash at run time: https://play.nim-lang.org/#ix=3Uee |
00:10:02 | FromDiscord | <auxym> unless you compile with `-d:danger` |
00:10:17 | FromDiscord | <Elegantbeef> Nice complex `1.5` |
00:10:51 | FromDiscord | <auxym> gotta trick the compile into thinking that the value isn't known at compile time 😄 |
00:11:17 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Uef |
00:11:20 | FromDiscord | <Elegantbeef> Nim doesnt do value narrowing |
00:11:33 | FromDiscord | <Elegantbeef> Subrange types only statically error if a literal or const is passed |
00:11:53 | FromDiscord | <auxym> `doThing(0.5 + 1)` was caught at compile time though |
00:15:36 | FromDiscord | <Elegantbeef> That's a constant |
00:16:27 | FromDiscord | <Elegantbeef> Just cause you write your constant `Tau / 2` doesnt mean it's not constant 😛 |
00:18:15 | * | yiggityswaps joined #nim |
00:24:33 | FromDiscord | <auxym> yeah. but that's the story of how `var b = 0.5 +1` happened |
00:41:50 | FromDiscord | <dither> Sorry dumb question, I think Nim is great and I'm not sure if I'm thinking of things correctly but it seems great for maintaining C/C++ projects since it supports the backend. There's an old large C++ codebase and I want to slowly rewrite it in Nim while still being integrated with the rest of the codebase as I go, similar to how you would go about modernizing a javascript project with typescript (or Nimlang even). Am I correct to think Ni |
00:42:22 | FromDiscord | <Elegantbeef> It does have C++ interop and is one of the few languages that does so it seems fine |
00:42:54 | FromDiscord | <Elegantbeef> Making the bindings is the biggest thing you'll need to do |
00:43:16 | FromDiscord | <dither> that doesn't sound too bad, would I write the bindings in Nim? |
00:43:29 | FromDiscord | <dither> overall that's great to hear, I thought so too because of how it had C++ backend support but wanted to make sure I wasn't coming to the wrong conclusion |
00:44:16 | FromDiscord | <Elegantbeef> https://youtu.be/d2VRuZo2pdA?t=1968 |
00:44:20 | FromDiscord | <Elegantbeef> Little talk about it if you want |
00:45:06 | FromDiscord | <dither> Thank you Elegantbeef, I appreciate it. Will watch it as soon as I can 🙏 |
00:46:27 | FromDiscord | <dither> Another small dumb question, I was reading a lot into Crystal and Zig, they seem to be going for similar use cases as well tho what I appreciated about Nimlang is that it seems to not overpromise, Zig is trying to tackle an entire toolchain and Crystal still lacks windows support outside of WSL2. Hope Nim keeps growing in popularity |
00:46:38 | FromDiscord | <dither> (edit) "dumb question," => "aside," |
00:46:58 | FromDiscord | <dither> (edit) "popularity" => "popularity, it seems mature enough for big projects" |
00:53:19 | FromDiscord | <Elegantbeef> Join the club 😛 |
00:53:45 | FromDiscord | <demotomohiro> Nim can wrap template class/functions in C++ |
00:53:51 | FromDiscord | <demotomohiro> https://forum.nim-lang.org/t/9007 |
00:54:13 | FromDiscord | <Elegantbeef> The talk i linked goes overthat |
01:10:00 | * | vicfred joined #nim |
01:17:31 | * | neurocyte86144 joined #nim |
01:19:37 | * | neurocyte8614 quit (Ping timeout: 256 seconds) |
01:19:37 | * | neurocyte86144 is now known as neurocyte8614 |
02:06:07 | * | Gustavo6046 quit (Quit: Gustavo6046) |
02:06:18 | * | Gustavo6046 joined #nim |
02:09:34 | * | Gustavo6046 quit (Client Quit) |
02:09:46 | * | Gustavo6046 joined #nim |
02:10:38 | * | rockcavera joined #nim |
02:10:38 | * | rockcavera quit (Changing host) |
02:10:38 | * | rockcavera joined #nim |
02:43:07 | yiggityswaps | Are the BigO notations of the the procs in the standard library anywhere? I usually check nim-lang.org/docs for the documentation but it doesn't seem like it has it anywhere... |
02:44:28 | FromDiscord | <ynfle> Which procs? Some have in the docs, some are quite obvious and some you can get by reading the source code |
02:52:45 | * | arkurious quit (Quit: Leaving) |
03:07:19 | FromDiscord | <Elegantbeef> Who whatns to make a bigopximator? 😛 |
03:07:21 | FromDiscord | <Elegantbeef> wants to |
03:07:39 | yiggityswaps | Right now I'm not curious about one, just wanted to know haha |
03:08:10 | FromDiscord | <Elegantbeef> I dont think any mentions big O |
03:08:24 | FromDiscord | <Elegantbeef> I guess some do |
03:12:11 | * | yiggityswaps quit (Quit: Leaving) |
03:13:17 | * | Gustavo6046 quit (Quit: Gustavo6046) |
03:13:21 | * | yoyojambo joined #nim |
03:49:29 | FromDiscord | <aph> can i read with encoding with `FileStream.readStr`? it got me stuck for a while, not sure what i did wrong but the text i got is just weird |
03:50:03 | FromDiscord | <Elegantbeef> Strings in nim are binary streams |
03:50:37 | FromDiscord | <aph> hmm |
03:50:51 | FromDiscord | <Elegantbeef> What's the code? |
03:50:57 | FromDiscord | <Elegantbeef> And the file |
03:51:17 | FromDiscord | <aph> hang on |
03:51:18 | FromDiscord | <aph> :) |
03:51:43 | FromDiscord | <aph> da file https://media.discordapp.net/attachments/371759389889003532/960386155826782278/lumine.pmx |
03:51:55 | FromDiscord | <aph> sent a code paste, see https://play.nim-lang.org/#ix=3Uf1 |
03:52:08 | FromDiscord | <aph> (edit) "https://play.nim-lang.org/#ix=3Uf1" => "https://play.nim-lang.org/#ix=3Uf2" |
03:52:36 | FromDiscord | <demotomohiro> That file contains a text not in unicode encoding? |
03:52:41 | FromDiscord | <Elegantbeef> I assume this file has non ascii text? |
03:52:47 | FromDiscord | <aph> yes |
03:53:10 | FromDiscord | <aph> it's in binary, but it also contains some text data in UTF8 or UTF16LE encoding |
03:53:47 | FromDiscord | <Elegantbeef> Well strings and streams are not unicode aware so you need to figure out if the string is unicode and if so figure out how much you need to read |
03:54:03 | FromDiscord | <demotomohiro> Nim's echo expects utf8 encoding. |
03:54:17 | FromDiscord | <Elegantbeef> I mean echo doesnt matter |
03:54:20 | FromDiscord | <aph> oh, i guess i need to convert it? |
03:54:31 | FromDiscord | <Elegantbeef> Nim's echo expects a string, it's whatever your terminal expects that's the issue |
03:54:40 | FromDiscord | <aph> In reply to @Elegantbeef "Nim's echo expects a": hmm |
03:54:44 | FromDiscord | <aph> time to switch os |
03:54:47 | FromDiscord | <aph> 😎 |
03:56:35 | FromDiscord | <demotomohiro> On windows, Nim change console code page to 65001 and fail to print utf8 encoded Japanese text if I didnt set the font of console correclty. |
03:57:29 | FromDiscord | <Elegantbeef> Well you could also make your own `unicodestream` 😛 |
03:57:55 | FromDiscord | <aph> oh i know why now. chinese characters contains 2 bytes |
03:57:56 | FromDiscord | <aph> hm |
03:58:05 | FromDiscord | <aph> In reply to @demotomohiro "On windows, Nim change": time to switch to linux ig |
03:58:07 | FromDiscord | <huantian> Well Inmean |
03:58:13 | FromDiscord | <huantian> What did you expect from utf16 |
03:58:26 | FromDiscord | <aph> i was supposed to get `女主角` instead of `sY;N҉`. heh |
03:58:29 | FromDiscord | <huantian> 16 bits = 2 bytes 😛 |
03:58:37 | FromDiscord | <aph> In reply to @huantian "16 bits = 2": :( |
03:58:42 | FromDiscord | <Elegantbeef> There is `widestr` |
03:59:41 | FromDiscord | <aph> sure will try |
03:59:42 | FromDiscord | <aph> ty |
03:59:57 | FromDiscord | <Elegantbeef> Though dont know if it'll help |
04:00:12 | FromDiscord | <aph> gotta try everything ¯\_(ツ)_/¯ |
04:00:23 | FromDiscord | <aph> ~~or just ignore it, who cares about comments or model name~~ |
04:03:00 | FromDiscord | <demotomohiro> On windows, if you want to echo non-utf8 charactors, compiling your code with `-d:nimDontSetUtf8CodePage` might work. |
04:03:09 | FromDiscord | <demotomohiro> https://github.com/nim-lang/Nim/blob/c3f03cfa5dfa2ca47f8e4cf99bbcdbf5a7d16eda/lib/std/syncio.nim#L856 |
04:03:43 | FromDiscord | <huantian> Why is windows so weird with utf8 honestly |
04:03:55 | FromDiscord | <huantian> Probably backwards compatibly baggage ig |
04:03:58 | FromDiscord | <aph> In reply to @demotomohiro "On windows, if you": heh, didn't work :( |
04:04:15 | FromDiscord | <aph> trying to use wsl if it makes a difference, installing nim |
04:04:19 | FromDiscord | <huantian> I feel bad for people who have to use cmd all the time |
04:04:28 | FromDiscord | <huantian> At least Windows Terminal exists |
04:05:13 | FromDiscord | <aph> In reply to @aph "trying to use wsl": nope it didn't! time to fix the code! |
04:05:21 | FromDiscord | <huantian> Maybe there’s something in std/unicode for this |
04:05:25 | FromDiscord | <aph> In reply to @huantian "I feel bad for": ~~use powershell smh~~ |
04:05:40 | FromDiscord | <huantian> Also shouldn’t UTF-8 account for variable width chars |
04:05:44 | FromDiscord | <huantian> Like isn’t that the point |
04:06:08 | FromDiscord | <aph> ¯\_(ツ)_/¯ |
04:07:54 | FromDiscord | <aph> hurray `encodings` worked |
04:07:56 | FromDiscord | <aph> thanks |
04:16:03 | FromDiscord | <Elegantbeef> you mean windows 😛↵(@huantian) |
04:17:49 | FromDiscord | <spoon> up + enter > interacting with ui |
04:18:13 | FromDiscord | <Elegantbeef> How'd you know my build process |
04:18:31 | FromDiscord | <Elegantbeef> How goes the nimscripter stuff anyway? |
04:19:12 | FromDiscord | <spoon> well i got it to run and then i had to leave |
04:19:41 | FromDiscord | <spoon> but now i have to figure out how to get it to fit into my object instead of a proc so i can flatty + supersnappy my world object |
04:20:08 | FromDiscord | <Elegantbeef> What do you mean? |
04:20:32 | FromDiscord | <spoon> remember how i was using an onHit proc in my game and it took an enemy as a parameter? |
04:20:47 | FromDiscord | <Elegantbeef> Sure |
04:21:36 | FromDiscord | <spoon> i'm trying to switch it to nimscript so i can serialize special objects |
04:21:57 | FromDiscord | <Elegantbeef> Well the bridge presently does everything by copies |
04:23:28 | FromDiscord | <spoon> so would `onHit: NimScriptFile"proc(e: enemy)"` work out do you think? |
04:24:08 | FromDiscord | <Elegantbeef> I dont see why it wouldnt, but you then need to make an intepreter for each |
04:24:28 | FromDiscord | <spoon> hmmm |
04:25:20 | FromDiscord | <spoon> could just be stored as a string, too |
04:25:32 | FromDiscord | <spoon> can i use options to make the enemy parameter optional? |
04:25:48 | FromDiscord | <Elegantbeef> If you ship the options module with your stdlib |
04:27:17 | FromDiscord | <spoon> sure, ship it with everything |
04:28:07 | FromDiscord | <Elegantbeef> Do you intend on dynamically scripting the actions? |
04:31:01 | FromDiscord | <Elegantbeef> Cause if not what you're doing is pretty silly |
04:34:00 | FromDiscord | <spoon> i'm not very familiar with embedding, so i'm probably reorganizing most of it later |
04:34:13 | FromDiscord | <spoon> or embedded scripting languages rather |
04:34:21 | FromDiscord | <Elegantbeef> Is this purely for seralizing? |
04:35:24 | FromDiscord | <spoon> no, the object originally had a `proc` field for modding/extension purposes, but you can't serialize a proc, at least not with flatty |
04:35:42 | FromDiscord | <Elegantbeef> I mean you can serialise it relatively easily |
04:35:52 | FromDiscord | <Elegantbeef> Assuming it's compiled in the binary |
04:37:19 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/wX9 |
04:37:53 | FromDiscord | <spoon> well having programmable objects is one of my goals |
04:38:02 | FromDiscord | <Elegantbeef> Well then i guess carry on |
04:38:28 | FromDiscord | <Elegantbeef> Sounded like this was only a serialisation issue prior |
04:42:23 | FromDiscord | <spoon> yeah, just meant procs don't serialize |
04:44:30 | FromDiscord | <spoon> guess it'll be easier now to just have all the potential functions in one nimscriptfile object |
04:47:24 | FromDiscord | <spoon> `isNil` doesn't work for it though |
04:47:26 | FromDiscord | <spoon> hmm |
04:47:41 | FromDiscord | <Elegantbeef> Fow what? |
04:48:13 | FromDiscord | <spoon> for `not isNil specialWeapon(ply.handEquip).onHit` |
04:48:46 | FromDiscord | <Elegantbeef> You'd have to load the interpreter up, and depending on how you set up nimscripter that check is moot |
04:49:22 | FromDiscord | <Elegantbeef> I'd suggest to just go with the table approach until later |
04:50:17 | FromDiscord | <spoon> so would i have to boot up a new interpreter each time the attack proc runs then? |
04:50:24 | FromDiscord | <Elegantbeef> no |
04:50:34 | FromDiscord | <Elegantbeef> You boot up the interpreter on changes |
04:50:39 | FromDiscord | <Elegantbeef> And then just call t he procedure |
04:50:51 | FromDiscord | <Elegantbeef> you can ensure the procedure exists statically |
04:51:29 | FromDiscord | <spoon> that's gonna be rough if the enemy can hold scripted weapons too |
04:51:31 | FromDiscord | <spoon> oh well |
04:51:41 | FromDiscord | <Elegantbeef> Well perhaps this isnt the library to use for you |
04:52:49 | * | yoyojambo quit (Quit: Leaving) |
04:53:20 | FromDiscord | <spoon> dunno, maybe can figure something out unless there's already a better fit |
04:53:28 | FromDiscord | <Elegantbeef> No clue |
04:53:38 | FromDiscord | <Elegantbeef> I'd personally use dynamic libraries or WASM |
04:53:59 | FromDiscord | <spoon> wasm? |
04:54:06 | FromDiscord | <spoon> how'd that work? |
04:54:30 | FromDiscord | <spoon> i guess if i were rendering with webkit |
04:54:36 | FromDiscord | <Elegantbeef> No |
04:54:57 | FromDiscord | <Elegantbeef> You can use the WASM runtime as a plugin system for slightly safer native code libraries |
04:55:13 | FromDiscord | <spoon> hm. |
04:56:33 | FromDiscord | <spoon> i'll have to look into how enu does its stuff |
04:57:16 | FromDiscord | <spoon> but haven't heard of using wasm |
04:57:23 | FromDiscord | <Elegantbeef> WASM/dynamic libraries give a language agnostic API for scripting |
04:57:36 | FromDiscord | <Elegantbeef> WASM would mostly be for sandboxxing |
04:57:49 | FromDiscord | <Elegantbeef> Dont want people to distribute malware and that would give you that |
04:59:47 | FromDiscord | <spoon> yea, being able to edit on the fly is important too so wasm doesn't sound ideal for that |
05:00:07 | FromDiscord | <spoon> if nimscript just doesn't work right now there's also lua, i like their hook system |
05:00:17 | FromDiscord | <huantian> Why do you need to edit your modded files on the fly? |
05:01:18 | FromDiscord | <spoon> In reply to @huantian "Why do you need": current game is also a testing ground for a future ss13-like where i'm hoping gms will be able to quickly prototype and make custom scripted weapons and such |
05:01:36 | FromDiscord | <spoon> but maybe i'll add drones in the current thing i'm making |
05:01:59 | FromDiscord | <Elegantbeef> Why cant you edit on the fly with WASM? |
05:02:10 | FromDiscord | <spoon> doesn't wasm need to be compiled for some lang? |
05:02:20 | FromDiscord | <spoon> from |
05:02:23 | FromDiscord | <Elegantbeef> Sure nad it'd be relatively small packages |
05:02:23 | * | rockcavera quit (Remote host closed the connection) |
05:03:00 | FromDiscord | <Elegantbeef> Like yes you need a compiler tool chain, but they'd be small packages so the code would be generated very quickly |
05:03:28 | FromDiscord | <spoon> i've actually done on the fly editing with luapad and gmod from within the actual game before before so i know it works |
05:03:43 | FromDiscord | <spoon> if i were to implement something else it'd likely be that |
05:04:34 | FromDiscord | <Elegantbeef> We have different views so dont let me dissuade you 😛 |
05:05:15 | FromDiscord | <spoon> meh, relying on a compiler toolchain and quick prototyping just don't sound like they go together for me |
05:05:26 | FromDiscord | <Solitude> i like your views more, beef |
05:06:01 | FromDiscord | <Elegantbeef> Well we're talking about small files, yes there is a bit of preamble for setup, but in the end it's more extensible |
05:06:30 | FromDiscord | <Elegantbeef> Lol why solitude |
05:06:32 | FromDiscord | <spoon> if i were making something where mods were loaded on startup and could maybe be refreshed, wasm would probably be a good choice |
05:06:38 | FromDiscord | <spoon> just not for my use case |
05:07:03 | FromDiscord | <spoon> 'cause giving tons of options for languages sounds cool |
05:08:13 | FromDiscord | <Elegantbeef> Also solitude i see you're using owlkettle aswell, am i missing how to force focus on a widget or is it just non existent presently? |
05:18:14 | FromDiscord | <Solitude> i see that shitload of stuff is missing and owlkettle's approach is a mistake |
05:18:25 | FromDiscord | <Solitude> he really shoud've built it on top of gintro |
05:19:04 | FromDiscord | <Elegantbeef> yea i know nothing about gtk, so i just see the purdy declarative API |
05:19:11 | FromDiscord | <huantian> In reply to @spoon "that's gonna be rough": Wait why does reloading on file changes not work with enemy weapons? Just curious |
05:19:38 | FromDiscord | <Elegantbeef> Each weapon would need it's own interpreter i think is the issue |
05:19:54 | * | slowButPresent quit (Quit: leaving) |
05:43:28 | FromDiscord | <morgan> so i added an input called shared to a proc, and it got highlighted different and inspect tokens or whatever says invalid keyword, but it runs with no errors/warnings and has no error/warning squiggles |
05:43:47 | FromDiscord | <morgan> but it's not in the list of reserved keywords |
05:44:00 | FromDiscord | <Elegantbeef> Extension sounds wrong |
05:44:05 | FromDiscord | <morgan> ok |
05:45:06 | FromDiscord | <morgan> https://media.discordapp.net/attachments/371759389889003532/960414690532532254/unknown.png |
05:45:27 | FromDiscord | <Elegantbeef> oh wait `shared` |
05:46:23 | FromDiscord | <morgan> the manual only has one instance of `shared` and it's not related |
05:47:11 | FromDiscord | <Elegantbeef> Ah i was thinking of isolated |
05:49:14 | FromDiscord | <morgan> only interface and out are in the list of reserved keywords so i assume that's to warn people when they type one of those that it's not a keyword that's going to work, which seems like not highlighting it as a keyword would be better for |
05:59:36 | * | rockcavera joined #nim |
05:59:37 | * | rockcavera quit (Changing host) |
05:59:37 | * | rockcavera joined #nim |
06:03:07 | * | rockcavera quit (Remote host closed the connection) |
06:39:27 | * | acidsys quit (*.net *.split) |
06:39:27 | * | systemdsucks quit (*.net *.split) |
06:39:27 | * | adium quit (*.net *.split) |
06:39:27 | * | nisstyre quit (*.net *.split) |
06:39:27 | * | madprops quit (*.net *.split) |
06:39:28 | * | lain quit (*.net *.split) |
06:39:28 | * | dv^_^ quit (*.net *.split) |
06:39:39 | * | madprops joined #nim |
06:40:00 | * | nisstyre joined #nim |
06:40:05 | * | madprops quit (Changing host) |
06:40:05 | * | madprops joined #nim |
06:40:23 | * | lain joined #nim |
06:41:23 | * | adium joined #nim |
06:41:33 | FromDiscord | <creikey> Anybody care to review a small amount of nim networking code? I'm meaning for it to be an example in using std/net https://github.com/creikey/nim-net-chat-example |
06:41:59 | * | acidsys joined #nim |
06:43:11 | * | cornfeedhobo quit (*.net *.split) |
06:43:11 | * | ecs quit (*.net *.split) |
06:43:19 | * | ecs joined #nim |
06:44:42 | * | systemdsucks joined #nim |
06:46:08 | * | nisstyre quit (Quit: WeeChat 3.4) |
06:46:17 | * | nisstyre joined #nim |
06:49:51 | * | cornfeedhobo joined #nim |
06:50:04 | FromDiscord | <Attachment Aditya> hey! |
06:50:14 | FromDiscord | <Attachment Aditya> where can i like ask questions? |
06:50:27 | FromDiscord | <Elegantbeef> You just asked one so hopefully here |
06:50:35 | FromDiscord | <Attachment Aditya> hmm |
06:50:48 | FromDiscord | <Attachment Aditya> i mean i want to convert my python project to nim |
06:50:59 | FromDiscord | <Elegantbeef> Ask questions her |
06:51:01 | FromDiscord | <Elegantbeef> here\ |
06:53:24 | FromDiscord | <Attachment Aditya> i want to convert my big python project to a big nim project... how do i convert it? is there a cheatsheet that can help me easily? are there converters out there? what do i do to convert 1895 lines of code of python to nim? why is it so hard? https://media.discordapp.net/attachments/371759389889003532/960431876340854784/unknown.png |
06:53:48 | FromDiscord | <Elegantbeef> It's hard cause python doesnt have type annotations |
06:53:56 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers |
06:54:20 | FromDiscord | <Elegantbeef> There arent any converters that work on unannotated python |
06:54:41 | * | ltriant quit (Ping timeout: 246 seconds) |
06:55:01 | * | dv^_^ joined #nim |
06:55:17 | FromDiscord | <Attachment Aditya> In reply to @Elegantbeef "It's hard cause python": it has actually |
06:55:25 | FromDiscord | <Attachment Aditya> but that isn't compulsory to use |
06:55:36 | FromDiscord | <Elegantbeef> @creikey\: https://github.com/creikey/nim-net-chat-example/blob/main/src/server.nim#L47-L54 is a bit odd why not just iterate backwards |
06:55:36 | FromDiscord | <Elegantbeef> Yes i know it's optional |
06:55:37 | FromDiscord | <Attachment Aditya> the annotations are just like nim too... |
06:55:40 | FromDiscord | <Attachment Aditya> almost... |
06:55:49 | FromDiscord | <Elegantbeef> I know typings exist |
06:56:12 | FromDiscord | <xflywind> there are some old transpiler https://github.com/adsharma/py2many |
06:56:23 | FromDiscord | <Attachment Aditya> so is that cheatsheet you sent in the first link? |
06:56:32 | FromDiscord | <Attachment Aditya> In reply to @flywind "there are some old": oh, thanks. |
06:56:39 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/zf5 |
06:56:59 | FromDiscord | <Elegantbeef> If you have type annotations a transpiler may work |
06:57:10 | FromDiscord | <Elegantbeef> You will still have to touch it up and make it idiomatic though |
06:57:23 | FromDiscord | <Elegantbeef> Just cause nim has significant whitespace doesnt mean it's like python |
06:58:12 | FromDiscord | <Attachment Aditya> ik, but its still ok for me to use nim, the c experience was horrible to me... |
06:58:22 | * | PMunch joined #nim |
07:01:13 | FromDiscord | <Elegantbeef> Also @creikey https://github.com/creikey/nim-net-chat-example/blob/main/src/common.nim#L6-L13↵you there is https://nim-lang.org/docs/net.html#recv%2CSocket%2Cpointer%2Cint |
07:02:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/k3z |
07:02:32 | FromDiscord | <Elegantbeef> And perhaps ensure it's LE but dont recall if that's needed |
07:03:09 | FromDiscord | <Elegantbeef> Same with your `sendData` |
07:04:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3UfP |
07:04:16 | FromDiscord | <Elegantbeef> guess you want `data.len.uint32` |
07:07:14 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3UfQ |
07:09:08 | FromDiscord | <Elegantbeef> Well that looks like it aside from "import system modules with `std/` prefix and group them in an array like `std/[net, common]` |
07:13:52 | * | gsalazar joined #nim |
07:23:17 | * | ltriant joined #nim |
07:57:11 | FromDiscord | <aph> `enum` vs `object`, which one should i use |
07:57:26 | PMunch | It totally depends on what you're doing |
07:57:31 | FromDiscord | <Elegantbeef> Do you need values or a data object |
07:57:34 | PMunch | They're not comparable in any way |
07:57:55 | FromDiscord | <Elegantbeef> They are if you squint |
07:58:07 | FromDiscord | <Elegantbeef> `type A = object` can look a lot like `type A = enum` |
07:58:29 | PMunch | Eh, fair enough |
07:58:30 | FromDiscord | <aph> In reply to @Elegantbeef "Do you need values": ehhh im not sure what i want |
07:58:33 | FromDiscord | <aph> lol |
07:58:43 | FromDiscord | <Elegantbeef> Well what are you doing |
07:58:48 | FromDiscord | <Elegantbeef> There has to be a reason to ask this |
07:58:54 | FromDiscord | <Elegantbeef> It's like asking bool or float |
07:58:55 | FromDiscord | <aph> In reply to @Elegantbeef "Well what are you": storing info of file header |
07:59:05 | FromDiscord | <aph> the type is the same everytime |
07:59:07 | FromDiscord | <Elegantbeef> So then a object |
07:59:10 | FromDiscord | <aph> okk |
07:59:12 | FromDiscord | <aph> tyy |
07:59:32 | FromDiscord | <Elegantbeef> Oh have you used Java/Rust enums? |
07:59:50 | FromDiscord | <aph> i have never used enums |
08:00:06 | FromDiscord | <Elegantbeef> In Nim enums are just named integers, with optional string names |
08:00:20 | FromDiscord | <aph> ohh |
08:00:22 | PMunch | You want to use enums instead of a lot of constant variables |
08:00:23 | FromDiscord | <Elegantbeef> You use them for flags, states and anything that's a fixed set of named values |
08:00:52 | FromDiscord | <aph> ohh |
08:00:58 | FromDiscord | <aph> i've been using `const` so long |
08:00:59 | FromDiscord | <aph> lol |
08:01:21 | FromDiscord | <Elegantbeef> Eh it's fine, depends what you're holding onto |
08:01:47 | FromDiscord | <Elegantbeef> In a 4 direction game you might use an enum for `North, East, South, West` |
08:02:14 | FromDiscord | <aph> heh i'm not fixing my dirty codebase |
08:02:17 | FromDiscord | <Elegantbeef> Also if you're passing a group of bools you can use enums instead |
08:02:34 | FromDiscord | <aph> will keep in note! |
08:02:57 | FromDiscord | <Elegantbeef> `proc doThing(doItFast, doItWeird, doItFunny, doitDumb: bool)` |
08:03:45 | FromDiscord | <aph> i didn't know that such thing exists |
08:04:08 | FromDiscord | <aph> i'm doing `doItFast: bool, doItWeird: bool, doItFunny: bool, doItDumb: bool` |
08:04:15 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Ug0 |
08:04:25 | FromDiscord | <aph> ohh, that's cool |
08:04:31 | FromDiscord | <Elegantbeef> then you can do `doThing({diFast, d iDumb}` |
08:07:51 | FromDiscord | <aph> wait, what happens to `diFunny` or `diWeird` |
08:09:10 | FromDiscord | <Rika> Not set |
08:10:03 | FromDiscord | <aph> hmm, like `void`? |
08:10:19 | FromDiscord | <aph> (edit) "`void`?" => "`nil`?" |
08:14:01 | FromDiscord | <Rika> no |
08:14:03 | FromDiscord | <Rika> like `false` |
08:14:27 | FromDiscord | <Rika> `doThing(true, false, false, true)` |
08:35:27 | FromDiscord | <aph> ohh, ty |
08:37:51 | FromDiscord | <Elegantbeef> Its a more clear and more friendly way to write passing of flags |
08:56:42 | * | jmdaemon quit (Ping timeout: 260 seconds) |
09:03:40 | * | adium quit (Ping timeout: 272 seconds) |
09:15:02 | * | ltriant quit (Ping timeout: 246 seconds) |
09:25:34 | * | ltriant joined #nim |
10:02:13 | FromDiscord | <exelotl> yooo nice to see Generic's GC emulator in the monthly post |
10:08:49 | FromDiscord | <ajusa> Yeah the macro writeup was super interesting |
10:12:54 | * | adium joined #nim |
10:15:29 | PMunch | I was actually thinking of maybe doing a podcast for these monthly posts |
10:19:28 | FromDiscord | <Rika> what kind of podcast, a live one? |
10:19:39 | FromDiscord | <Rika> or those which are recorded and then edited? |
10:21:30 | PMunch | The thought was an edited one |
10:22:22 | PMunch | Find a "guest" possibly one of the ones who have a library in the list, and then talk about the different entries, and possibly other stuff that's been going on with Nim for the past month |
10:31:17 | FromDiscord | <ajusa> Personally I prefer writeups, but hey if there's demand a podcast sounds cool |
11:49:40 | * | Gustavo6046 joined #nim |
11:56:20 | * | jjido joined #nim |
12:06:02 | FromDiscord | <mratsim> podcast for programming? Do they stay high-level, I can't fathom how you can discuss concrete code without showing it. |
12:10:56 | PMunch | Oh yeah, it would be a totally high-level thing |
12:11:12 | FromDiscord | <Tanguy> You can spell it |
12:11:34 | PMunch | More talking about the new projects people write, the new libraries, etc. |
12:12:06 | FromDiscord | <Tanguy> (edit) "spell" => "read" | "readit ... " added "aloud" |
12:12:29 | PMunch | I'm not going to be sat there going "indentation level 4, for i in x, dot, keys, colon, newline, indentation level 5" |
12:14:42 | FromDiscord | <Tanguy> Just do it ASMR style |
12:17:08 | FromDiscord | <Phil> Brain storm a concept to elegantly and beautifully make something that is as flexible and as extensible as Djangos object oriented views, I would love to steal whatever is drawn up, thank |
12:17:33 | FromDiscord | <Phil> (edit) "views," => "views in one of the podcast episodes," |
12:25:49 | FromDiscord | <mratsim> > object oriented↵↵You lost me there. |
12:31:09 | * | vicecea quit (Remote host closed the connection) |
12:31:38 | * | vicecea joined #nim |
12:39:48 | FromDiscord | <riplooke> Does Nim have a Wayland api |
12:42:27 | FromDiscord | <Solitude> https://github.com/yglukhov/wayland here is something, you figure out how it works |
12:43:08 | FromDiscord | <riplooke> Ok |
12:43:53 | FromDiscord | <riplooke> I like the ||lack of||documentation for it 😂 |
12:43:59 | FromDiscord | <riplooke> (edit) "of||documentation" => "of|| documentation" |
12:50:53 | PMunch | @Phil, I have an idea for a type oriented web-api |
12:51:17 | FromDiscord | <Phil> In reply to @mratsim "> object oriented ": Doesn't have to be oo, preferably isn't, just want that level of extensibility |
12:51:22 | PMunch | Essentially treating routes as procedures, with a strict typed set of arguments and return type |
12:52:55 | FromDiscord | <Phil> Yeh but does it provide a default implementation in which I can change around individual aspects? |
13:02:40 | FromDiscord | <Phil> Though I think... Hmmm you could solve this with a proc that accepts a ton of procs as parameters that contains default arguments |
13:12:51 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
13:12:54 | PMunch | A default implementation? |
13:12:58 | PMunch | Not sure what you mean |
13:18:03 | FromDiscord | <riplooke> Can I use gnu make (and a makefile) to compile nim |
13:18:27 | FromDiscord | <Rika> Sure, why not |
13:18:53 | FromDiscord | <Rika> A makefile is almost basically a shell script anyway |
13:19:14 | PMunch | Yeah, I've used Makefiles a lot for building Nim |
13:20:24 | * | slowButPresent joined #nim |
13:28:30 | arkanoid | I need an idea to implement a disk based concurrent queue. A producer fills the queue, a consumer empty it and pushes to the network. If push fails, data must persist to the queue until success (or out of space) |
13:28:57 | arkanoid | Is there an existing solution to reliably implement this? |
13:29:39 | * | arkurious joined #nim |
13:30:17 | arkanoid | I was thinking about using sqlite but we have multiple writers here so its not the best thing |
13:32:31 | FromDiscord | <Rika> Is there a priority to performance? |
13:34:30 | arkanoid | Rika, no, the most important thing is never lose data |
13:35:04 | PMunch | arkanoid, I've recently done something similar |
13:35:14 | PMunch | Basically what I ended up with was a simple journaling system |
13:35:18 | FromDiscord | <Rika> I was going to suggest using directories (per writer) and files (per message) and monotonic counters and stuff |
13:35:45 | FromDiscord | <Rika> Yeah that works too, append only log |
13:36:37 | PMunch | My program is essentially a relay, it receives messages on HTTP, and sends them on with a proprietary protocol |
13:36:41 | arkanoid | Rika the problem with files is the amount of them. I have very small buffers to queue, if I produce a file per buffer I'd ed up with a very difficult situation to list files |
13:37:36 | arkanoid | PMunch: why you think Journaling is required? |
13:37:51 | FromDiscord | <Rika> That’s for performance I believe |
13:38:03 | * | rockcavera joined #nim |
13:38:03 | * | rockcavera quit (Changing host) |
13:38:03 | * | rockcavera joined #nim |
13:38:04 | arkanoid | I mean, I just need to assure that the network push is successful, then I can delete the entry |
13:38:12 | PMunch | To ensure that if my program crashes every message that has been received and returned 200 OK will eventually be ent |
13:38:17 | FromDiscord | <Rika> The quicker you can write something the less likely that if you crash you’ll lose something haha |
13:38:35 | PMunch | They are written into the journal but only read from the journal on start-up |
13:39:10 | FromDiscord | <Rika> You could probably also make a “clean up” stage that does deletes from the log, if you’re sure it’s sent already |
13:39:44 | PMunch | So when I receive a message I write a "new message" flag and the message to a journal file, if I've written more than 100 entries to that journal file I create a new one. Then I put it into some internal data-structures (and keeping track of which journal it lives in). Then when I manage to pass it on I write a "message sent flag" and the GUID of the task. If this was the 100th message completed in this journal file I delete the journal file. |
13:40:47 | PMunch | This means that if I have accepted a message and then crash (or the computer is shut of or whatever) my program will read the journal during startup, figure out which tasks where accepted but never completed, and start working through them. |
13:41:11 | PMunch | I actually considered writing a small Nim library for this |
13:41:42 | FromDiscord | <Rika> I mean it’s just technically a structured log file |
13:41:54 | PMunch | Well yes, that's what a journal is |
13:49:24 | FromDiscord | <Zoom> My knee-jerk reaction would be to try to utilize a loop device with some journaling fs to store the messages and unload all the hard work on the os↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
13:52:19 | arkanoid | PMunch: what's the advantage of your solution over sqlite? |
13:52:50 | arkanoid | Sqlite has journaling, but also write ahead log that's even more resilient |
13:53:10 | arkanoid | And it supports multiple writers thanks to locking. And is also very battle tested |
13:53:38 | FromDiscord | <Rika> I thought you didn’t want to use that? |
13:54:49 | arkanoid | I said that multiple writers to same sqlite is not the best thing, not that I don't want to use it |
13:54:57 | PMunch | arkanoid, I used sqlite at first, but it was too slow |
13:55:02 | PMunch | And it kept locking up |
13:55:37 | arkanoid | PMunch: ok |
13:55:43 | PMunch | To be fair I used it fully as a database, with all my logic going through sqlite |
13:56:20 | PMunch | My new system basically just uses journaling, and then it does all the sqlite/database stuff with other structures in memory |
13:57:16 | PMunch | But since I didn't need any of the relational stuff or other fancy features sqlite offers it was a bit overkill and as I said didn't meet my performance criteria |
14:46:28 | * | v9fk joined #nim |
15:09:52 | * | v9fk quit (Quit: Goodbye!) |
15:23:32 | PMunch | Hmm, is there a way I can check if a value will be possible to put in a const block? |
15:24:30 | PMunch | Something like `when isCompileTime` |
15:32:44 | FromDiscord | <Yardanico> I guess one way you can do it is by using `compiles` :P |
15:33:03 | PMunch | I tried, but it doesn't like `when compiles(const x = something)` |
15:33:17 | PMunch | Error: expression expected, but found 'keyword const' |
15:34:46 | FromDiscord | <Yardanico> ah right, you need to make it an expression |
15:35:15 | FromDiscord | <Yardanico> you can just add () around it to make it an statement list expression |
15:35:22 | FromDiscord | <Yardanico> `when compiles((const x = stuff)):` |
15:38:08 | PMunch | Hmm, that seems to work |
15:38:18 | PMunch | But now I get a -1 not in 0..0 error |
15:38:24 | PMunch | But it doesn't say where it comes from.. |
15:38:29 | PMunch | I guess it might be the compiler |
15:43:40 | FromDiscord | <huantian> In reply to @Yardanico "you can just add": Wait you can do that? I just used a template lmao |
15:44:53 | FromDiscord | <gerwy> quick question↵i know its possible with tuples i think, that i can access its stuff with index like `[0]`↵but can i do the same for objects? How would i access the field if i don't know which name its gonna have? |
15:45:11 | FromDiscord | <gerwy> other way than using iterators of course |
15:45:41 | FromDiscord | <Rika> no |
15:45:59 | FromDiscord | <gerwy> :C |
15:46:32 | FromDiscord | <Vindaar> for what unholy purpose would you not know the field names of the object? |
15:46:54 | FromDiscord | <Vindaar> you _could_ write a macro for that. but... I'm not sure that's the best idea |
15:47:14 | FromDiscord | <Rika> well you could |
15:47:15 | FromDiscord | <gerwy> tagged union |
15:47:20 | FromDiscord | <Rika> i dont think its too bad with a ma |
15:47:29 | FromDiscord | <Rika> macro |
15:47:49 | FromDiscord | <Rika> In reply to @Life Sucks "tagged union": what? |
15:49:51 | FromDiscord | <gerwy> fieldPairs work |
15:50:05 | FromDiscord | <gerwy> and its in two lines of code so :// |
15:50:26 | FromDiscord | <gerwy> In reply to @Rika "what?": i have `Value` object that uses tagged union for expression evaluation |
15:50:33 | FromDiscord | <Yardanico> any reason you're not using object variants instead? |
15:50:40 | FromDiscord | <gerwy> In reply to @Yardanico "any reason you're not": thats exactly what i do |
15:50:44 | FromDiscord | <Yardanico> ?? |
15:50:46 | FromDiscord | <gerwy> i forgor how its called in nim 💀 |
15:50:59 | FromDiscord | <gerwy> you mean `case .. of` ? |
15:51:01 | FromDiscord | <Yardanico> yes |
15:51:05 | FromDiscord | <gerwy> (edit) "?" => " in object declaration?" |
15:51:08 | FromDiscord | <gerwy> (edit) "declaration?" => "definition?" |
15:51:12 | FromDiscord | <gerwy> yeah thats what i do |
15:51:17 | FromDiscord | <Rika> field pairs works with object variants? |
15:51:48 | FromDiscord | <Yardanico> i don't think so? |
15:51:49 | FromDiscord | <Yardanico> https://github.com/nim-lang/RFCs/issues/367 |
15:51:51 | FromDiscord | <Yardanico> is open |
15:53:14 | PMunch | Huh, apparently you can do `when is static`, that's handy |
15:54:04 | FromDiscord | <Yardanico> huh, but won't that only apply to variables that are `const` and won't work for expressions that can be computed at compile-time? |
15:54:09 | FromDiscord | <Yardanico> ah nvm, apparently it works for stuff like 1 + 5 too |
15:54:13 | FromDiscord | <Yardanico> interesting |
15:58:42 | FromDiscord | <gerwy> In reply to @Rika "field pairs works with": works for me idk |
15:58:50 | FromDiscord | <gerwy> In reply to @PMunch "Huh, apparently you can": oh yeah, i use when :3 |
15:58:57 | FromDiscord | <gerwy> (edit) "when" => "`when`" | "`when`:3 ... " added "maybe thats why" |
15:59:10 | PMunch | Huh? |
15:59:23 | PMunch | I was talking about an issue I had |
16:00:33 | FromDiscord | <gerwy> oh sorry |
16:00:44 | PMunch | Argh, this unhandled exception is really annoying.. |
16:00:47 | FromDiscord | <gerwy> i was talking about fields with object variants |
16:01:05 | FromDiscord | <Yardanico> @PMunch if you installed the compiler with build_all you also should have nim_temp |
16:01:13 | PMunch | nim_temp? |
16:01:14 | FromDiscord | <Yardanico> or was it nim_debug |
16:01:24 | FromDiscord | <Yardanico> nim-dbg |
16:01:26 | FromDiscord | <Yardanico> arghh |
16:01:28 | FromDiscord | <Yardanico> nim_dbg |
16:01:31 | FromDiscord | <Yardanico> debug build of the compiler |
16:01:35 | FromDiscord | <Yardanico> with stacktrace and all that stuff on |
16:01:40 | FromDiscord | <Yardanico> so at least you'll know where it crashes |
16:02:05 | FromDiscord | <Yardanico> actually it's built by `koch tools` |
16:07:27 | PMunch | Ah right, that helped |
16:07:45 | PMunch | So apparently this crashes the compiler: https://play.nim-lang.org/#ix=3Uil |
16:11:18 | FromDiscord | <Phil> In reply to @PMunch "A default implementation?": I was mentally again at fully generic handler-procs (as prologue calls them) aka controller procs.↵If the framework is very opinionated, you could provide an entire handler that is associated with the route and that can be adjusted by passing custom procs as parameter for fetching a given entry from the database, for checking permissions a user may have on that entry etc. |
16:12:37 | FromDiscord | <Phil> E.g. if the request is "put", then demand that there must be an ID-param or a custom-provided "fetch entry from database" proc and the default handler provided will automatically be for carrying out an update of sorts, so it'll check for update permissions and execute the correct SQL for that for you and and and |
16:31:58 | * | nixpica_ joined #nim |
16:31:58 | * | nixpica joined #nim |
16:32:11 | * | nixpica quit (Client Quit) |
16:34:54 | * | noxnivi joined #nim |
16:34:58 | * | nixpica_ quit (Client Quit) |
17:04:56 | * | noxnivi quit (Quit: Leaving) |
17:06:44 | * | jjido joined #nim |
17:12:00 | FromDiscord | <salt> i've seen this hack of mimicking oo with closures in python, maybe you can do something like that in nim, i'd have to look for it |
17:15:20 | FromDiscord | <salt> this is pretty old stuff: https://code.activestate.com/recipes/578091/ -- am not sure how one can use it with nim |
17:17:00 | FromDiscord | <Rika> streams in the nim stdlib uses this "kind of oop" |
17:19:07 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=3UiF |
17:21:43 | FromDiscord | <salt> that's interesting |
17:22:59 | FromDiscord | <Phil> The end result doesn't look.... great but, well, functional I guess |
17:23:33 | FromDiscord | <Phil> `createReadHandler[ReadDiaryEntryParams, DiaryEntryRead, DiaryEntrySerializable](getDiaryEntry, checkReadPermission, serializeDiaryEntryRead)` |
17:27:36 | FromDiscord | <Phil> Fun fact, trying to provide default values for the generic parameters of generic procs is a terrible idea |
17:27:43 | FromDiscord | <Phil> (edit) removed "the" |
17:28:27 | FromDiscord | <Phil> I did not realize it at the time, but that essentially locks your typing down again, because now everything you provide instead of the default must match the type-signature of your default value again |
17:29:05 | FromDiscord | <gerwy> so umm, i kinda have no idea how to make macros in nim heh |
17:29:22 | FromDiscord | <Phil> That makes two of us, what are you trying to do? Maybe you can solve it with generics or templates |
17:29:45 | FromDiscord | <gerwy> sent a code paste, see https://play.nim-lang.org/#ix=3UiG |
17:30:14 | FromDiscord | <Phil> Is there a specific reason why you want to express this as a macro when you can express it in normal syntax? |
17:30:19 | FromDiscord | <gerwy> basically, its what i talked about earlier when getting second field in object variant |
17:30:37 | FromDiscord | <gerwy> In reply to @Isofruit "Is there a specific": the point is that i can't lol |
17:31:12 | FromDiscord | <Phil> I mean, the only thing that changes is what type "arg" is, right? |
17:31:19 | FromDiscord | <gerwy> yeah but |
17:31:37 | FromDiscord | <gerwy> sent a code paste, see https://play.nim-lang.org/#ix=3UiH |
17:32:05 | FromDiscord | <Phil> I might be missing this if you tried it already. Would a generic work instead? |
17:32:06 | FromDiscord | <gerwy> (edit) "https://play.nim-lang.org/#ix=3UiH" => "https://play.nim-lang.org/#ix=3UiI" |
17:32:46 | FromDiscord | <gerwy> idk, wait actually i should try to compile it because it just assume won't work from lsp showing error but it might be wrong |
17:33:06 | FromDiscord | <Phil> Ohhh wait, you don't know what type it'll spit out at the end do you |
17:33:20 | FromDiscord | <gerwy> nope it tells me `type mismatch: got <NimNode>` |
17:34:17 | FromDiscord | <Phil> More as in, you don't know the data-type of the first field in `arg` that is not called "typ", correct?↵Could be string, int, whatever |
17:36:02 | FromDiscord | <gerwy> i know the first field, its gonna be enum of what type the value is↵i just can't get second field since they have different names |
17:36:28 | FromDiscord | <gerwy> In reply to @Isofruit "More as in, you": object arg, has field `typ` which is enum and some field of value that has whatever the type |
17:39:44 | FromDiscord | <Phil> Could you give me your "Value" type definition? |
17:40:01 | FromDiscord | <Phil> Playing around a bit, I'm fairly sure you don't need a macro, a generic should do with this |
17:41:09 | * | vicfred quit (Quit: Leaving) |
17:41:56 | FromDiscord | <Rika> yikes, im wondering if this is way too long of an import path for a module https://media.discordapp.net/attachments/371759389889003532/960595084804517888/unknown.png |
17:42:08 | FromDiscord | <ShalokShalom> https://nim-lang.github.io/Nim/manual_experimental.html#void-type↵↵What is the difference between void and auto? |
17:42:28 | FromDiscord | <Rika> void means no return type, at all |
17:42:42 | FromDiscord | <Rika> auto means "please infer what the type should be for me, compiler" |
17:42:48 | FromDiscord | <Rika> at least to my understanding, that is |
17:43:00 | FromDiscord | <Phil> In reply to @Life Sucks "object arg, has field": Nevermind, worked it out |
17:43:05 | FromDiscord | <ShalokShalom> Thanks |
17:43:17 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=3UiL |
17:43:18 | FromDiscord | <ShalokShalom> Somebody told me, that auto means also 'any type' |
17:43:46 | FromDiscord | <Rika> technically, yeah |
17:44:09 | FromDiscord | <gerwy> sent a code paste, see https://play.nim-lang.org/#ix=3UiN |
17:44:18 | FromDiscord | <Rika> you can pass any type to the proc, and expect it to not error out because of a type mismatch at the proc signature |
17:44:27 | FromDiscord | <Rika> it can still type mismatch in the body, though |
17:44:30 | FromDiscord | <Phil> In reply to @Life Sucks "hmm looks cool i": "R" is a generic type, it's a placeholder for "Whatever the programmer defines is R" |
17:44:41 | FromDiscord | <ShalokShalom> That sounds confusing |
17:44:48 | FromDiscord | <Phil> That's why there's the `[]` in front of the proc |
17:45:13 | FromDiscord | <ShalokShalom> So it is essentially NOT any type |
17:45:16 | FromDiscord | <ShalokShalom> Just in theory |
17:45:17 | FromDiscord | <Phil> So you define what types `T` and `R` in this particular usage of `get_val` represent |
17:45:19 | FromDiscord | <Rika> im not sure what you mean |
17:45:23 | FromDiscord | <ShalokShalom> And that theory doesnt matter |
17:45:27 | FromDiscord | <gerwy> oh hmm, well that makes sense, but what if i don't know its type? |
17:45:30 | FromDiscord | <Phil> I think shalok is not talking about my generic stuff |
17:45:30 | FromDiscord | <ShalokShalom> Well, I try to understand the difference |
17:45:31 | FromDiscord | <Rika> ah yeah it would still error on compile time if types dont match |
17:45:34 | FromDiscord | <Rika> somewhere in the body |
17:45:44 | FromDiscord | <ShalokShalom> yeah, thats what I mean |
17:45:47 | FromDiscord | <gerwy> do i really need to have few if's just to get that thing? |
17:46:04 | FromDiscord | <gerwy> i can't do like `typeof` since i can't reach second field without knowing its name |
17:46:07 | FromDiscord | <ShalokShalom> So the fact that it doesnt error in the type declaration is completely irrelevant |
17:46:15 | FromDiscord | <Rika> it's equivalent to using an explicit generic with no restriction, i believe |
17:46:20 | FromDiscord | <Phil> In reply to @Life Sucks "oh hmm, well that": If you don't know the type, that means you have several options for T again, at which point the proc that uses this proc likely should also be a generic |
17:46:37 | FromDiscord | <gerwy> hmm okay i will give it a try maybe |
17:46:45 | FromDiscord | <Rika> so `proc p[T](a: T)` and `proc p(a: auto)` i believe are similar or the same |
17:47:37 | FromDiscord | <gerwy> but im also thinking↵macro in nim can get properties of what im giving to it right?↵can't it just like ↵`echo get_value(p)` and its gonna return `p.int_value` if its int or `p.float_value` if its float? |
17:47:40 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
17:47:49 | FromDiscord | <gerwy> just return the parameter name with dot and the second field? |
17:47:57 | FromDiscord | <gerwy> that should be doable maybe? |
17:48:02 | FromDiscord | <gerwy> but i will try the Phil way first |
17:48:10 | FromDiscord | <ShalokShalom> So auto returns a type, void does not |
17:48:31 | FromDiscord | <Rika> i guess thats one way to put it |
17:48:35 | FromDiscord | <ShalokShalom> I would it welcome, if the documentation mentions similar techniques |
17:48:48 | FromDiscord | <ShalokShalom> Like, mention auto at the place of void and vice versa |
17:48:55 | FromDiscord | <Rika> it might have just been written in a different way that you didnt understand |
17:49:14 | FromDiscord | <Phil> In reply to @Life Sucks "that should be doable": I generally recommend to look for solutions in the following order:↵generics > templates > macros↵generics are imo always easier to grasp in what they do than templates, which in turn are a fair bit easier to grasp and maintain than macros |
17:49:19 | FromDiscord | <Rika> to me, auto and void are extremely clear and didnt need explanation even as a beginner, but eh |
17:49:57 | FromDiscord | <ShalokShalom> Also like cmd and all the 3748 similar concepts |
17:50:17 | FromDiscord | <gerwy> In reply to @Isofruit "I generally recommend to": `Error: cannot instantiate: 'R'` heh |
17:50:27 | FromDiscord | <Generic> In reply to @Isofruit "I generally recommend to": don't forget generic macros and generic templates 😛 |
17:50:28 | FromDiscord | <Phil> I'd need to see your code there |
17:50:40 | FromDiscord | <Phil> In reply to @Generic "don't forget generic macros": Do not speak in cursed tongue to me! |
17:50:45 | FromDiscord | <gerwy> In reply to @Life Sucks "`Error: cannot instantiate: 'R'`": either that or ↵`Error: type mismatch: got 'int64' for 'arg.int_value' but expected 'string'` |
17:50:57 | FromDiscord | <fs> is there any reason to explicitly state void as a type instead of just leaving the return type empty? |
17:51:01 | FromDiscord | <Rika> In reply to @Isofruit "Do not speak in": generic concepts |
17:51:07 | FromDiscord | <fs> (edit) "is there any reason to explicitly state void as a ... type" added "return" |
17:51:12 | FromDiscord | <Rika> In reply to @fs "is there any reason": not really, pretty much if you'd like |
17:51:17 | FromDiscord | <gerwy> also your example works on inherited field↵im using object variant |
17:51:19 | FromDiscord | <Rika> theyre useful for generics |
17:51:38 | FromDiscord | <ShalokShalom> In reply to @Rika "to me, auto and": Well, you are not a beginner |
17:51:40 | FromDiscord | <Rika> `proc p[T](): T` that you pass a `void` as `T` |
17:51:45 | FromDiscord | <Rika> In reply to @ShalokShalom "Well, you are not": i was one |
17:51:50 | FromDiscord | <Rika> i never thought of it |
17:51:51 | FromDiscord | <Phil> In reply to @Rika "generic concepts": Somebody get me some holy water, I've got demons to exorcise |
17:51:53 | FromDiscord | <ShalokShalom> Its pretty easy to see, whats nice to a beginner, by being a beginner |
17:51:55 | FromDiscord | <ShalokShalom> Vice versa |
17:52:05 | FromDiscord | <Rika> i will not have this conversation again |
17:52:32 | FromDiscord | <Rika> In reply to @Isofruit "Somebody get me some": lol |
17:52:44 | FromDiscord | <ShalokShalom> In reply to @Rika "i never thought of": Void is experimental |
17:52:55 | FromDiscord | <Rika> i. am. not. having. this. again. |
17:53:02 | FromDiscord | <ShalokShalom> How were you a beginner |
17:53:04 | FromDiscord | <Rika> end of conversation with me, discuss it with someone else |
17:53:08 | FromDiscord | <Rika> good bye |
17:53:09 | FromDiscord | <Phil> Shalok, stop it. |
17:53:24 | FromDiscord | <ShalokShalom> 🙄 |
17:53:28 | FromDiscord | <Rika> call me ignorant all you want or whatever, i'm done with you |
17:53:41 | FromDiscord | <ShalokShalom> I call you dismissive |
17:53:42 | FromDiscord | <Phil> I was there the last time we debated for an hour or so whether things should be capable of being inferred 100% |
17:53:53 | FromDiscord | <Rika> see you elsewhere 🙂 |
17:53:53 | FromDiscord | <ShalokShalom> That's not the point |
17:54:04 | FromDiscord | <gerwy> In reply to @Isofruit "I'd need to see": literally no code, i just copied your example and used it like you |
17:54:30 | FromDiscord | <ShalokShalom> I just say 'this is helpful' and instead of accepting it, my opinion is put down with the pseudo argument 'I dont need it' |
17:54:34 | FromDiscord | <gerwy> thats how Value object looks like https://media.discordapp.net/attachments/371759389889003532/960598267312365568/unknown.png |
17:54:39 | FromDiscord | <ShalokShalom> And 'you are dumb for doing so' |
17:54:48 | FromDiscord | <Rika> you're putting words in my mouth |
17:54:49 | FromDiscord | <ShalokShalom> That's extremely abusive. |
17:54:54 | FromDiscord | <Phil> Okay, could you guys move this to offtopic |
17:54:54 | FromDiscord | <Rika> i said i never thought of it |
17:54:59 | FromDiscord | <ShalokShalom> That's exactly what you convey. |
17:54:59 | FromDiscord | <Rika> i will not continue |
17:55:18 | FromDiscord | <Rika> In reply to @ShalokShalom "That's exactly what you": it is your assumption |
17:55:19 | FromDiscord | <Phil> I'd like to check out gerwy's point where I mistook his original issue to be about inheritance instead of object variants |
17:55:57 | FromDiscord | <gerwy> no, its object variant |
17:56:03 | FromDiscord | <Rika> thats what phil did say |
17:56:19 | FromDiscord | <Phil> It was my mistake that I thought it were about inheritance |
17:56:26 | FromDiscord | <gerwy> and i need to get the second field↵i know that its already possible with fieldPairs but i don't want to type it every time i need to access it... |
17:56:32 | FromDiscord | <Phil> Maybe badly expressed on my end, I'm playing about with object variant atm |
17:56:37 | FromDiscord | <gerwy> In reply to @Isofruit "It was my mistake": It's okay! i still appreciate help<3 |
17:56:55 | FromDiscord | <Rika> what are you trying to do again |
17:57:31 | FromDiscord | <Phil> Essentially a getter on an object variant that gives you the filled in field without complaining |
17:57:45 | FromDiscord | <Rika> oh good luck you're not getting that |
17:58:01 | FromDiscord | <Phil> You coooouuuuuuld just write a normal proc for that |
17:58:08 | FromDiscord | <Rika> its the "return type can differ depending on a runtime value" thing |
17:58:10 | FromDiscord | <Phil> With a switch case in it |
17:58:19 | FromDiscord | <Rika> which is just, no |
17:58:37 | FromDiscord | <Phil> Wait, no, I'm an idiot, then you still don't have the type |
17:58:38 | FromDiscord | <Phil> gnaaaa |
17:58:40 | FromDiscord | <Rika> the fix is to.... use an object variant, which is just the same thing |
17:58:46 | FromDiscord | <Rika> back to square one so |
17:58:50 | FromDiscord | <Rika> nope, you just dont here |
17:58:52 | FromDiscord | <Phil> It's object variants all the way down |
17:58:56 | FromDiscord | <Rika> template if you want |
17:59:05 | FromDiscord | <Rika> prolly? |
17:59:16 | FromDiscord | <Rika> im not sure, ive never used this but i think its prolly possible |
17:59:46 | FromDiscord | <Phil> I mean, you run into trouble every time |
17:59:53 | FromDiscord | <Rika> nop |
17:59:54 | FromDiscord | <Phil> Because the variable you put your stuff in has to know what type it is |
17:59:56 | FromDiscord | <Rika> nope |
17:59:58 | FromDiscord | <Rika> you cant do this at all |
18:00:04 | FromDiscord | <Rika> manually only |
18:00:12 | FromDiscord | <Rika> i forget easily |
18:00:12 | FromDiscord | <Phil> And with an object variant you don't necessarily know what value your type is |
18:00:25 | FromDiscord | <Phil> (edit) "And with an object variant you don't necessarily know what value your ... type" added "output" |
18:00:38 | FromDiscord | <gerwy> In reply to @Rika "oh good luck you're": im very sure that it can be done easily in macros but macros in Nim are a bit weird and wacky |
18:00:42 | FromDiscord | <Rika> no |
18:00:45 | FromDiscord | <Rika> you cant |
18:01:00 | FromDiscord | <gerwy> but i just need to add it to code |
18:01:01 | FromDiscord | <Rika> return type based on runtime value is impossible without type elision i believe? |
18:01:08 | FromDiscord | <Rika> no matter what |
18:01:16 | FromDiscord | <Rika> macro, template, no not possible |
18:01:27 | FromDiscord | <Rika> i'm pretty confident its not |
18:01:35 | FromDiscord | <gerwy> i know what type its gonna be, i have an enum that says it, it shows me what type the value is that its holding↵i just can't access it manually typing the field |
18:01:38 | FromDiscord | <fs> macros only act in compile time |
18:01:46 | FromDiscord | <Rika> you dont know what it is on compile time |
18:01:54 | FromDiscord | <Rika> it must be known on compile time |
18:01:56 | FromDiscord | <Rika> therefore |
18:02:00 | FromDiscord | <Phil> Could you show me the context in which you're trying to have this proc? |
18:02:07 | FromDiscord | <fs> (edit) "macros" => "macro magic" | "act" => "acts" |
18:02:18 | FromDiscord | <Phil> I want to be doubly sure I'm not misunderstanding you there |
18:02:33 | FromDiscord | <Rika> okay wait |
18:02:34 | FromDiscord | <gerwy> sent a code paste, see https://paste.rs/8lm |
18:02:44 | FromDiscord | <Rika> wait wait i think i can think of a thing that MIGHT work |
18:03:16 | FromDiscord | <gerwy> think fast |
18:03:33 | FromDiscord | <Rika> i cant make code as quick as a certain type of meat here can |
18:04:13 | FromDiscord | <Phil> Question,if you do `let x = get_value(myValue)` do you always know at compile time what type x is going to be? |
18:05:00 | FromDiscord | <Phil> (that was directed at gerwy) |
18:05:26 | FromDiscord | <Rika> this might work |
18:05:27 | FromDiscord | <Rika> im not sure |
18:05:29 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=3UiT |
18:05:48 | FromDiscord | <Rika> yes the exception is required |
18:06:19 | FromDiscord | <Rika> also no its just a proof of concept, you might need to promote this into a macro for parts |
18:06:26 | FromDiscord | <Rika> (edit) "also no its just a proof of concept, you might need to promote this into a macro for ... partsto" added "the enum and field" | "the enum and fieldparts ... " added "to work" |
18:06:50 | FromDiscord | <Rika> usage would be like `v.value(int)` or something like that |
18:06:57 | FromDiscord | <Phil> In reply to @fs "is there any reason": I... err... can't think of anything tbh |
18:06:59 | FromDiscord | <Rika> which is still pretty bad, but you can use generics here |
18:07:07 | FromDiscord | <Rika> `v.value(T)` if you have a T generic type |
18:07:18 | FromDiscord | <gerwy> In reply to @Isofruit "Question,if you do `let": compile time, not sure, but runtime yeah you will know |
18:07:23 | FromDiscord | <Rika> if this is still pretty bad then idk what you want lol |
18:07:28 | FromDiscord | <Rika> its just an idea |
18:07:31 | FromDiscord | <Rika> its three am |
18:07:35 | FromDiscord | <Rika> give me a break xdddddd |
18:07:36 | FromDiscord | <Phil> In reply to @Life Sucks "compile time, not sure,": Runtime isn't good enough sadly... I think |
18:08:12 | FromDiscord | <gerwy> sent a code paste, see https://play.nim-lang.org/#ix=3UiV |
18:08:17 | FromDiscord | <Rika> no |
18:08:21 | FromDiscord | <gerwy> D: |
18:08:21 | FromDiscord | <Rika> procs cannot be untyped |
18:08:24 | FromDiscord | <gerwy> bruh |
18:08:34 | FromDiscord | <Phil> Because the compiler has to figure out "Do I reserve some memory space the size of an int? A string? an array?" |
18:08:37 | FromDiscord | <gerwy> what if i change untyped to T? |
18:08:44 | FromDiscord | <Rika> no |
18:08:51 | FromDiscord | <Rika> return types conflict in each runtime branch |
18:09:06 | FromDiscord | <ajusa> there's no way to determine stuff at compile time when it is decided at runtime |
18:09:12 | FromDiscord | <ajusa> if v is static maybe you could do it |
18:09:34 | FromDiscord | <gerwy> no |
18:10:35 | FromDiscord | <Phil> This is one of those points where it shows that nim doesn't really do dynamic typing. You can escape the static typing a little bit in general, but a type that isn't known at compiletime is going to be hard to deal with |
18:10:49 | FromDiscord | <fs> why don't you guys just appreciate the fact that you're working in a static language :) |
18:10:57 | FromDiscord | <Vindaar> given that you already provide a generic argument `T` you can make it work if in each branch you call some conversion proc from type `U` (the type of the field) to the output `T`. That may error at CT for certain combinations |
18:11:21 | FromDiscord | <Phil> In reply to @fs "why don't you guys": I mean, I do, I just also like generics a lot 😛 |
18:12:14 | FromDiscord | <Rika> In reply to @fs "why don't you guys": sometimes its needed really, like if you want to represent arbitrary JSON |
18:12:24 | FromDiscord | <Rika> but yeah idk it hasnt been a problem for me |
18:12:34 | FromDiscord | <ShalokShalom> Could concepts do it? |
18:12:46 | FromDiscord | <Rika> concepts are compile time as well |
18:13:04 | FromDiscord | <gerwy> damn its so simple concept and im still struggling to find a solution bruh |
18:13:18 | FromDiscord | <Rika> shalok i'll have to apologise for last time, my intention was not to tell you what you thought i mean |
18:13:18 | FromDiscord | <Rika> (edit) "mean" => "meant" |
18:13:33 | FromDiscord | <fs> In reply to @Rika "sometimes its needed really,": mh, then stdlib json already solves it with the getStr, getInt, ... |
18:13:42 | FromDiscord | <Rika> but i meant something more like "i didnt think it was common to mistake auto and void, so that's why its not there" |
18:13:47 | FromDiscord | <Rika> im not sure if people do that |
18:13:49 | FromDiscord | <Phil> In reply to @Life Sucks "damn its so simple": It's a simple concept, but in a static language this particular thing is very hard to achieve in order to allow other nice things in nim |
18:14:10 | FromDiscord | <Rika> In reply to @fs "mh, then stdlib json": its still ugly lol |
18:14:17 | FromDiscord | <Phil> There can be no types that you don't know what they are at compile time |
18:14:51 | FromDiscord | <Rika> i really prefer it if the type were not embedded in the name xdddd |
18:14:57 | FromDiscord | <Rika> get(T) |
18:15:07 | FromDiscord | <fs> i like the way treeform's jsony maps json to static types |
18:15:15 | FromDiscord | <Rika> yes that works most of the time and its good |
18:15:20 | FromDiscord | <gerwy> just tell me how do to this in macro ↵that i give it an enum and that Value variable↵and it just returns like `variable.field_according_to_enum` |
18:15:24 | FromDiscord | <Phil> jsony is my go to for transforming object --> json |
18:15:26 | FromDiscord | <Rika> but sometimes json's arbitrary-er than that |
18:15:47 | FromDiscord | <Rika> In reply to @Life Sucks "just tell me how": no can do if the enum is not static 🙂 |
18:15:57 | FromDiscord | <Rika> back to square one, are we |
18:16:22 | FromDiscord | <Phil> I mean, maybe let him experience for himself? I'd give you a macro to knock yourself out but I tend to avoid macros for a reason |
18:16:40 | FromDiscord | <Phil> (edit) "himself?" => "himself (?)↵Could be educational ^^↵" |
18:16:44 | FromDiscord | <ShalokShalom> In reply to @Rika "shalok i'll have to": All fine |
18:18:30 | FromDiscord | <ShalokShalom> sent a long message, see http://ix.io/3UiY |
18:18:40 | FromDiscord | <Rika> hm |
18:18:41 | FromDiscord | <ShalokShalom> Since you might look for a, but stumble across b |
18:18:50 | FromDiscord | <Rika> just a different way of thinking |
18:19:03 | FromDiscord | <Rika> really hard to account for stuff like that really |
18:19:06 | FromDiscord | <Rika> (edit) "that" => "that," |
18:19:55 | FromDiscord | <ShalokShalom> In reply to @Isofruit "There can be no": So, I assume void simply counts as its own type?↵↵And auto as well? |
18:19:56 | FromDiscord | <Phil> In reply to @Life Sucks "just tell me how": Try to tackle beef if he shows up? |
18:20:05 | FromDiscord | <ShalokShalom> Like, at compile time. |
18:20:10 | FromDiscord | <gerwy> Beef gets really easily annoyed by me heh |
18:20:12 | FromDiscord | <Phil> In reply to @ShalokShalom "So, I assume void": Void is an absence of type. It is not a type, it is nothing |
18:20:28 | FromDiscord | <Phil> It is beyond type for it's just nothingness |
18:21:14 | FromDiscord | <ShalokShalom> So, it avoids type checking? |
18:21:16 | FromDiscord | <Phil> and auto as stated is just a place-holder that the compiler fills in for you |
18:21:24 | FromDiscord | <Rika> teeeeeeeeeeechnically its a type but only in a sense, its less type-y than int lool |
18:21:25 | FromDiscord | <Rika> (edit) "lool" => "lol" |
18:21:28 | FromDiscord | <Phil> It is a type, just one that you don't specify |
18:21:31 | FromDiscord | <ShalokShalom> So, that would mean its even more loose than dynamic types? |
18:21:35 | FromDiscord | <ShalokShalom> Aha. |
18:21:37 | FromDiscord | <Phil> (edit) "It ... is" added "(auto)" |
18:21:40 | FromDiscord | <Rika> no its literally the lack of a type |
18:21:47 | FromDiscord | <Rika> you cannot pass anything to it |
18:21:50 | FromDiscord | <Rika> it is no type |
18:22:00 | FromDiscord | <Rika> oh auto? |
18:22:03 | FromDiscord | <Rika> im lost xd |
18:22:06 | FromDiscord | <ShalokShalom> Well both |
18:22:21 | FromDiscord | <ShalokShalom> See, that would make sense to be documented |
18:22:26 | FromDiscord | <Rika> void is lack of type in the sense there is none↵auto is lack of type in the sense that you leave the compiler to choose |
18:22:28 | FromDiscord | <Phil> We're talking about both at once.↵Auto is a type, just one that the compiler determines.↵Void isn't a type, it's just nothing. |
18:22:29 | FromDiscord | <Rika> oh |
18:22:32 | FromDiscord | <Rika> i see your confusion now] |
18:22:43 | FromDiscord | <gerwy> okay so Rika, having your thingy i think might be the closest to what i want |
18:22:49 | FromDiscord | <gerwy> what should toEnum(T) return |
18:23:13 | FromDiscord | <Rika> nimnode of an enum value |
18:23:14 | FromDiscord | <ShalokShalom> In reply to @Isofruit "We're talking about both": That sounds very appropriate |
18:23:31 | FromDiscord | <Rika> it was just a concept i htought of and i dont know if it works at all' |
18:23:41 | FromDiscord | <Rika> you still kinda have to pass a type |
18:23:41 | FromDiscord | <gerwy> sent a code paste, see https://play.nim-lang.org/#ix=3Uj1 |
18:23:47 | FromDiscord | <Rika> In reply to @Life Sucks "and whats the deal": yeah pm |
18:23:48 | FromDiscord | <gerwy> i mean it seems like it will work |
18:24:02 | FromDiscord | <Phil> IIRC it works identical in java and...err... does C++ have a similar concept? I know it has auto which does the same as in nim, just not sure about void |
18:24:05 | FromDiscord | <gerwy> In reply to @Rika "yeah pm": okay so i guess now i need to figure out how to declare it |
18:24:08 | FromDiscord | <Rika> yeah, but idk why you're against `.int_value` if youre fine with `.value(int)` |
18:24:21 | FromDiscord | <Rika> i have my reasons, idk yours |
18:25:13 | FromDiscord | <fs> ~~just use python~~ |
18:25:14 | FromDiscord | <gerwy> hmm wait i have an idea |
18:25:20 | FromDiscord | <gerwy> In reply to @fs "~~just use python~~": ew nah, i prefer to suffer |
18:25:23 | FromDiscord | <Phil> In reply to @fs "~~just use python~~": But the speeeeeeed |
18:25:34 | FromDiscord | <Rika> In reply to @Life Sucks "ew nah, i prefer": so you prefer using python? |
18:25:41 | FromDiscord | <Rika> 😛 |
18:25:43 | FromDiscord | <ShalokShalom> In reply to @Isofruit "IIRC it works identical": Yeah, I also thought about [auto] coming from C++ |
18:26:21 | FromDiscord | <Phil> let me google if c++ has void |
18:26:45 | FromDiscord | <ShalokShalom> Well, C has a void type to begin with |
18:26:50 | FromDiscord | <Phil> I'm reading about void pointers |
18:26:51 | FromDiscord | <ShalokShalom> But idk if that's the same |
18:26:52 | FromDiscord | <Phil> This is dark magic |
18:26:53 | FromDiscord | <Phil> burn it |
18:27:00 | FromDiscord | <Rika> nim has `pointer` though :))) |
18:27:02 | FromDiscord | <ShalokShalom> 🔥 |
18:27:09 | FromDiscord | <Rika> bet phil cant sleep today because of that |
18:27:19 | FromDiscord | <Phil> I need holy water and holy fire |
18:27:24 | FromDiscord | <Rika> is there holy fire? |
18:27:29 | FromDiscord | <Phil> One to exorcise generic concepts, the other to burn void pointers |
18:27:31 | FromDiscord | <Rika> shit man sorry you're shit outta luck |
18:27:35 | FromDiscord | <Phil> If there isn't I will make some |
18:27:54 | FromDiscord | <Rika> what about void pointers that store void pointers |
18:28:06 | FromDiscord | <Rika> `ptr ptr pointer` |
18:28:09 | FromDiscord | <Phil> I'll staple so many layers of generic on top of one another until my machine bursts in holy fury |
18:28:18 | FromDiscord | <Phil> And a holy flame shall erupt from it |
18:28:18 | FromDiscord | <fs> i should get more into pointers and c to understand the jokes |
18:28:32 | FromDiscord | <Phil> void pointers can just be converted into any type |
18:28:36 | FromDiscord | <gerwy> okay never mind it doesn't work D: |
18:28:39 | FromDiscord | <fs> (edit) "i should get more into pointers and c ... to" added "just" |
18:29:05 | FromDiscord | <Phil> It's basically "What if I basically allow this to be anything now and open myself up to a whole host of potential memory issues" |
18:29:35 | FromDiscord | <gerwy> sent a code paste, see https://play.nim-lang.org/#ix=3Uj3 |
18:29:53 | FromDiscord | <Rika> yeah i told you |
18:29:55 | FromDiscord | <Rika> why |
18:29:58 | FromDiscord | <Rika> i told you why |
18:29:58 | FromDiscord | <gerwy> :<< |
18:30:08 | FromDiscord | <gerwy> i don't like it |
18:30:13 | FromDiscord | <gerwy> it should work >:c |
18:30:23 | FromDiscord | <Phil> I banged my head against the object variant wall as well for a while |
18:30:25 | FromDiscord | <Phil> I relented |
18:30:52 | FromDiscord | <Phil> I found my pice in solving the problem in a different way... one that surpsrisingly enough lead to a macro |
18:30:57 | FromDiscord | <gerwy> yeah i have enough i think, but i still don't want to have millions of if's just to get that stupid value |
18:31:00 | FromDiscord | <Phil> (edit) "surpsrisingly" => "surprisingly" |
18:31:25 | FromDiscord | <Phil> (edit) "pice" => "peace" |
18:31:52 | FromDiscord | <Rika> i'll finish the demo i made if you can give me the type def of your Value thing |
18:32:17 | FromDiscord | <Phil> Not a screenshot, copy paste of code please, so Rika can copy paste as well |
18:32:29 | FromDiscord | <Rika> haha |
18:32:32 | FromDiscord | <Rika> thats what i meant |
18:32:46 | FromDiscord | <gerwy> oh oka wait |
18:32:53 | FromDiscord | <ShalokShalom> @gerwy what are you trying to do in the first place? |
18:33:01 | FromDiscord | <Phil> A getter on an object variant |
18:33:09 | FromDiscord | <gerwy> sent a code paste, see https://play.nim-lang.org/#ix=3Uj4 |
18:33:15 | FromDiscord | <ShalokShalom> Seems like you map types to .. equivalent versions of it |
18:33:27 | FromDiscord | <Phil> Want's to get the value out of an object variant for which he doesn't know the type. So a getter that could return any type whatsoever |
18:33:46 | FromDiscord | <gerwy> In reply to @ShalokShalom "<@347345994217816066> what are you": having an AST, trying to evaluate expressions with this, since i don't know what their types are, i just know an enum and string value |
18:33:54 | * | PMunch quit (Quit: leaving) |
18:35:36 | * | jmdaemon joined #nim |
18:35:46 | FromDiscord | <ShalokShalom> And there is no concept in Nim, that does allow that? |
18:35:59 | FromDiscord | <ShalokShalom> This sounds like a relatively common use case |
18:36:20 | FromDiscord | <ShalokShalom> Would it make sense to raise an issue, and ask for a new implementation, that allows that? |
18:36:26 | FromDiscord | <Phil> you're trying to do `let x = get_value(objectVariant)` without knowing if x will be an int, string, object, array, seq, set or whatnot |
18:36:36 | FromDiscord | <Phil> And in this case, the compiler won't know either |
18:36:51 | FromDiscord | <Phil> And if the compiler doesn't know at compile time, it can't deal with it |
18:37:35 | FromDiscord | <gerwy> In reply to @ShalokShalom "And there is no": there is and its called object variant, exact thing im using |
18:37:39 | FromDiscord | <ShalokShalom> C# has lots of dynamic features, despite being a mostly statically typed language |
18:37:45 | FromDiscord | <gerwy> people call it tagged union too |
18:37:48 | FromDiscord | <ShalokShalom> 😬 |
18:37:50 | FromDiscord | <Phil> Because you don't know if objectVariant is of variant "hasString", "hasObj", "hasArr", "hasSeq" etc. |
18:38:13 | FromDiscord | <ShalokShalom> In reply to @Life Sucks "people call it tagged": Yeah, but why isnt it working then for you? |
18:38:19 | FromDiscord | <enthus1ast> you must check with "of" then cast to concrete type |
18:38:22 | FromDiscord | <gerwy> In reply to @Isofruit "you're trying to do": you know if its an int or string or whatever thats the point |
18:38:26 | FromDiscord | <enthus1ast> or convert not cast |
18:38:33 | FromDiscord | <gerwy> In reply to @ShalokShalom "Yeah, but why isnt": because nim is wacky and doesn't understand simple stuff |
18:38:37 | FromDiscord | <ShalokShalom> Seems like have only part of the solution |
18:38:41 | FromDiscord | <Phil> In reply to @ShalokShalom "Yeah, but why isnt": Because you can deal with it: By dealing with what to do for every single variant |
18:38:45 | FromDiscord | <Rika> im still not sure why you'd rather my solution than just `int_value` etc etc |
18:38:46 | FromDiscord | <Phil> Which is a lot of typing |
18:38:46 | FromDiscord | <ShalokShalom> Yeah, thats what I mean. |
18:39:00 | FromDiscord | <gerwy> In reply to @Rika "im still not sure": how would i know if its INT? |
18:39:03 | FromDiscord | <gerwy> (edit) "INT?" => "int?" |
18:39:09 | FromDiscord | <ShalokShalom> In reply to @Isofruit "Which is a lot": So that sounds like a macro? |
18:39:42 | FromDiscord | <Phil> Not necessarily. I don't know what you want to do when you encounter an int variant vs a string variant |
18:39:45 | FromDiscord | <gerwy> In reply to @enthus1ast "or convert not cast": so you say i should do `toInt(v.int_value)` or something like this? |
18:39:56 | FromDiscord | <Phil> So I can't write a macro that does a specific thing for you |
18:40:19 | FromDiscord | <enthus1ast> first check what kind the object is, then use type conversion |
18:40:25 | FromDiscord | <ShalokShalom> That sounds like dynamic typing then :p |
18:40:30 | FromDiscord | <Phil> If I presume that you always want whatever value is stored as a string I could write a compile-time-proc instead of a macro that contains the entire if-stuff |
18:40:41 | FromDiscord | <Phil> (edit) "If I presume that you always want whatever value is stored as a string I could write a compile-time-proc instead of a macro that contains the entire if-stuff ... " added "and converts from the various types into string" |
18:41:10 | FromDiscord | <gerwy> In reply to @enthus1ast "first check what kind": yeah i check it with `case typ` which is an enum and it tells me which type this object is |
18:41:13 | FromDiscord | <Phil> In reply to @ShalokShalom "That sounds like dynamic": Yeh, just type-intensive to ensure correctness |
18:41:34 | FromDiscord | <Phil> (edit) "Yeh," => "Its" |
18:41:43 | FromDiscord | <Phil> (edit) "type-intensive" => "typing-intensive" |
18:42:22 | FromDiscord | <ShalokShalom> Yeah, I see. |
18:42:41 | FromDiscord | <enthus1ast> ah no ignore me, not test with `of` |
18:42:50 | FromDiscord | <enthus1ast> this is for oop |
18:43:05 | FromDiscord | <gerwy> sent a code paste, see https://play.nim-lang.org/#ix=3Uj6 |
18:43:09 | FromDiscord | <enthus1ast> yes |
18:43:19 | FromDiscord | <Phil> In reply to @enthus1ast "ah no ignore me,": I don't think I've ever used of anywhere so I can't really comment on it.... that was sarcasm right? |
18:43:31 | FromDiscord | <Phil> (edit) "In reply to @enthus1ast "ah no ignore me,": I don't think I've ever used of anywhere so I can't really comment on it.... that was sarcasm ... right?" added "about how we didn't respond to "of"," |
18:43:35 | FromDiscord | <gerwy> sent a code paste, see https://play.nim-lang.org/#ix=3Uj7 |
18:43:49 | FromDiscord | <enthus1ast> no with `of` you can test if an object is of the given type |
18:43:59 | FromDiscord | <ShalokShalom> @gerwy is this 'case typ' meaning case type? |
18:44:03 | FromDiscord | <Phil> Wait... isn't that just "is"? |
18:44:30 | FromDiscord | <gerwy> In reply to @ShalokShalom "<@347345994217816066> is this 'case": yeah, typ is enum storing what type that object is |
18:44:35 | FromDiscord | <Phil> (My stuff was directed at enthus1ast) |
18:44:38 | FromDiscord | <gerwy> In reply to @Isofruit "Wait... isn't that just": no |
18:44:50 | FromDiscord | <Phil> Hah! Saw it coming from a mile away! |
18:45:02 | FromDiscord | <ShalokShalom> So just to avoid name duplication |
18:45:50 | FromDiscord | <Phil> Shalok, have you read about object variants in nim already? |
18:45:57 | FromDiscord | <ShalokShalom> Would you need proc in this case? |
18:46:05 | FromDiscord | <ShalokShalom> Seems like func would work as well |
18:46:14 | FromDiscord | <ShalokShalom> And provides you with more guarantees. |
18:46:34 | FromDiscord | <ShalokShalom> In reply to @Isofruit "Shalok, have you read": Yes, what am I missing? |
18:46:46 | FromDiscord | <gerwy> In reply to @ShalokShalom "Seems like func would": if it only could return any type |
18:47:09 | FromDiscord | <Phil> In reply to @ShalokShalom "Yes, what am I": Nothing, If not I'd have just thrown the url to their docs at you since I thought you might've found that interesting |
18:47:23 | FromDiscord | <enthus1ast> this is what i meant @Phil https://play.nim-lang.org/#ix=3Uj9 |
18:47:35 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=3Ujb |
18:47:37 | FromDiscord | <Rika> this is dumb btw |
18:47:40 | FromDiscord | <ShalokShalom> Yeah, actually the only Nim code I every wrote and commited, is nothing both that |
18:47:54 | FromDiscord | <ShalokShalom> But I am not used yet to call it object variants |
18:48:06 | FromDiscord | <ShalokShalom> Grew up calling them choice types |
18:48:20 | FromDiscord | <ShalokShalom> Or discriminated unions. |
18:48:21 | FromDiscord | <Rika> yeah some others call them tagged unions as well |
18:48:27 | FromDiscord | <Phil> Ah, fair. |
18:48:29 | FromDiscord | <ShalokShalom> Yeah |
18:48:39 | FromDiscord | <Rika> lotsa names for it |
18:48:40 | FromDiscord | <enthus1ast> since attribs in case objects cannot be named nicely, i try to avoid them |
18:48:47 | FromDiscord | <ShalokShalom> I was confused initially that they are realized with objects here |
18:49:34 | FromDiscord | <Phil> In reply to @enthus1ast "this is what i": Huh... yeah that works entirely different than "is" |
18:49:44 | FromDiscord | <ShalokShalom> sent a long message, see http://ix.io/3Ujc |
18:50:13 | FromDiscord | <enthus1ast> my example is misleading since the attrib name can be just val (withouth the str/int prefix) |
18:50:16 | FromDiscord | <gerwy> sent a code paste, see https://paste.rs/DTi |
18:50:17 | FromDiscord | <Rika> In reply to @Life Sucks "throws an exception for": used how? |
18:50:49 | FromDiscord | <gerwy> In reply to @Rika "used how?": pasted your example lol |
18:50:50 | FromDiscord | <ShalokShalom> Could pure C do what gerwy wants? |
18:50:56 | FromDiscord | <Rika> thats the point i mean |
18:50:58 | FromDiscord | <ShalokShalom> Since then we could just inline. |
18:51:01 | FromDiscord | <Rika> the first part works, the second doesnt |
18:51:02 | FromDiscord | <Rika> just to show |
18:51:02 | FromDiscord | <enthus1ast> and this is the reason i usually use them instead of case objects |
18:51:03 | FromDiscord | <Phil> In reply to @ShalokShalom "Objects always represented to": How languages shape what concepts you like. In java everything insane I've seen is objects. The only good bits I've seen in there resemble functional programming bits (lambdas, just so many lambdas) |
18:51:07 | FromDiscord | <gerwy> In reply to @ShalokShalom "Could pure C do": in macros, maybe, i have no idea if there are tagged unions in C |
18:51:20 | FromDiscord | <ShalokShalom> In reply to @Isofruit "How languages shape what": Yeah, totally |
18:51:37 | FromDiscord | <ShalokShalom> You have ever seen the Java part of the Clojure source code? |
18:51:40 | FromDiscord | <Rika> i should prolly go to sleep lest i risk having under 6 hours of sleep |
18:51:47 | FromDiscord | <ShalokShalom> Its said to be pretty much like that. |
18:51:50 | FromDiscord | <gerwy> In reply to @enthus1ast "and this is the": i can't use just val for object variant, since it shows an error for redefinition of val |
18:51:50 | FromDiscord | <Rika> ask beef to fix whatever dumb idea i had today |
18:51:56 | FromDiscord | <ShalokShalom> In reply to @Rika "i should prolly go": Sleep well. |
18:52:08 | FromDiscord | <Phil> Sleeping? So weak! |
18:52:11 | FromDiscord | <gerwy> In reply to @Rika "i should prolly go": go to sleep Rika, i appreciate all your help, i will figure it out thank youu<3 |
18:52:16 | FromDiscord | <Phil> Just stay awake! Sleep is wasted time! |
18:52:24 | FromDiscord | <ShalokShalom> In reply to @Life Sucks "in macros, maybe, i": Well, I am generally asking, because C is much more loose about its types |
18:52:29 | FromDiscord | <Rika> last time i did that was yesterday, for 30 hours |
18:52:33 | FromDiscord | <Phil> You could be coding more an give progressively better coding advice as you forego sleep for more coding! |
18:52:37 | FromDiscord | <gerwy> oh wait it makes sense that it doesn't work since you made it doesn't work lol |
18:52:40 | FromDiscord | <Rika> no thanks, i have things to do in the morning |
18:52:51 | FromDiscord | <gerwy> but i still want it to use enum instead of type <_> |
18:53:06 | FromDiscord | <creikey> In reply to @Elegantbeef "Same with your `sendData`": this is an interesting way of doing it, I was mainly just used to binny but didn't want to add a whole other dependency so just copy pasted the functions I needed |
18:53:14 | FromDiscord | <enthus1ast> yes i know, thats the reason i try to avoid case objects, but use inheritance↵(@gerwy) |
18:53:29 | FromDiscord | <Rika> In reply to @Life Sucks "but i still want": cannot do, the value must be compile time resolvable |
18:53:41 | FromDiscord | <ShalokShalom> In reply to @Isofruit "You could be coding": That doesn't scale well 😂 |
18:53:44 | FromDiscord | <Rika> that is a must, there is no going around that |
18:53:46 | FromDiscord | <creikey> the counting down so I don't have a seq for indices is useful though I forgot you could do that |
18:53:54 | FromDiscord | <Rika> In reply to @ShalokShalom "That doesn't scale well": it's a fine line |
18:53:56 | FromDiscord | <gerwy> In reply to @Rika "cannot do, the value": i can do like↵`ident tolower($T) & "value"` maybe hmm? |
18:54:01 | FromDiscord | <Phil> In reply to @ShalokShalom "That doesn't scale well": Just buy more scales if your scale isn't well! |
18:54:09 | FromDiscord | <Rika> a fine line of alcohol, caffeine, and sleep deprivation |
18:54:12 | FromDiscord | <enthus1ast> @gerwy\: https://play.nim-lang.org/#ix=3Uje |
18:54:50 | FromDiscord | <gerwy> In reply to @enthus1ast "<@347345994217816066>\: https://play.nim-lang.org/#": cool, now you need to use specifically StrObj only if you know exactly thats its gonna be string |
18:56:13 | FromDiscord | <gerwy> made it work for enums |
18:56:18 | FromDiscord | <gerwy> thanks to toLowerAscii |
18:56:37 | FromDiscord | <gerwy> oh wait i need to.. |
18:56:38 | FromDiscord | <gerwy> uugh |
18:56:46 | FromDiscord | <gerwy> Rikaaa |
18:57:35 | FromDiscord | <ShalokShalom> Considering the malware issue, that led to blocking Nim, and all Nim programs in general seen by Windows as potential thread:↵↵How does Windows know, that a certain software is written in Nim? |
18:57:41 | FromDiscord | <ShalokShalom> Considering its compiled. |
18:57:50 | FromDiscord | <gerwy> you know, this `echo val.value(INT)` is cool and all |
18:58:05 | FromDiscord | <gerwy> but i kinda wanted something like `echo val.value(val.typ)` to work too... |
18:58:39 | FromDiscord | <ShalokShalom> (edit) removed "Nim, and all" | removed "in general seen" |
18:58:43 | FromDiscord | <gerwy> In reply to @ShalokShalom "Considering the malware issue,": not only Nim suffers from that, its just that software is not signed↵same happens on Mac |
18:58:53 | FromDiscord | <ShalokShalom> Yeah, true |
18:58:58 | FromDiscord | <Rika> In reply to @ShalokShalom "Considering the malware issue,": Signature or patterns in the code generated |
18:59:02 | FromDiscord | <creikey> In reply to @Life Sucks "not only Nim suffers": I tried googling it but couldn't get a straight answer, how hard is it to get your executables signed? |
18:59:08 | FromDiscord | <Rika> In reply to @creikey "I tried googling it": Expensive |
18:59:09 | FromDiscord | <Phil> In reply to @ShalokShalom "Considering the malware issue,": Antivirus is just all ML learning |
18:59:14 | FromDiscord | <ShalokShalom> https://media.discordapp.net/attachments/371759389889003532/960614540607885382/Screenshot_2022-04-04-20-59-06-37.jpg |
18:59:23 | FromDiscord | <ShalokShalom> But I am talking about that |
18:59:27 | FromDiscord | <Rika> In reply to @Life Sucks "Rikaaa": Again the enum should be compile time determinable as I’ve said |
18:59:31 | FromDiscord | <Rika> Nowhere around that |
18:59:43 | FromDiscord | <ShalokShalom> In reply to @Isofruit "Antivirus is just all": Ah, I see. So it decompiled and knows its based on Nim |
18:59:44 | FromDiscord | <Phil> So it'll have some patterns the way the nim compiler translates nim code to C |
18:59:53 | FromDiscord | <gerwy> In reply to @Isofruit "Antivirus is just all": no, its checking hash of software and also its behaviour in small VM↵ML i think is not that effective |
19:00:05 | FromDiscord | <gerwy> In reply to @Rika "Nowhere around that": thats such a boomer |
19:00:07 | FromDiscord | <ShalokShalom> In reply to @creikey "I tried googling it": There are Reddit groups, who help ypu |
19:00:15 | FromDiscord | <ShalokShalom> Since x amount of users can say its fine |
19:00:19 | FromDiscord | <ShalokShalom> And then its fine |
19:00:30 | FromDiscord | <Rika> Sometimes AV vendors are stubborn though |
19:00:34 | FromDiscord | <Phil> In reply to @Life Sucks "no, its checking hash": It checks software hashes against a known whitelist? |
19:00:36 | FromDiscord | <creikey> In reply to @ShalokShalom "Since x amount of": interestintg |
19:00:37 | FromDiscord | <ShalokShalom> In reply to @Isofruit "So it'll have some": I see. |
19:00:44 | FromDiscord | <creikey> In reply to @ShalokShalom "There are Reddit groups,": https://stackoverflow.com/questions/252226/signing-a-windows-exe-file there's this but how do I get the actual certificate |
19:00:47 | FromDiscord | <creikey> do I need to be LLC |
19:00:55 | FromDiscord | <Rika> No you just have to pay |
19:01:03 | FromDiscord | <gerwy> i guess i will use that cringe ass fieldPairs for this moment↵we will see what i can do in future↵i planned on rewriting this language in Zig but thats only if i will decide to make it better and stuff |
19:01:04 | FromDiscord | <Phil> Or is there more to it? Because that'd be very surprising to me if you can see from a hash whether it's malware or not |
19:01:17 | FromDiscord | <Phil> Unless you've got blacklists/whitelists |
19:01:39 | FromDiscord | <gerwy> In reply to @Isofruit "It checks software hashes": ye, if the software does something malicious to your PC, its hash is saved in database and then reused in AV scanning files |
19:01:44 | FromDiscord | <creikey> In reply to @Rika "No you just have": who do I pay though? like where is the information |
19:02:25 | FromDiscord | <Phil> In reply to @Life Sucks "ye, if the software": That wouldn't explain why nim lands in the bin though, would it? That is under the assumption the various AV providers out there haven't just thrown the entire nim language on a blacklist |
19:02:46 | FromDiscord | <Phil> I assume that because I want to have some faith in humanity that AV providers don't just blacklist an entire language because of like 3 programs written in it |
19:02:58 | FromDiscord | <gerwy> In reply to @Isofruit "That wouldn't explain why": not signed software that does suspicious things↵again, you can sign your binary on windows |
19:03:33 | FromDiscord | <Phil> But the suspicious things would be determined through ML I'd assume |
19:03:56 | FromDiscord | <creikey> https://www.digicert.com/tls-ssl/compare-certificates do I buy this? |
19:04:37 | FromDiscord | <ShalokShalom> In reply to @creikey "who do I pay": You can also get your binary on the whitelist, when a certain amount of users accepts it as trustworthy |
19:04:46 | FromDiscord | <enthus1ast> when its easy for AV to trigger on eg gc then yes \:)↵(@Phil) |
19:04:49 | FromDiscord | <ShalokShalom> You can avoid paying that way |
19:04:57 | FromDiscord | <creikey> In reply to @ShalokShalom "You can also get": every time I update the executable though the same process has to happen right |
19:05:06 | FromDiscord | <creikey> but if I get the signature I can just sign every update |
19:05:06 | FromDiscord | <ShalokShalom> In reply to @Isofruit "I assume that because": Cute |
19:05:32 | FromDiscord | <enthus1ast> i must say lately my windows antivirus and sophos did not flag nim applications |
19:06:52 | FromDiscord | <ShalokShalom> In reply to @Isofruit "That wouldn't explain why": "This language is so rarely used, just block every single program. Basically, the malware is the first program, that I have encountered in it, so it is probably not really used for anything else." |
19:07:48 | FromDiscord | <ShalokShalom> In reply to @enthus1ast "when its easy for": You can still create hash rates from all Nim programs that are out in the wild. |
19:07:58 | FromDiscord | <gerwy> ugh god okay i guess fieldPairs doesn't work... |
19:08:02 | FromDiscord | <gerwy> i need to find some workaround |
19:08:13 | FromDiscord | <ShalokShalom> In reply to @creikey "every time I update": I think so, yes. Or you as the vendor become trustworthy. |
19:08:36 | FromDiscord | <ShalokShalom> But I think I can remember that people complained about having to do it for every version |
19:08:41 | FromDiscord | <ShalokShalom> Windows 🤷🏻♂️ |
19:09:14 | FromDiscord | <ShalokShalom> (edit) "become" => "becomes" |
19:09:24 | FromDiscord | <Phil> I mean, AV's have already started with the base assumption that nim as a language isn't trustworthy, otherwise the issue wouldn't exist |
19:09:36 | FromDiscord | <ShalokShalom> Yeah, totally. |
19:10:00 | FromDiscord | <Phil> So the only really viable paths are convincing them otherwise which needs community growth by like tenfold and then some and flooding them with complaints, or paying |
19:10:03 | FromDiscord | <gerwy> i have, veryyyy stupid idea that i hate to even have |
19:10:22 | FromDiscord | <gerwy> what if i just stored all the values as strings↵and convert them to the needed type |
19:10:22 | FromDiscord | <ShalokShalom> I guess they treat it as an obfuscation tool |
19:10:29 | FromDiscord | <ShalokShalom> What's understandable |
19:10:43 | FromDiscord | <ShalokShalom> Since honestly, thats it, pretty much |
19:11:00 | FromDiscord | <ShalokShalom> From a AV/ML point of view. |
19:11:05 | FromDiscord | <Phil> In reply to @Life Sucks "what if i just": That's.... why would you do this to yourself. You might as well keep using the object variant |
19:11:20 | FromDiscord | <Phil> You're exposing yourself to a sleuth of bugs in order to save some typing effort xP |
19:11:33 | FromDiscord | <Phil> Might as well convert to json and back |
19:11:48 | FromDiscord | <ShalokShalom> In reply to @Life Sucks "i have, veryyyy stupid": Sounds like you're enjoying the language |
19:11:52 | FromDiscord | <gerwy> In reply to @Isofruit "That's.... why would you": this fucking fucker doesn't work |
19:12:00 | FromDiscord | <ShalokShalom> Do you want to rate us in the app shop? |
19:12:00 | FromDiscord | <gerwy> this idea is literally what JS does lol |
19:12:57 | FromDiscord | <Phil> Yeh, and nowadays JS is treated more like a compilation target than an actual language xP |
19:13:11 | FromDiscord | <Phil> (By Typescript mind you, not nim) |
19:16:44 | FromDiscord | <gerwy> Typescript imo is awful too but well 🙄 |
19:17:10 | FromDiscord | <gerwy> i thought Nim would be able to tolerate my horrible idea but i guess i need to think about it in a different way |
19:17:11 | FromDiscord | <ShalokShalom> In reply to @Isofruit "(By Typescript mind you,": Why not by Nim? |
19:17:38 | FromDiscord | <ShalokShalom> Practically every language compiles to JS these days |
19:17:43 | FromDiscord | <ShalokShalom> Why is Nim different? |
19:18:00 | om3ga | Strange thing, I try to add() row I got from mariadb to the sec[string], and it not works :X ... rror: type mismatch: got <seq[string], string> |
19:18:01 | FromDiscord | <enthus1ast> it also compiles to c? |
19:18:38 | FromDiscord | <enthus1ast> is your seq a var? |
19:18:46 | FromDiscord | <ShalokShalom> sent a long message, see http://ix.io/3Ujl |
19:18:52 | FromDiscord | <gerwy> i will just have horrible code for now i guess |
19:18:59 | om3ga | If I'm not mistaken, sequences are similar to array of char arrays right? |
19:19:04 | FromDiscord | <gerwy> i mostly need this to evaluate expression |
19:19:06 | FromDiscord | <ShalokShalom> In reply to @enthus1ast "it also compiles to": Well, it treats JS as a compilation target |
19:19:40 | om3ga | enthus1ast: sequence.add(data[i][1]) |
19:19:40 | FromDiscord | <enthus1ast> show some code please↵(<@709044657232936960_om3ga=5b=49=52=43=5d>) |
19:20:05 | FromDiscord | <enthus1ast> where does `sequence` come from? |
19:20:10 | om3ga | where data[i][1] == cell from table (string) |
19:20:22 | om3ga | sequence: seq[string] |
19:20:29 | FromDiscord | <Phil> In reply to @ShalokShalom "Why not by Nim?": That was more a jab in that IIRC Typescript is the largest amount of source code that is used to compile to JS, because... well, it's the default for most of the entire JS ecosystem |
19:20:54 | FromDiscord | <Phil> Nim can compile to JS, in terms of sheer amount of code typescript will bury you |
19:21:02 | FromDiscord | <Phil> (edit) "Nim can compile to JS, in terms of sheer amount of code ... typescript" added "intended to compile to JS" |
19:21:15 | om3ga | I tested in playground... .add() works well with regular strings |
19:21:22 | FromDiscord | <enthus1ast> to share a more complete code snippet |
19:21:35 | om3ga | ok, just a minute |
19:21:42 | FromDiscord | <ShalokShalom> In reply to @Isofruit "That was more a": I think its so complicated because of the type system |
19:22:05 | FromDiscord | <Phil> In reply to @ShalokShalom "I think its so": You mean TS is complicated? |
19:22:08 | FromDiscord | <ShalokShalom> I heard it has a very advanced type system, to accommodate for JS |
19:22:20 | FromDiscord | <ShalokShalom> Well, complicated in terms of much code |
19:22:47 | FromDiscord | <Phil> TS is basically JS, but you can stick types at the end to guarantee that you didn't just do a dumb mistake in your types |
19:22:48 | FromDiscord | <ShalokShalom> Like, basically all functional languages are said to have a simpler type system |
19:23:06 | FromDiscord | <ShalokShalom> TS is actually based on researched, that had not been tested in production |
19:23:18 | FromDiscord | <ShalokShalom> In reply to @Isofruit "TS is basically JS,": Yeah, from a user side |
19:23:37 | FromDiscord | <ShalokShalom> But in order to be 100% compatible, they had to jump through hoops. |
19:23:46 | FromDiscord | <Phil> That I can imagine |
19:23:48 | FromDiscord | <ShalokShalom> (edit) "a" => "an" |
19:23:59 | FromDiscord | <Phil> Stuff like decorator annotations were still barely to non functional IIRC |
19:24:10 | FromDiscord | <Phil> (edit) "Stuff like ... decorator" added "some levels of" |
19:24:41 | FromDiscord | <Phil> At least they were early last year, I remember being unable to do so because not yet supported |
19:24:58 | FromDiscord | <Phil> (edit) "do so" => "annotate a couple decorators how I wanted" |
19:26:08 | om3ga | enthus1ast: https://pastebin.pl/view/13519a44 |
19:26:19 | om3ga | shortened example |
19:26:41 | FromDiscord | <enthus1ast> sequence is a proc param |
19:26:41 | FromDiscord | <ShalokShalom> Still, I guess TS would be able to do, what gerwy wants to do |
19:26:52 | FromDiscord | <ShalokShalom> Probably even pretty elegantly. |
19:27:02 | FromDiscord | <ShalokShalom> Due to the runtime being dynamic |
19:27:05 | FromDiscord | <enthus1ast> proc params are immutable unless you use `sequence: var seq[string]` |
19:27:23 | FromDiscord | <Phil> I mean, depends on if you have certain rules active. TS does have rules that enforce every variable must have a specific type |
19:27:29 | FromDiscord | <Phil> If you enable that you're once more in fun town |
19:27:52 | * | neurocyte8614 quit (Read error: Connection reset by peer) |
19:28:00 | FromDiscord | <Phil> Not sure how elaborate they made that one, we're at work working towards being able to enable it without it blowing up various parts of our frontend projects |
19:28:02 | om3ga | enthus1ast: yes, db.getAllRows returns sequence of Row type, where Row == string |
19:28:47 | om3ga | enthus1ast, oh! |
19:28:51 | * | neurocyte86144 joined #nim |
19:28:53 | om3ga | that's my fault |
19:29:10 | om3ga | but I tried to return new seq from that proc |
19:29:22 | om3ga | warning was the same... Let me try again |
19:29:52 | om3ga | or yeah, I will try to make param mutable |
19:30:25 | FromDiscord | <ShalokShalom> In reply to @Isofruit "I mean, depends on": Sounds like you just have to disable a certain rule and voila. |
19:30:33 | FromDiscord | <ShalokShalom> Or just use inline js |
19:30:40 | FromDiscord | <tandy> https://github.com/alaviss/union↵(@gerwy) |
19:30:41 | FromDiscord | <ShalokShalom> Whatever |
19:30:59 | om3ga | enthus1ast: it worked, thanks for helping me |
19:31:12 | FromDiscord | <enthus1ast> sure np |
19:31:16 | FromDiscord | <gerwy> In reply to @tandy "https://github.com/alaviss/union (<@347345994217816": i really have enough for today thanks, but i will think about it later |
19:31:25 | FromDiscord | <ShalokShalom> @tandy#0000 they are anonymous? |
19:31:33 | FromDiscord | <ShalokShalom> I think he wants named ones |
19:32:05 | FromDiscord | <ShalokShalom> And he is not missing the unions, he is missing something to read and convert it |
19:32:35 | FromDiscord | <ShalokShalom> (edit) "he" => "he/she" |
19:32:45 | FromDiscord | <ShalokShalom> Or do I not get something |
19:33:50 | FromDiscord | <gerwy> In reply to @ShalokShalom "I think he/she wants": i mean, everything will be better than what im currently trying to do... https://media.discordapp.net/attachments/371759389889003532/960623248540848148/unknown.png |
19:34:06 | FromDiscord | <gerwy> yeah... |
19:39:35 | FromDiscord | <ShalokShalom> I like to mention that the type declarations are by far the most messy thing about this |
19:40:01 | FromDiscord | <ShalokShalom> That does look like C |
19:40:07 | FromDiscord | <ShalokShalom> Or some other generic language |
19:40:25 | FromDiscord | <ShalokShalom> Congratulations, you got Nim out of Nim 🥳 |
19:41:03 | FromDiscord | <pmunch> Gerwy, an easier way to do that would be to first get the values converted to float, then do the math afterwards. |
19:47:03 | FromDiscord | <pmunch> sent a long message, see http://ix.io/3Ujr |
19:48:05 | FromDiscord | <pmunch> Hmm, apparently Matrix doesn't have code highlighting |
19:48:10 | FromDiscord | <pmunch> But you get the point |
20:03:27 | FromDiscord | <gerwy> In reply to @pmunch "Something like this\: \`\`\`nim": well i wouldn't say its easier, since i still need this ugly case but i guess its gonna look better if i make this conversion |
20:03:34 | FromDiscord | <gerwy> god this language gonna be so slow haha |
20:17:34 | FromDiscord | <ShalokShalom> https://github.com/jart/cosmopolitan#readme= |
20:18:18 | FromDiscord | <ShalokShalom> https://github.com/jart/cosmopolitan#readme↵↵Why not incorporating this into the language? |
20:20:24 | FromDiscord | <ShalokShalom> It could help making the language available on all platforms, just with one binary. |
20:20:55 | FromDiscord | <Rika> Doesn’t work for GUI applications |
20:21:03 | FromDiscord | <Rika> Also I can’t sleep lol good luck to me today I guess |
20:21:46 | * | xet7 quit (Remote host closed the connection) |
20:22:32 | FromDiscord | <Rika> M8 I’m not staying up for another 30 hours |
20:22:40 | FromDiscord | <gerwy> yes go to sleep |
20:22:43 | FromDiscord | <gerwy> drink tea and sleep |
20:22:54 | FromDiscord | <Rika> No, it’s kinda a bit too late now |
20:23:08 | FromDiscord | <Rika> I could prolly nap for two or three hours if I can even fall asleep |
20:24:15 | FromDiscord | <enthus1ast> whats up @Rika ? |
20:24:38 | FromDiscord | <Rika> It’s been an hour or so and I couldn’t fall asleep that’s all |
20:24:57 | FromDiscord | <Rika> Prolly gonna stay up again unless I could nap |
20:26:14 | FromDiscord | <enthus1ast> put you digital devices away \:) |
20:26:58 | FromDiscord | <Rika> That’s not my issue, I have for the whole hour |
20:28:42 | FromDiscord | <ShalokShalom> Light blocks the release of the sleep hormone. |
20:48:16 | FromDiscord | <morgan> ok so im just a little unsure what to do. i have two tables in an object that have ref objects as the value. do i need to do anything more than declare the object and its inputs? i had read something with `new()` but i can't find anything that fully addresses this |
20:49:06 | * | LuxuryMode joined #nim |
20:49:30 | FromDiscord | <morgan> sent a code paste, see https://play.nim-lang.org/#ix=3UjE |
20:49:57 | FromDiscord | <morgan> (edit) "https://play.nim-lang.org/#ix=3UjE" => "https://paste.rs/qLi" |
20:50:07 | FromDiscord | <morgan> that isn't the code exactly |
20:50:24 | FromDiscord | <morgan> it's spread over two files and a bunch of unnecessary stuff |
20:50:26 | FromDiscord | <creikey> sent a code paste, see https://paste.rs/iSl |
20:50:30 | FromDiscord | <creikey> (edit) "https://play.nim-lang.org/#ix=3UjF" => "https://play.nim-lang.org/#ix=3UjG" |
20:53:08 | FromDiscord | <demotomohiro> You can write `flagShort['a'] = FlagVariantRef(...)` |
20:54:35 | FromDiscord | <morgan> so there's actually 4 tables, two pairs based on whether its shared with subcommands or not, and then short and long separately |
20:54:59 | FromDiscord | <demotomohiro> @creikey https://nim-lang.org/docs/with.html |
20:55:01 | FromDiscord | <morgan> https://media.discordapp.net/attachments/371759389889003532/960643677028511804/unknown.png |
20:55:12 | * | lain quit (Quit: kthxbai) |
20:55:44 | * | lain joined #nim |
20:55:47 | * | jjido joined #nim |
21:01:23 | FromDiscord | <demotomohiro> You can create object/ref object types like `Foo(fieldName: value)` : https://nim-lang.org/docs/manual.html#types-object-construction |
21:02:43 | FromDiscord | <demotomohiro> Then you can put it on `table`. |
21:04:17 | FromDiscord | <demotomohiro> @morgan Your code looks fine. |
21:11:00 | FromDiscord | <creikey> In reply to @demotomohiro "<@180866243819995136> https://nim-lang.org/docs/wit": is there this but it only uses the argument of `with` if it works in the function? |
21:11:09 | FromDiscord | <creikey> so you can have like a `with d:` and other non-d-using functions in the scope |
21:18:39 | FromDiscord | <morgan> In reply to @demotomohiro "<@277133333773811712> Your code looks": cool thanks |
21:18:48 | FromDiscord | <demotomohiro> How people see if it is a function called with d or not under `with d:`? |
21:26:08 | FromDiscord | <demotomohiro> If you want to mix procedures that take an argment of `with` and procedures that doesn't take under `with`, I think you need to implement it yourself. |
21:36:06 | FromDiscord | <ShalokShalom> I dont really understand, what the ref keyword is supposed to mean |
21:36:24 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
21:36:24 | FromDiscord | <ShalokShalom> I assume, it means reference? |
21:36:57 | FromDiscord | <ShalokShalom> And then, the docu says something about "Built-in generic traced pointer type." which does not really say anything about it to me. |
21:40:37 | FromDiscord | <demotomohiro> `ref T` means it is a reference to T allocated on heap and actually it is a pointer managed by Nim's memory management. |
21:41:00 | FromDiscord | <ShalokShalom> And shouldnt it be called "generically traced"? |
21:41:25 | FromDiscord | <ShalokShalom> So I need it for manual memory management? |
21:42:07 | * | vicfred joined #nim |
21:42:55 | * | wyrd quit (Ping timeout: 240 seconds) |
21:43:19 | FromDiscord | <demotomohiro> I think it is called generic because it can be used to reference any types. |
21:44:27 | FromDiscord | <demotomohiro> I think traced means Nim's GC manages `ref` types. |
21:44:41 | FromDiscord | <ShalokShalom> pfft |
21:44:51 | FromDiscord | <ShalokShalom> Is it important for a newbie? |
21:44:57 | FromDiscord | <morgan> yeah so ref works with the GC, ptr is ignored by it and you have to do more if you want to have it help you out |
21:45:13 | FromDiscord | <morgan> that's my understanding as a newb |
21:45:28 | FromDiscord | <morgan> well, maybe moving past newb |
21:45:39 | FromDiscord | <morgan> but recent newb at least |
21:46:38 | FromDiscord | <ShalokShalom> Isnt the point of GC that I dont need to care about? |
21:46:40 | FromDiscord | <demotomohiro> If you want to do manual memory management, you can use `ptr T`. It is just a pointer that Nim's GC do nothing to it. |
21:46:46 | FromDiscord | <ShalokShalom> Aha. |
21:49:51 | FromDiscord | <demotomohiro> I think the point of GC is heap is freed automatically when it is no longer used. |
21:49:57 | * | wyrd joined #nim |
21:59:53 | FromDiscord | <ShalokShalom> The point of gc is so you dont have to free and allocate memory yourself↵↵Basically, think about memory |
22:06:48 | * | arkanoid quit (Ping timeout: 252 seconds) |
22:07:03 | * | om3ga quit (Remote host closed the connection) |
22:07:13 | * | ozzz joined #nim |
22:20:02 | FromDiscord | <Elegantbeef> I mean you can also use GC'd memory like memory allocations |
22:22:21 | FromDiscord | <Elegantbeef> `GCRef` and `GCUnref` let you make references stay alive longer and then deallocate them later when you get them back from pointer |
22:28:37 | NimEventer | New thread by ElegantBeef: This Month with Nim - March and Feburary, see https://forum.nim-lang.org/t/9073 |
22:40:36 | FromDiscord | <creikey> In reply to @demotomohiro "How people see if": called with d if it makes sense to call with d |
22:41:00 | FromDiscord | <creikey> as in you can do with d: and make draw calls which use the d context and also do other math |
22:41:53 | FromDiscord | <Elegantbeef> Creikey did you see my long list of suggestions or just the ones i pinged you with? |
22:48:03 | FromDiscord | <ShalokShalom> sent a long message, see http://ix.io/3Ukz |
22:48:32 | FromDiscord | <ShalokShalom> So proc 1 with a parameter T1 would obviously mix with proc 2 with a T1 para |
22:48:47 | FromDiscord | <ShalokShalom> Or how is this? |
22:49:01 | FromDiscord | <demotomohiro> Nim's procedure overload picks the procedure based on a number and types of argument, but it seems you are asking to pick arguments based on defined procedures. @creikey |
22:49:04 | FromDiscord | <Elegantbeef> What do you mean? |
22:49:48 | FromDiscord | <Elegantbeef> If you want the generics to bind to the same type you have to explicitly do it, not use auto |
22:50:20 | FromDiscord | <Elegantbeef> Auto as it says emits a generic parameter for each parameter, whereas explicit generics do not |
22:50:27 | FromDiscord | <huantian> If you’re asking if having multiple procs with the same generic name effect each other, they do not |
22:50:43 | FromDiscord | <huantian> Each generic name is scoped to the individual proc |
22:50:53 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3UkD |
22:51:36 | FromDiscord | <Elegantbeef> Nim has many mechanisms for resolving ambiguity anyway |
22:51:42 | * | jkl quit (Quit: Gone.) |
22:52:08 | * | arkanoid joined #nim |
22:52:34 | FromDiscord | <demotomohiro> @creikey Maybe creating a template that takes `d` and a code block, and define draw templates work without taking `d` that can be used only in the code block. |
22:52:54 | FromDiscord | <Elegantbeef> What are we trying to solve? |
22:53:04 | * | jkl joined #nim |
22:54:12 | FromDiscord | <Elegantbeef> Is it just the "pass `d` as the first parameter to a bunch of calls"? |
22:55:21 | FromDiscord | <ShalokShalom> In reply to @huantian "If you’re asking if": So they would clash, if I am trying to combine different instances of T1? |
22:55:39 | FromDiscord | <Elegantbeef> What do you mean? |
22:56:20 | FromDiscord | <ShalokShalom> @Elegantbeef#0000 As I read the linked documentation, is your example not correct |
22:56:28 | FromDiscord | <ShalokShalom> Or am I reading it wrong |
22:56:30 | FromDiscord | <Elegantbeef> My example is correct |
22:56:46 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/960674318138900520/image.png |
22:56:51 | FromDiscord | <Elegantbeef> My example doesnt disagree with that |
22:57:00 | FromDiscord | <ShalokShalom> https://media.discordapp.net/attachments/371759389889003532/960674375919607888/Screenshot_2022-04-05-00-56-53-97.jpg |
22:57:09 | FromDiscord | <Elegantbeef> Yes my example agrees with that |
22:57:25 | FromDiscord | <Elegantbeef> `# a does not change B's type` |
22:58:08 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3UkF |
22:58:43 | FromDiscord | <Elegantbeef> I do not get what the confusion is from shalok, can you elaborate what you're asking about? |
22:59:28 | FromDiscord | <Elegantbeef> auto generates a generic parameter per parameter, so if you want them to be the same type you need to be explicit |
23:00:00 | FromDiscord | <demotomohiro> If you have a proc `foo(a: auto) = echo a` and call it like `foo(1)` and foo("abc"), Nim creates `foo(a: int) = echo a` and `foo(a: string) = echo a`. It is not a problem as Nim have overloading. |
23:01:05 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3UkH |
23:01:27 | FromDiscord | <Elegantbeef> Nim chooses the most specialised procedure on dispathc |
23:01:30 | FromDiscord | <Elegantbeef> dispatch even |
23:02:54 | FromDiscord | <demotomohiro> If you call `foo(1)` and `foo(2)`, Nim creates `proc foo(a: int) = echo a` only when `foo(1)` is used and `foo(2)` just calls it. |
23:03:21 | FromDiscord | <Elegantbeef> I dont even know what we're talking about |
23:03:55 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "`# a does not": It doesnt say anything about that |
23:04:03 | FromDiscord | <ShalokShalom> Where do you read this? |
23:04:18 | FromDiscord | <Elegantbeef> It says that |
23:04:30 | FromDiscord | <Elegantbeef> `proc name[T1,T2](a: T1, b: T2)` |
23:04:32 | FromDiscord | <Elegantbeef> It says it right htere |
23:04:45 | FromDiscord | <Elegantbeef> Each parameter gets it's own generic parameter which means `a` does not change `b`'s type |
23:05:08 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "auto generates a generic": This comes probably down to me not understanding generic types in general |
23:05:25 | FromDiscord | <Elegantbeef> generics in nim are just templates basically that are emitted on first call |
23:05:43 | FromDiscord | <Elegantbeef> So when you get a generic it's specialiized for the given types and instantiated |
23:05:58 | FromDiscord | <Elegantbeef> It's called monomorphism i believe |
23:06:41 | FromDiscord | <demotomohiro> Nim generics is similar to C++'s template. |
23:06:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3UkM |
23:06:59 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3UkN |
23:06:59 | FromDiscord | <Elegantbeef> Eh dont bring in other languages |
23:07:06 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "Each parameter gets it's": But how is this different with auto then? |
23:07:14 | FromDiscord | <ShalokShalom> It says clearly it is the same |
23:07:29 | FromDiscord | <Elegantbeef> the comparison was with `proc name[T](a, b: T)` |
23:07:42 | FromDiscord | <Elegantbeef> Notice how `a` and `b` are assigned `T` as their type? |
23:07:58 | FromDiscord | <Elegantbeef> That means if `a is int` b also has to be |
23:08:29 | FromDiscord | <ShalokShalom> You said the two examples are different |
23:08:43 | FromDiscord | <Elegantbeef> So anyway when you do `MyObject[float]()` what happens is nim types that type definition and replaces `T` with `float` |
23:08:48 | FromDiscord | <Elegantbeef> Did you fucking read my message? |
23:08:57 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/960677384649076838/image.png |
23:09:01 | FromDiscord | <demotomohiro> !eval proc foo(a, b: auto) = echo typeof(a), typeof(b); foo(1, "2") |
23:09:03 | NimBot | <no output> |
23:09:13 | FromDiscord | <Elegantbeef> Look at the code in that image i just linked |
23:09:15 | FromDiscord | <ShalokShalom> My head hurts |
23:09:38 | FromDiscord | <Elegantbeef> Generics are simply "Replace all instances of `T ` with my instantiated argument" |
23:10:09 | FromDiscord | <Elegantbeef> They arent that complicated really, it's just "we're using X symbol for placeholder of what we're getting passed, when we get that we replace that with our symbol" |
23:10:12 | FromDiscord | <ShalokShalom> I just recognized right now, that you sneaked in a T |
23:10:24 | FromDiscord | <ShalokShalom> I assumed, you would have just copied the example |
23:10:33 | FromDiscord | <Elegantbeef> The example isnt what i wanted to explain |
23:10:49 | FromDiscord | <Elegantbeef> The example explains each parameter gets it's own generic parameter |
23:10:58 | FromDiscord | <Elegantbeef> I was explaining how to bind multiple parameters to the same type |
23:10:58 | FromDiscord | <ShalokShalom> I still dont understand, why you have brought this up |
23:11:47 | FromDiscord | <Elegantbeef> I brought it up cause your question made no sense and i thought explaining how generic parameters worked would help |
23:11:58 | FromDiscord | <Elegantbeef> But apparently that was a fools errand |
23:12:12 | FromDiscord | <Elegantbeef> What even is your question |
23:12:44 | FromDiscord | <ShalokShalom> If I am using auto all over the place, would that provide some kind of type safety? |
23:12:53 | FromDiscord | <Elegantbeef> Well yes Nim is statically typed |
23:13:05 | FromDiscord | <Elegantbeef> It's very annoying to use |
23:13:11 | FromDiscord | <Elegantbeef> But yes you still have static type safety |
23:13:31 | FromDiscord | <ShalokShalom> Well, that doesnt change anything about the fact, that a statically typed program with just string types and nothing else provides zero type safety |
23:13:44 | FromDiscord | <Elegantbeef> What? |
23:14:05 | FromDiscord | <ShalokShalom> If all the types are the same, it wont prevent type mismatch |
23:14:15 | FromDiscord | <Elegantbeef> But they arent all the same |
23:14:18 | FromDiscord | <ShalokShalom> Does auto all over the place prevent type mismatch |
23:14:24 | FromDiscord | <Elegantbeef> No |
23:14:32 | FromDiscord | <ShalokShalom> Well, if they are on auto, they are all T1, T2 |
23:14:35 | FromDiscord | <Elegantbeef> `auto` isnt type erasure |
23:14:50 | FromDiscord | <Elegantbeef> T1, and T2 are inferred or explicitly got from procedure instantiation |
23:15:01 | FromDiscord | <ShalokShalom> So the type generated by T1, etc do produce unique types |
23:15:34 | FromDiscord | <ShalokShalom> It would be so much cooler, if it would be inferred from the body |
23:15:44 | FromDiscord | <Elegantbeef> Well they're placeholder names of the actual type |
23:15:45 | FromDiscord | <Elegantbeef> `myObjFloat.doThing` erros |
23:15:46 | FromDiscord | <Elegantbeef> cause `field` is of type `float` and you're attempting to assign `int` |
23:15:46 | FromDiscord | <ShalokShalom> I hope that comes, as considered in the docs |
23:15:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3UkO |
23:15:57 | FromDiscord | <Elegantbeef> Concepts exist |
23:16:08 | FromDiscord | <huantian> or just↵write out the types you want the arguments to be |
23:16:16 | FromDiscord | <Elegantbeef> Inferred would be nice, but concepts are nice |
23:16:28 | FromDiscord | <Elegantbeef> So until we get inferred be cool and use conceepts |
23:16:29 | FromDiscord | <ShalokShalom> 🤯 |
23:17:07 | FromDiscord | <Elegantbeef> There we go |
23:17:09 | FromDiscord | <Elegantbeef> Much nicer |
23:17:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/K9X |
23:17:25 | FromDiscord | <Elegantbeef> Dont eve need `int(300)` now |
23:17:29 | FromDiscord | <Elegantbeef> We statically know it's an int |
23:18:30 | FromDiscord | <ShalokShalom> Instead of (int) could I also use my custom type? |
23:18:37 | FromDiscord | <Elegantbeef> Of course |
23:18:38 | FromDiscord | <ShalokShalom> default is a keyword here? |
23:19:00 | FromDiscord | <Elegantbeef> We'll say it's a keyword |
23:19:04 | FromDiscord | <Elegantbeef> It's not really, but we'll say it |
23:19:20 | FromDiscord | <Elegantbeef> It's a procedure which returns the 0'd value of a type |
23:19:59 | FromDiscord | <Elegantbeef> You might say "well this is more typing than auto" but personally having a concrete explanation of what a type needs to implements is much nicer than auto |
23:20:31 | FromDiscord | <Elegantbeef> you can also do like `d.someProc("", 3d, 3d)` |
23:21:17 | FromDiscord | <ShalokShalom> One is more horrible than the other |
23:21:36 | FromDiscord | <Elegantbeef> Yea `auto` fucking sucks |
23:30:33 | FromDiscord | <jmgomez> hey guys, super noob question. Im testing out the import of a cpp header file. I have my header file alongside the nim one and Im compiling it with cpp. What else I suppose to do in order to get it compiling? |
23:30:58 | FromDiscord | <Elegantbeef> Afaik that should be it |
23:32:09 | FromDiscord | <Elegantbeef> Actually you might need to tell nim to compile the C file or link a shared library |
23:32:21 | FromDiscord | <Elegantbeef> C++ file\ |
23:32:31 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-importcpp-pragma if you havent looked already |
23:32:44 | FromDiscord | <ShalokShalom> sent a long message, see http://ix.io/3UkU |
23:32:50 | FromDiscord | <Elegantbeef> types are lovely |
23:33:01 | FromDiscord | <ShalokShalom> Types are lovely |
23:33:14 | FromDiscord | <Elegantbeef> Explicit types give a clear and concise requirement of API |
23:33:22 | FromDiscord | <Elegantbeef> `auto` is noise and doesnt help |
23:33:32 | FromDiscord | <Elegantbeef> No i dont want to run a docgen on all my code |
23:33:44 | FromDiscord | <ShalokShalom> Nothing in the way Nim presents types is not noise. |
23:34:09 | FromDiscord | <Elegantbeef> I mean let's look at concepts |
23:34:18 | FromDiscord | <Elegantbeef> It gives an explicit requirement of types to match |
23:34:37 | FromDiscord | <Elegantbeef> You cannot get that automatically without modifying source code or tools |
23:34:44 | FromDiscord | <jmgomez> That's the error Im getting https://media.discordapp.net/attachments/371759389889003532/960683870477504582/message.txt |
23:34:46 | FromDiscord | <Elegantbeef> And those two things are tedious to worry about |
23:35:14 | FromDiscord | <huantian> I don't think i've ever thought about using auto for param typing ever |
23:35:29 | FromDiscord | <Elegantbeef> Me either |
23:35:35 | FromDiscord | <Elegantbeef> Maybe as a work around to a compiler bug |
23:36:00 | FromDiscord | <Elegantbeef> So is this a `hpp` and `cpp` file? |
23:36:11 | FromDiscord | <Elegantbeef> If so you might need `{.compiler: "myfile.cpp".}` |
23:36:16 | FromDiscord | <jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=3UkV |
23:36:26 | FromDiscord | <Elegantbeef> Ah thanks let me give this a whirl |
23:36:43 | FromDiscord | <jmgomez> I tried with compiler but it didnt seem to pick it |
23:36:57 | FromDiscord | <huantian> Like \~70% of the time you can just specify the type directly with the name↵and the rest you just use generics and concepts |
23:38:25 | FromDiscord | <huantian> I think it would be a bit overkill to say that all types in nim are horrible though |
23:38:25 | FromDiscord | <Elegantbeef> Hmm it works here i think |
23:38:28 | FromDiscord | <ShalokShalom> @huantian#0000 That was not what was the discussion about |
23:38:52 | FromDiscord | <Elegantbeef> atleast with `test.cpp` as the file name |
23:39:14 | FromDiscord | <Elegantbeef> Ah works with `.h` aswell |
23:39:19 | FromDiscord | <Elegantbeef> These are next to eachother right? |
23:39:22 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "You cannot get that": Yeah, and its still a horrible choice compared to full type inference. |
23:39:29 | FromDiscord | <Elegantbeef> It's really not |
23:39:33 | FromDiscord | <ShalokShalom> Like no solution at all. |
23:40:23 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=3UkW |
23:40:48 | FromDiscord | <huantian> you have to specify that a and b are the types you want |
23:41:06 | FromDiscord | <jmgomez> aghh I might have something going on because I changed the name of the files and now the linker is complaining about a duplicated name :/ |
23:43:05 | FromDiscord | <huantian> what is this in response too?↵(@ShalokShalom) |
23:44:26 | FromDiscord | <Elegantbeef> it'ss even worse haun, you cannot use static values for optimizations either |
23:44:30 | FromDiscord | <Elegantbeef> Or protection |
23:44:37 | FromDiscord | <Elegantbeef> Want to only allow a `0..10`in your procedure |
23:44:45 | FromDiscord | <Elegantbeef> Well now you need to do `assert myVal in 0..10` |
23:44:50 | FromDiscord | <Elegantbeef> Fuck yea i love tedium! |
23:45:41 | FromDiscord | <jmgomez> I got it working, I seems like the compile directive was adding the file again and also it seems like the imported class needs to have a different name in nim (which kinda makes sense). Thanks! |
23:45:42 | FromDiscord | <ShalokShalom> In reply to @huantian "you have to specify": A and b are parameter names, not types |
23:45:44 | FromDiscord | <Elegantbeef> Yea jmgomez it works here so cannot say much |
23:45:54 | FromDiscord | <abdu> sent a long message, see http://ix.io/3UkY |
23:46:01 | FromDiscord | <ShalokShalom> And there are languages with full type inference |
23:46:19 | FromDiscord | <abdu> (edit) "https://paste.rs/H1N" => "https://paste.rs/Oby" |
23:46:21 | FromDiscord | <Elegantbeef> Do they have sub range types? |
23:46:45 | FromDiscord | <Elegantbeef> abdu `import std/strutils; echo o.join()` |
23:46:50 | FromDiscord | <abdu> (edit) "http://ix.io/3Ul0" => "http://ix.io/3UkZ" |
23:46:54 | FromDiscord | <huantian> If a language did have full type inference I woudl probably not use that↵typing parameters and return types are great for making self documenting code |
23:46:58 | FromDiscord | <abdu> (edit) "http://ix.io/3UkZ" => "http://ix.io/3Ul1" |
23:47:30 | FromDiscord | <Elegantbeef> Const generic dispatch and subrange types cant really be done in "typeless" code |
23:47:47 | FromDiscord | <Elegantbeef> you cannot really infer something is supposed to be in a range unless there is a range check 😛 |
23:48:23 | FromDiscord | <Elegantbeef> `proc doThing(s: static string)` i guess can be inferred due to \`when s == "hello"\~ |
23:49:33 | FromDiscord | <huantian> I think I just don’t see why specifying that a proc takes a string and returns an int is bad |
23:49:54 | FromDiscord | <konsumlamm> Haskell actually encourages type annotations for top level definitions, despite having full type inference |
23:49:55 | FromDiscord | <Elegantbeef> Well i see that it harms code reuse but not all functions can be reused |
23:50:23 | FromDiscord | <ShalokShalom> @huantian#0000 http://www.fssnip.net/86m |
23:50:46 | FromDiscord | <ShalokShalom> In reply to @konsumlamm "Haskell actually encourages type": Haskell recommends type declarations everywhere |
23:50:57 | FromDiscord | <ShalokShalom> FSharp does it, as you say |
23:51:07 | FromDiscord | <Elegantbeef> In the case procedures can be reused use concepts |
23:51:08 | FromDiscord | <Elegantbeef> If the procedure cannot be reused use types, since it gives an explicit requirement to use it |
23:51:33 | FromDiscord | <konsumlamm> In reply to @ShalokShalom "Haskell recommends type declarations": not really, just for top level definitions |
23:51:53 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "Do they have sub": I really dont care. |
23:52:13 | FromDiscord | <Elegantbeef> Ah nice |
23:52:14 | FromDiscord | <ShalokShalom> In reply to @konsumlamm "not really, just for": Thats not how 99% of all Haskell code I see. |
23:52:23 | FromDiscord | <ShalokShalom> Top level definitions make sense |
23:52:41 | FromDiscord | <ShalokShalom> I know one web framework, that encourages ditching them all together |
23:53:27 | FromDiscord | <Elegantbeef> Does F# have static parameters? |
23:53:30 | FromDiscord | <ShalokShalom> IHP - Integrated Haskell Platform |