00:07:07 | * | pch quit (Remote host closed the connection) |
00:11:28 | FromDiscord | <ynfle (ynfle)> Is there a way to get a `var` version of a base type (for a `distinct`)? |
00:11:58 | FromDiscord | <ynfle (ynfle)> Or, how can I `{.borrow.}` `mitems` where it's generic? It doesn't seem to be working |
00:12:27 | * | kayabaNerve quit (Ping timeout: 264 seconds) |
00:16:44 | * | pch joined #nim |
00:17:13 | FromDiscord | <Elegantbeef> You can do `thing.base[: type].mitems` |
00:17:30 | FromDiscord | <Elegantbeef> Atleast assuming you're using a version of Nim with my fixes implemented |
00:17:34 | FromDiscord | <Elegantbeef> Might require devel |
00:18:43 | FromDiscord | <Elegantbeef> Generic distincts borrowing generic ops isnt presently supported and it's a bit confusing what it should mean |
00:31:52 | FromDiscord | <evoalg> Has anyone tried Julia (programming language)? I'm interested to know why people chose to use Nim instead. Julia is like python in that it's high-level and interpreted, but runs at near C speed. I'm thinking it has it's place but it may be too specialized, whereas Nim can be used for loads of different things. I suspect that Nim has smaller executables etc too. |
00:32:20 | FromDiscord | <Elegantbeef> I've briefly looked into it, it's use of multiple dispatch is a bit scary to me |
00:34:05 | FromDiscord | <evoalg> if it's scary for you then I'd be petrified |
00:35:03 | FromDiscord | <Elegantbeef> Eh it's more for data scientists |
00:35:46 | FromDiscord | <impbox [ftsf]> multi dispatch is cool though? |
00:36:07 | FromDiscord | <Elegantbeef> I mean it's confusing to reason about |
00:37:41 | FromDiscord | <Elegantbeef> Nim does have it though it's deprecated behind a flag |
00:38:20 | FromDiscord | <impbox [ftsf]> yeah i used to use it a bunch |
00:38:38 | FromDiscord | <impbox [ftsf]> nice for interactions between different types |
00:38:42 | FromDiscord | <Elegantbeef> I pretty much never touch the OOP stuff in Nim so havent ever really felt the need for it |
00:39:58 | FromDiscord | <jfmonty2> tbh the more I've used OOP patterns the more I tend to dislike them |
00:40:18 | FromDiscord | <jfmonty2> personal taste, but composition \> inheritance as far as I'm concerned, because it's more explicit |
00:41:10 | FromDiscord | <jfmonty2> having worked with one or two massively overly-abstracted codebases (cough Magento) I can say with absolute certainly that trying to chase a method call up through 6 levels of `AbstractBaseRouteHandlerGeneratorFactory` classes is Not Fun |
00:41:25 | FromDiscord | <impbox [ftsf]> magento makes me so upset |
00:41:33 | FromDiscord | <impbox [ftsf]> i used to have to work with it at previous job |
00:41:35 | FromDiscord | <impbox [ftsf]> D: D: D: |
00:41:35 | FromDiscord | <jfmonty2> it's just a big ball of cancer |
00:41:55 | FromDiscord | <jfmonty2> to add insult to injury I was the one who made the call to use it in the first place \:( |
00:41:59 | FromDiscord | <jfmonty2> I have learned my lesson |
00:42:17 | FromDiscord | <impbox [ftsf]> i don't mind light usage of classes/objects, but deep stuff like that is terrible |
00:42:37 | FromDiscord | <jfmonty2> yeah classes can be great, as long as you basically just use them as "state containers" so to speak |
00:42:50 | FromDiscord | <jfmonty2> i.e. some state, some functions that manipulate the state, and bob's yer uncle |
00:43:11 | FromDiscord | <impbox [ftsf]> when I worked with magento we solved problems by just avoiding it and talking to the DB directly |
00:43:27 | FromDiscord | <jfmonty2> That's very amusing because I've wound up with pretty much the exact same solution |
00:43:35 | FromDiscord | <impbox [ftsf]> which magento didn't like, but at least we could follow the code and it was fast |
00:44:02 | FromDiscord | <jfmonty2> e.g. our warehouse management software is bad at keeping Magento's inventory levels in sync, so I've had to write a nightly sync task that keeps them up to date, and at some point recently the Magento API just broke |
00:44:07 | FromDiscord | <jfmonty2> like it was responding 200, but no updates were happening |
00:44:10 | FromDiscord | <jfmonty2> so now I just talk to the DB directly |
00:44:14 | FromDiscord | <jfmonty2> as you said |
00:48:21 | FromDiscord | <impbox [ftsf]> we made a lot of money "fixing" magento performance for customers just by putting lots of caches in front of it |
00:48:38 | FromDiscord | <jfmonty2> yeah I love how that's always the solution |
00:48:48 | FromDiscord | <jfmonty2> like how they built support for Varnish because they couldn't do it fast enough themselves |
00:49:39 | FromDiscord | <jfmonty2> tbh I don't even blame PHP for the most part, I mean it doesn't help but I've seen fast sites written in PHP |
00:49:53 | FromDiscord | <jfmonty2> but Magento did it to themselves with shitty design choices |
00:50:06 | FromDiscord | <impbox [ftsf]> and made it worse with every release |
00:50:11 | FromDiscord | <jfmonty2> oh yes |
00:50:26 | FromDiscord | <jfmonty2> last time I tried to update it, I discovered that Elasticache is now a hard requirement (???) |
00:51:49 | FromDiscord | <jfmonty2> and I've lost count of the garbage 3rd-party extensions that are now bundled-by-default because somebody paid them money, and in some cases can't even be disabled because basic functionality now depends on them |
00:57:00 | FromDiscord | <impbox [ftsf]> yup, oh well, good incentive to get away from it |
00:57:16 | FromDiscord | <jfmonty2> some day I'll just write my own |
00:57:45 | FromDiscord | <jfmonty2> maybe in Nim! if I can convince my manager |
01:06:41 | FromDiscord | <ynfle (ynfle)> @beef I don't get this syntax `thing.base[: type].mitems` |
01:07:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3FVF |
01:08:05 | FromDiscord | <Elegantbeef> `[: type]` is just a solution for generics + method call syntax |
01:08:15 | FromDiscord | <Elegantbeef> you can of course do `seq[int](myDist).mitems` |
01:10:15 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3FVG |
01:10:44 | FromDiscord | <Elegantbeef> Ideally someone fixes borrowing generic symbols, but presently i think they only work for procs |
01:20:18 | FromDiscord | <demotomohiro> Nim needs `[:type]` syntax because Nim use`[]` for both generic parameter and array/seq element access? |
01:20:57 | FromDiscord | <Elegantbeef> Yes it needs it to know whether it's `[](a.b)` or `b[](a)` |
01:21:53 | FromDiscord | <ynfle (ynfle)> Thanks. For some reason that didn't work for me |
01:22:04 | FromDiscord | <Elegantbeef> It doesnt or didnt? |
01:22:31 | FromDiscord | <ynfle (ynfle)> It does now, but what I tried to do, didn't work |
01:25:49 | FromDiscord | <ynfle (ynfle)> nvm, I think it's because I forgot the `var` in the proc definition |
01:25:53 | FromDiscord | <ynfle (ynfle)> Don't need it anyway |
01:36:18 | FromDiscord | <demotomohiro> There are not many charactors that can be used like parenthesis in ascii code and some programming language reuse same charactor for different thing. C++ uses '>' for compare, bit shift and template parameter and `vector<vector<int>>` caused problem.↵If Nim could use unicode parenthesis like 【】 or「」 and didn't reuse them for different things, Nim would not need to create a inconsistent `[:type]` syntax. |
01:36:46 | FromDiscord | <Elegantbeef> Sure but that's also a very annoying thing to write on the standard US keyboard |
01:37:06 | FromDiscord | <Elegantbeef> The `[: T]` is a nice solution to the problem imo |
01:42:41 | FromDiscord | <Elegantbeef> Well the proof of concept macro REPL has started 😀 |
01:49:22 | FromDiscord | <demotomohiro> I thought always use `[:T]` for every generic parameters would be consistent coding rule but Nim says `var x: seq[:int]` is invalid indentation. |
01:50:15 | FromDiscord | <Elegantbeef> Well it's an escape hatch for `[]` |
01:51:30 | FromDiscord | <Elegantbeef> I think it's fine to not allow `seq[: T]` since it's odd and bad style in this case |
01:51:43 | FromDiscord | <Elegantbeef> There is no ambiguity to solve there |
01:56:08 | FromDiscord | <demotomohiro> But there are 2 different ways to specify generic parameters and I have to choose right one o n the right place is inconsistent and not simple. |
01:58:53 | FromDiscord | <demotomohiro> I can use one syntax to specify generic parameter in anywhere would be nice. |
02:04:38 | FromDiscord | <Elegantbeef> Well suggest a way of doing it that isnt hideous or confusing 😛 |
02:11:54 | FromDiscord | <demotomohiro> How about to `[.T.]` syntax? It use '.' like pragma. AFAIF, Nim never use '.' for suffix nor prefix. I don't think it looks so odd. |
02:13:03 | FromDiscord | <demotomohiro> AFAIK, Nim never use '.' for suffix nor prefix. |
02:15:26 | FromDiscord | <Elegantbeef> I feel like making generics always `[.T.]` falls under hideous |
02:15:32 | FromDiscord | <Elegantbeef> Pragmas are already hideous |
02:19:27 | FromDiscord | <demotomohiro> That idea was already suggested in 2015: https://github.com/nim-lang/Nim/issues/3502 |
02:22:33 | FromDiscord | <cpunion (Li Jie)> sent a code paste, see https://paste.rs/7E0 |
02:27:43 | FromDiscord | <demotomohiro> This idea looks best but he changed mind: https://github.com/nim-lang/Nim/issues/3502#issuecomment-152781004 |
02:41:59 | * | src quit (Quit: Leaving) |
03:24:53 | * | arkurious quit (Quit: Leaving) |
03:44:52 | FromDiscord | <Rika> pragmas do not look hideous to me lol |
03:52:12 | FromDiscord | <hyu1996> what is this https://media.discordapp.net/attachments/371759389889003532/912913462856941609/unknown.png |
03:53:42 | FromDiscord | <hyu1996> garbled code? |
04:04:18 | FromDiscord | <Rika> broken linK? |
04:04:20 | FromDiscord | <Rika> dunno |
04:06:02 | * | supakeen quit (Quit: WeeChat 3.3) |
04:06:31 | * | supakeen joined #nim |
04:11:42 | * | ox joined #nim |
04:12:29 | * | ox is now known as oz |
04:51:42 | * | rockcavera quit (Remote host closed the connection) |
05:23:04 | * | elph quit (Quit: Connection closed for inactivity) |
06:13:00 | FromDiscord | <claude> pragmas don't look bad, it's just that the symbol characters around them are distracting from the usually ~4 letter words inside them that are important, just curlies would have the same problem |
06:17:24 | FromDiscord | <claude> they're still better than things like java annotations imo |
06:18:32 | FromDiscord | <claude> though that might be because they come after the declaration, which i think is pretty uncommon |
07:29:25 | FromDiscord | <𝙧𝙚𝙢> is there a more idiomatic way of doing this loopign structure in nim |
07:29:33 | FromDiscord | <𝙧𝙚𝙢> the while(1) i mean |
07:29:34 | FromDiscord | <𝙧𝙚𝙢> sent a code paste, see https://play.nim-lang.org/#ix=3FWz |
07:30:39 | FromDiscord | <Elegantbeef> `while true` |
07:30:56 | FromDiscord | <haxscramper> idiomatic nim would probably use less continue/returns, but that's up to you |
07:31:05 | FromDiscord | <haxscramper> "structured control flow" |
07:31:07 | FromDiscord | <𝙧𝙚𝙢> well i need to build up a ast |
07:31:12 | FromDiscord | <𝙧𝙚𝙢> so idk if i have a choice |
07:32:15 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3FWA |
07:32:24 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3FWB |
07:32:28 | FromDiscord | <Elegantbeef> and even then the `return n ` is questionable |
07:32:32 | FromDiscord | <Elegantbeef> There we go |
07:33:22 | FromDiscord | <haxscramper> (edit) "https://play.nim-lang.org/#ix=3FWB" => "https://play.nim-lang.org/#ix=3FWC" |
07:34:17 | FromDiscord | <𝙧𝙚𝙢> slight issue my lexer has the tokens emitted for `1 + 2` as `[tkInt, tkPlus, tkInt]` - there is no `Add` token |
07:34:36 | FromDiscord | <haxscramper> Ins't `Plus` == `Add`? |
07:34:53 | FromDiscord | <𝙧𝙚𝙢> wait |
07:34:53 | FromDiscord | <𝙧𝙚𝙢> yeah |
07:35:44 | FromDiscord | <𝙧𝙚𝙢> wait howd you do `new` in nim |
07:35:58 | FromDiscord | <𝙧𝙚𝙢> i have a `Node(kind: thing, ...)` struct |
07:36:29 | FromDiscord | <haxscramper> you can do func newTree(kind: NodeKind, subnodes: varargs[Node]): Node |
07:36:31 | FromDiscord | <𝙧𝙚𝙢> this basically |
07:36:33 | FromDiscord | <𝙧𝙚𝙢> sent a code paste, see https://play.nim-lang.org/#ix=3FWE |
07:36:38 | FromDiscord | <haxscramper> first of, |
07:36:44 | FromDiscord | <𝙧𝙚𝙢> hm? |
07:40:53 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3FWF |
07:41:03 | FromDiscord | <𝙧𝙚𝙢> no nim uses nnk |
07:41:22 | FromDiscord | <haxscramper> I have a compiler fatigue then, it uses `nk` |
07:41:35 | FromDiscord | <𝙧𝙚𝙢> good idea changing it tho |
07:41:46 | FromDiscord | <𝙧𝙚𝙢> so can u give an example of how i can implement subnodes |
07:44:16 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3FWH |
07:44:24 | FromDiscord | <haxscramper> The proc above is a constructor |
07:44:50 | FromDiscord | <Elegantbeef> There are some sexy nodes 😛 |
07:45:00 | FromDiscord | <haxscramper> And you don't have the `Add/Plus/Minus` nodes for expressios, you have `Infix[Ident("+"), <some-node>, <some-node>]` |
07:45:13 | FromDiscord | <𝙧𝙚𝙢> this is mildly confusing, could u give an example of using it for an add node and string node? |
07:45:24 | FromDiscord | <haxscramper> Same for `Call[Ident("+"), <arg-1>, <arg-2>]` |
07:45:34 | FromDiscord | <𝙧𝙚𝙢> In reply to @𝙧𝙚𝙢 "this is mildly confusing,": ^ |
07:45:57 | FromDiscord | <haxscramper> `func newXxxNode(strVal: string): XXXNode = XXXNode(kind: xxxStr, strVal: strVal)` |
07:46:02 | FromDiscord | <haxscramper> Like this? |
07:46:10 | FromDiscord | <𝙧𝙚𝙢> i mean the whole thing |
07:46:16 | FromDiscord | <𝙧𝙚𝙢> i dotn really understand the code |
07:47:37 | FromDiscord | <𝙧𝙚𝙢> In reply to @haxscramper "Same for `Call[Ident("+"), <arg-1>,": especially this part |
07:48:16 | FromDiscord | <𝙧𝙚𝙢> @haxscramper |
07:48:27 | FromDiscord | <𝙧𝙚𝙢> could u epxlain it please |
07:48:30 | FromDiscord | <haxscramper> yes, give be a second to write an example |
07:48:35 | FromDiscord | <𝙧𝙚𝙢> okay |
07:55:47 | * | PMunch joined #nim |
07:57:57 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3FWK |
07:58:28 | FromDiscord | <Elegantbeef> Damn hax you went all out |
07:58:32 | FromDiscord | <Elegantbeef> +1 to you |
07:59:07 | FromDiscord | <haxscramper> etc |
07:59:10 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3FWL |
07:59:26 | FromDiscord | <𝙧𝙚𝙢> is this some cursed nim java hybrid 🤔 |
07:59:36 | FromDiscord | <haxscramper> I suppose `Token` is a current token that you edit somewhere else, so you can have a |
07:59:39 | FromDiscord | <𝙧𝙚𝙢> tysm tho this makes much more sense |
07:59:55 | FromDiscord | <𝙧𝙚𝙢> `token` is just `parser.peek` |
08:00:02 | FromDiscord | <haxscramper> `func newIdent(token: TokenType): XXXNode = newXXXIndet(token.strVal)` |
08:00:03 | FromDiscord | <𝙧𝙚𝙢> just returns the `n`th token |
08:00:50 | FromDiscord | <haxscramper> also look at the `lispRepr` - you can see the utility of the single `subnodes` field |
08:01:12 | FromDiscord | <haxscramper> imagine you had to write something like that with separate fields for all the nodes and then repeatedly edit it each time you add a new tree kind |
08:01:13 | FromDiscord | <𝙧𝙚𝙢> is this a builtin function were overriding or? |
08:01:35 | FromDiscord | <haxscramper> no, it is just a common convention |
08:01:51 | FromDiscord | <𝙧𝙚𝙢> ah |
08:02:05 | FromDiscord | <𝙧𝙚𝙢> also only other thing is im struggling to see where subnodes is being populated |
08:02:59 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/inH |
08:03:01 | FromDiscord | <haxscramper> but none of them are "built-in" |
08:03:28 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3FWP |
08:03:34 | FromDiscord | <haxscramper> `@` converts `varargs` tot he `seq[Node]` |
08:03:40 | FromDiscord | <𝙧𝙚𝙢> ohh i see |
08:05:18 | FromDiscord | <𝙧𝙚𝙢> so Infix is used instead of Add/Sub/Mul/Div? |
08:05:18 | * | blackbeard420_ joined #nim |
08:05:47 | * | blackbeard420 quit (Ping timeout: 264 seconds) |
08:06:17 | * | systemdsucks quit (Ping timeout: 250 seconds) |
08:06:23 | * | joshbaptiste quit (Ping timeout: 264 seconds) |
08:06:32 | FromDiscord | <haxscramper> Yes. You can use dumpTree from std/macros and see how nim parses this |
08:06:44 | FromDiscord | <𝙧𝙚𝙢> ahh ok |
08:06:53 | FromDiscord | <𝙧𝙚𝙢> also off topic but whats a better way to structure this |
08:06:53 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3FWS |
08:06:55 | FromDiscord | <𝙧𝙚𝙢> spam incoming |
08:07:12 | FromDiscord | <𝙧𝙚𝙢> this is very ugly code |
08:07:12 | FromDiscord | <𝙧𝙚𝙢> sent a code paste, see https://play.nim-lang.org/#ix=3FWT |
08:07:20 | FromDiscord | <𝙧𝙚𝙢> however its just a list of tokens |
08:07:26 | FromDiscord | <𝙧𝙚𝙢> so idk if i can use the same as the AST |
08:07:57 | * | systemdsucks joined #nim |
08:08:09 | * | joshbaptiste joined #nim |
08:08:54 | FromDiscord | <𝙧𝙚𝙢> i just dont want this to be this ugly if its possible |
08:09:21 | FromDiscord | <𝙧𝙚𝙢> its less than it was before a day or two ago but still a lot of ugliness |
08:11:41 | FromDiscord | <𝙧𝙚𝙢> and how would i better name them than tk |
08:11:42 | FromDiscord | <haxscramper> Tokens are most ok I guess, but it of course depends on crazy you want to go |
08:12:00 | FromDiscord | <haxscramper> In reply to @𝙧𝙚𝙢 "and how would i": ctk ? Just first letter of the language |
08:12:05 | FromDiscord | <haxscramper> qtk |
08:12:13 | FromDiscord | <haxscramper> Well, you get the idea |
08:12:16 | FromDiscord | <𝙧𝙚𝙢> i see |
08:12:59 | FromDiscord | <haxscramper> I mean there is not a lot of space for maneuvering anyway, it is a token kind, so you would probably end up with tk somewhere |
08:13:42 | FromDiscord | <𝙧𝙚𝙢> yeah |
08:17:08 | FromDiscord | <𝙧𝙚𝙢> also whats func vs proc |
08:19:40 | FromDiscord | <Elegantbeef> `func` is pure in that it cannot have side effects |
08:19:58 | FromDiscord | <Elegantbeef> so you can only mutate state of things passed in as `var` |
08:20:24 | FromDiscord | <𝙧𝙚𝙢> i see |
08:24:21 | FromDiscord | <haxscramper> for that to be true enable `{.experimental: "strictFuncs".}`, otherwise you can also mutate `ref`, which is most likely not what you want if you use `func` |
08:28:12 | FromDiscord | <evoalg> I just found out that `.add` not like python's `.append` in that it seems to do this conversion ... https://play.nim-lang.org/#ix=3FX0 |
08:31:41 | FromDiscord | <Elegantbeef> It doesnt get converted there is a `seq.add(seq)` |
08:31:51 | FromDiscord | <Elegantbeef> Procedures can overload! |
08:32:01 | FromDiscord | <evoalg> ahhhh |
08:32:11 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/912983926916661288/image.png |
08:32:23 | FromDiscord | <Elegantbeef> Dont know if they're contigious in the docs |
08:32:50 | FromDiscord | <𝙧𝙚𝙢> In reply to @haxscramper "your code here would": btw i tried to implement this and it doesnt work |
08:33:02 | FromDiscord | <𝙧𝙚𝙢> ` of rtkPlus: node = newRuneNode(rnInfix, newRuneIdent(token.strVal), node, parseFactor)↵` |
08:33:30 | FromDiscord | <𝙧𝙚𝙢> sent a code paste, see https://play.nim-lang.org/#ix=3FX1 |
08:33:43 | FromDiscord | <haxscramper> `parseFactor()` |
08:33:50 | FromDiscord | <haxscramper> you passed a proc, not proc's resultt |
08:33:58 | FromDiscord | <𝙧𝙚𝙢> still not working |
08:34:03 | * | xet7 quit (Remote host closed the connection) |
08:34:12 | FromDiscord | <𝙧𝙚𝙢> you never defined a newXXXnode that takes this params |
08:34:23 | FromDiscord | <𝙧𝙚𝙢> unless u meant newTree? |
08:34:33 | FromDiscord | <haxscramper> yes, new tree |
08:34:52 | FromDiscord | <haxscramper> well, it is a pseudocode anywya |
08:35:09 | FromDiscord | <haxscramper> yes, I messed up names |
08:35:14 | * | xet7 joined #nim |
08:35:20 | FromDiscord | <𝙧𝙚𝙢> yeah just confused me a bit lol |
08:45:45 | FromDiscord | <𝙧𝙚𝙢> @haxscramper seeing as u have knowledge w/ parsing i assume, could u help me w/ why my parseFactor function just recurses forever? |
08:45:55 | FromDiscord | <𝙧𝙚𝙢> sent a code paste, see https://play.nim-lang.org/#ix=3FX3 |
08:45:56 | FromDiscord | <𝙧𝙚𝙢> this is all the relavent code |
08:46:06 | FromDiscord | <𝙧𝙚𝙢> im testing it w/ expression `2 4` |
08:47:22 | FromDiscord | <haxscramper> You call parse factor immediately in the parse factor, it is not possible to parse infix expressions using simple recursive descent parser |
08:47:39 | FromDiscord | <𝙧𝙚𝙢> so what should i do then |
08:48:02 | FromDiscord | <haxscramper> You need to use a Pratt parser, or precedence climbing algorithm, or shunting-yard, IIRC those are the alternatives |
08:48:21 | FromDiscord | <𝙧𝙚𝙢> brb killing myself |
08:48:25 | FromDiscord | <𝙧𝙚𝙢> this sounds way harder |
08:49:55 | FromDiscord | <haxscramper> https://github.com/haxscramper/hack/blob/4b3672348cef91bb8e9441d29c127e73be5d4b69/testing/nim/wip1/shunting_yard_parser.nim |
08:50:13 | FromDiscord | <haxscramper> https://github.com/haxscramper/hack/blob/master/testing-impls/parsing/pratt.nim |
08:50:31 | FromDiscord | <haxscramper> those won't compile beacuse I already broke all dependencies twice |
08:51:12 | FromDiscord | <haxscramper> but it worked at some point at least |
08:51:51 | FromDiscord | <𝙧𝙚𝙢> looks complex and confusing |
08:55:13 | FromDiscord | <𝙧𝙚𝙢> @haxscramper so hwo do i convert my code to shunting yard or do i only do it for my factor and term parsing functions? |
08:55:31 | FromDiscord | <haxscramper> only for expression parsers |
08:56:09 | FromDiscord | <𝙧𝙚𝙢> how do i create a stack in nim |
08:56:16 | FromDiscord | <𝙧𝙚𝙢> is there a data type |
08:56:58 | FromDiscord | <that_dude> I want to confirm my email for the forums, but nothing was sent to me? How do I confirm it? |
08:57:22 | FromDiscord | <haxscramper> `seq.add`, `seq.pop`↵(@𝙧𝙚𝙢) |
08:57:30 | FromDiscord | <haxscramper> ping @dom96↵(@that_dude) |
08:58:13 | FromDiscord | <𝙧𝙚𝙢> ok thanks |
08:58:16 | FromDiscord | <that_dude> Well @dom96 If you're awake, how would I go about it? (sorry for ping) |
09:02:01 | FromDiscord | <𝙧𝙚𝙢> sent a code paste, see https://play.nim-lang.org/#ix=3FX8 |
09:03:45 | * | neurocyte0132889 joined #nim |
09:03:45 | * | neurocyte0132889 quit (Changing host) |
09:03:45 | * | neurocyte0132889 joined #nim |
09:05:26 | FromDiscord | <𝙧𝙚𝙢> @haxscramper any idea because if i just remove the return it will break the entire RD parser |
09:06:20 | FromDiscord | <𝙧𝙚𝙢> but i need to push it to the operand stack which im not sure how to do both |
09:06:24 | FromDiscord | <haxscramper> I recommend you to read about the algorithm first, because it is not exactly a trivial hack-in, and it is better to understand what is going on |
09:06:24 | FromDiscord | <𝙧𝙚𝙢> without breaking the entire thing |
09:06:52 | FromDiscord | <𝙧𝙚𝙢> i have a wikipedia article up |
09:07:00 | FromDiscord | <𝙧𝙚𝙢> im just wondering how the fuck do i get this to not break |
09:07:35 | FromDiscord | <haxscramper> I never actually wrote a proper parser for whole expressions, I just had this for some calculator thing |
09:07:53 | FromDiscord | <𝙧𝙚𝙢> ok well how would i get this working though |
09:08:21 | FromDiscord | <haxscramper> https://gist.github.com/haxscramper/3562fa8fee4726d7a30a013a37977df6#examples there are quite a few implementations that you can look at |
09:09:57 | FromDiscord | <𝙧𝙚𝙢> https://github.com/nc-x/crafty/blob/master/src/craftypkg/parser.nim↵↵this is just using RD lol |
09:21:11 | * | advesperacit joined #nim |
09:24:45 | * | Guest3758 joined #nim |
09:26:17 | Guest3758 | Hello. New to nim. I'm trying to create a template/macro that will print an expression then evaluate it. Something like: demo 1+1 => echo "1+1", 1+1 |
09:27:07 | Guest3758 | I can't splice the expression inside the string. I've tried: |
09:27:08 | Guest3758 | macro demo(expr) = quote("@") do: echo "@expr = ", @expr |
09:27:18 | Guest3758 | but it doesn't work. What do I miss? |
09:28:26 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3FXe here you go |
09:28:40 | FromDiscord | <Elegantbeef> Oh i misread what you wanted but close enough 😀 |
09:29:16 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3FXf for that proper thing |
09:29:30 | FromDiscord | <Elegantbeef> My assumption is that it was printing `@expr = 1+ 1` ? |
09:30:16 | FromDiscord | <Elegantbeef> If so that's cause you should do before `let strExpr = expr.repr` `echo @strExpr, " = ", @expr` |
09:31:14 | Guest3758 | Thanks! |
09:31:15 | Guest3758 | template demo(expr) = echo astToStr(expr), " = ", `expr` |
09:31:18 | Guest3758 | Is what I waned |
09:31:23 | Guest3758 | *wanted |
09:31:37 | FromDiscord | <Elegantbeef> For stuff like this templates are more suited anyway |
09:31:51 | FromDiscord | <Elegantbeef> templates for copy pastes, macros for introspection required logic |
09:37:33 | FromDiscord | <𝙧𝙚𝙢> this algorithm is insanely complex |
09:42:14 | * | fputs0 joined #nim |
09:44:06 | * | fputs quit (Ping timeout: 245 seconds) |
09:44:06 | * | fputs0 is now known as fputs |
09:51:47 | * | neurocyte0132889 quit (Quit: The Lounge - https://thelounge.chat) |
09:52:45 | * | neurocyte0132889 joined #nim |
09:52:45 | * | neurocyte0132889 quit (Changing host) |
09:52:45 | * | neurocyte0132889 joined #nim |
09:57:50 | PMunch | @Guest3758, just in case you want a ready made solution: https://nim-lang.org/docs/sugar.html#dump.m%2Cuntyped |
10:02:09 | * | Guest3758 quit (Ping timeout: 256 seconds) |
10:03:54 | FromDiscord | <hyu1996> https://play.nim-lang.org/#ix=3FXm how to make it work |
10:05:10 | FromDiscord | <Elegantbeef> i assume someone realized it was just `.subobj` away 😀 |
10:12:47 | FromDiscord | <hyu1996> sorry for my mistake |
10:13:30 | FromDiscord | <hyu1996> typo |
10:13:42 | FromDiscord | <Elegantbeef> Dont apologize, you did nothing wrong! |
10:14:12 | FromDiscord | <Rika> Unlike you beef you do everything wrong |
10:14:17 | FromDiscord | <Rika> Smh |
10:14:24 | FromDiscord | <Elegantbeef> Indeed |
10:19:45 | * | rlp10 quit (Ping timeout: 250 seconds) |
10:20:01 | * | rlp10 joined #nim |
10:34:46 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3FXr |
10:35:49 | FromDiscord | <enthus1ast> `var flagsArr = [0x01'u8, 0x20'u8]` |
10:35:51 | FromDiscord | <enthus1ast> ... |
10:36:00 | FromDiscord | <enthus1ast> thanks guys and gals \:) |
10:36:41 | FromDiscord | <Elegantbeef> is the `...` you solving it? |
10:36:45 | FromDiscord | <enthus1ast> yes |
10:36:57 | FromDiscord | <Elegantbeef> Second one of these, rubber ducking is fun! |
10:37:40 | FromDiscord | <enthus1ast> thats why adding types to vars is a good thing, would have catched it immediately |
10:38:01 | FromDiscord | <tandy> i think i just found a unittest bug |
10:38:04 | FromDiscord | <Rika> I’m assuming the array was of 64 but numbers |
10:38:08 | FromDiscord | <Rika> Bit |
10:38:11 | FromDiscord | <enthus1ast> yes |
10:38:16 | FromDiscord | <Rika> Lol |
10:38:44 | FromDiscord | <tandy> aparently having 13 checks in a suite is too many? |
10:39:11 | FromDiscord | <Rika> Too many how? |
10:39:16 | FromDiscord | <Rika> What issue did you run into |
10:40:59 | FromDiscord | <tandy> i have a suite with 13 tests, each has a check |
10:41:35 | FromDiscord | <tandy> sent a code paste, see https://play.nim-lang.org/#ix=3FXt |
10:41:51 | FromDiscord | <tandy> but if i comment out hte check it runs |
10:42:22 | FromDiscord | <enthus1ast> so can you comment ANY one of your tests, or just the last one? |
10:42:52 | FromDiscord | <enthus1ast> `Error: generic instantiation too nested` imho indicates that the compiler tries to unwrap a generic call |
10:43:05 | FromDiscord | <enthus1ast> recursively until it fails |
10:43:36 | FromDiscord | <tandy> hm actualy using a new suite didnt help |
10:43:58 | FromDiscord | <tandy> any `check` |
10:44:16 | FromDiscord | <tandy> oh wait no |
10:44:17 | FromDiscord | <tandy> not any check |
10:44:33 | FromDiscord | <tandy> sent a code paste, see https://play.nim-lang.org/#ix=3FXv |
10:44:40 | FromDiscord | <tandy> sent a code paste, see https://play.nim-lang.org/#ix=3FXw |
10:44:42 | FromDiscord | <tandy> just checks that look like these |
10:49:30 | FromDiscord | <hmmm> hoy beauties! if I have an enum directions north south west, can I add east at runtime? |
10:49:47 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3FXy |
10:50:34 | FromDiscord | <tandy> il try |
10:51:00 | FromDiscord | <enthus1ast> @hmmm\: no |
10:51:15 | FromDiscord | <hmmm> 😓 |
10:51:46 | FromDiscord | <tandy> this worked |
10:51:49 | FromDiscord | <tandy> sent a code paste, see https://play.nim-lang.org/#ix=3FXA |
10:52:09 | FromDiscord | <enthus1ast> yeah strange |
10:52:34 | FromDiscord | <enthus1ast> might actually be a bug in unittest |
10:53:52 | FromDiscord | <enthus1ast> @hmmm\: when you'r goal is to add another value to an enum |
10:54:03 | FromDiscord | <tandy> hmm how can i find if ther is an existing issue.. |
10:55:21 | FromDiscord | <enthus1ast> @hmmm\: i mean, what could be potentially be the goal here? Adding an enum at runtime makes no sense (or i can't imagine one to be honest) |
10:56:58 | FromDiscord | <hmmm> actually I think I don't really need to use an enum (well except for the fact I need to rewrite the entire app lol), I need to use some kind of data structure that allows the user to add new options to it |
10:57:23 | FromDiscord | <enthus1ast> while running? |
10:57:27 | FromDiscord | <hmmm> yep |
10:57:41 | FromDiscord | <enthus1ast> yeah then better use a seq, or table, or hashset |
10:58:19 | FromDiscord | <hmmm> hm yea but the enum was comfy because it kinda restricted the flow of it |
10:58:28 | FromDiscord | <hmmm> maybe I'll just hack a seq |
10:58:34 | FromDiscord | <tandy> and i dont really know how to make an MWE, |
10:58:46 | FromDiscord | <enthus1ast> MWE? |
10:59:05 | FromDiscord | <tandy> minmum working example |
10:59:20 | FromDiscord | <tandy> i wrote this but it works.. |
10:59:21 | FromDiscord | <tandy> sent a code paste, see https://play.nim-lang.org/#ix=3FXD |
11:01:53 | FromDiscord | <enthus1ast> maybe rip everything out of board that does not get touched by getPlayerMoves(board.human) |
11:31:31 | PMunch | When I do `createShared` and `freeShared`, can I but a GC'ed element like a string into that object? |
11:31:49 | PMunch | The data might be used and freed by a different thread than the one which allocated it |
11:34:37 | FromDiscord | <Rika> Not sure how that would fuck with the reference counting |
11:34:46 | FromDiscord | <KittyBorgX> heyy, im new here! |
11:34:50 | PMunch | Yeah that's what I'm afraid of |
11:35:03 | PMunch | I do use ORC by the way |
11:35:08 | PMunch | Welcome @KittyBorgX! |
11:35:10 | FromDiscord | <Rika> Hello |
11:40:31 | FromDiscord | <KittyBorgX> In reply to @PMunch "Welcome <@786599434960109568>!": Thankss!! |
11:40:48 | FromDiscord | <impbox [ftsf]> Welcome!! |
11:41:20 | FromDiscord | <KittyBorgX> ty!! |
11:41:44 | FromDiscord | <KittyBorgX> i want to learn and start using nim for daily basis and for my compiler development! |
11:42:01 | FromDiscord | <KittyBorgX> are there any good resources like yt vids or ebooks? |
11:42:02 | PMunch | Sounds like a good fit! |
11:42:31 | PMunch | This is a good place to start: https://nim-lang.org/documentation.html |
11:42:43 | FromDiscord | <KittyBorgX> In reply to @PMunch "This is a good": Thanks!! |
11:42:44 | FromDiscord | <enthus1ast> Hi @KittyBorgX |
11:42:48 | FromDiscord | <KittyBorgX> hey1 |
11:43:35 | FromDiscord | <KittyBorgX> i started my journey in nim cuz i find it to be the perfect place between js / cpp / python and rust |
11:43:45 | FromDiscord | <KittyBorgX> all the features in one language hehe |
11:44:09 | PMunch | Sounds familiar :P |
11:45:06 | FromDiscord | <impbox [ftsf]> I think a good way to get familiar with nim is to port something you've written in another language to it |
11:45:30 | FromDiscord | <impbox [ftsf]> It's good to have a goal |
11:45:48 | FromDiscord | <impbox [ftsf]> Other than just "i want to learn nim" |
11:46:56 | PMunch | Or just some small project that you want to make |
11:48:48 | PMunch | Ugh, this is why I wish the new ARC/ORC stuff was documented better.. |
11:49:35 | PMunch | Araq, ARC/ORC should really be documented better, specifically I want to know how it works across threads |
11:52:18 | FromDiscord | <haxscramper> what specific points are missing from the docs |
11:52:51 | FromDiscord | <KittyBorgX> In reply to @impbox "I think a good": yeah! i was finding a language to port my compiler written in rust cuz rust is a pain to work with and i stumbled upon nim! |
11:53:00 | PMunch | @haxscramper, I just struggle with figuring out what I can and can't do when it comes to threads |
11:53:04 | FromDiscord | <haxscramper> I don't know anything about arc-threading interaction, but surely your frustration is not just general "bad docs", you have some specific pain points |
11:53:20 | FromDiscord | <KittyBorgX> does nim have an init tool, like `cargo new --bin myproject` ? |
11:53:27 | FromDiscord | <haxscramper> `nimble init` |
11:54:07 | PMunch | This time I interact with a C library which can hold a reference for me and give it back to me when I get called later (which might not occur on the same thread). I use createShared for this, which works fine, but can I put GC'ed memory in that object? |
11:54:41 | FromDiscord | <KittyBorgX> In reply to @haxscramper "`nimble init`": thanks! i wasnt aware of `nimble` being there, i was aware only of the `nim` command! |
11:55:41 | PMunch | Last time I was wondering if I could "steal" GCed memory from a thread. If one thread has allocated memory and put it in e.g. an array. Then another thread who knows where in memory this array lies, copies out the reference to this object and removes it from the array (either protected by a lock or with an atomic operation). |
11:56:08 | PMunch | Would that work? Or does the thread have to do something in order to move memory from one thread to another |
11:56:38 | PMunch | Just general things which I feel like I would be able to reason about if I had a document that shed some more light on the details of how ARC/ORC works |
11:57:00 | PMunch | @KittyBorgX, nimble is the most common package manager/build tool for Nim |
11:57:47 | FromDiscord | <KittyBorgX> In reply to @PMunch "<@786599434960109568>, nimble is the": ah, thanks for letting me know! |
12:02:48 | FromDiscord | <Yardanico> In reply to @PMunch "This time I interact": I think so, as long as you GC_ref it |
12:04:31 | * | xet7_ joined #nim |
12:04:39 | PMunch | That's my whole problem, I can't "think" I know what I'm doing, I need to "know" what will and won't work |
12:06:01 | * | supakeen quit (Quit: WeeChat 3.3) |
12:06:32 | * | supakeen joined #nim |
12:07:46 | * | xet7 quit (Ping timeout: 260 seconds) |
12:24:27 | FromDiscord | <hmmm> this is hell my desktop pc has 4 spaces for tab and my laptop has 2 spaces and all my files are fucky aaaaaa |
12:25:01 | FromDiscord | <hmmm> 😒 |
12:26:00 | PMunch | glhf |
12:27:59 | FromDiscord | <tandy> where is your compiler project?↵(@KittyBorgX) |
12:31:33 | FromDiscord | <xflywind> In reply to @PMunch "<@608382355454951435>, I just struggle": IMO, when it comes to threads with ARC, better to treat it as C++. Use smart pointers + ARC and don't use ref. Alternative way is using `std/isolated` which only works for acyclic refs. |
12:32:15 | FromDiscord | <xflywind> (edit) "refs." => "refs atm." |
12:33:06 | PMunch | That requires that I'm comfortable with how you would do it in C++, which I'm not |
12:33:16 | PMunch | I would do it the C way if I had to handle this in C++ |
12:47:40 | FromDiscord | <tandy> https://github.com/nim-lang/Nim/issues/19189 |
12:48:04 | arkanoid | Is there a nim lib for network (graph) analysis? Like networkx for python |
12:48:08 | FromDiscord | <tandy> worlds biggest mwe |
12:48:11 | arkanoid | Or a wrapper |
12:48:19 | FromDiscord | <haxscramper> no and no |
12:48:32 | arkanoid | K thanks |
12:52:39 | arkanoid | If the world picked nim instead of python for science, now we would have a cure for cancer, avoided covid, and turned nuclear research into proper energy production. |
12:53:53 | FromDiscord | <Rika> Time for you to port it xd |
12:56:52 | FromDiscord | <haxscramper> Maybe at some point hcparse will work just the way i want it it work |
12:56:52 | FromDiscord | <haxscramper> right now it just 1v1 with me against whole cxx ecosystem |
12:57:10 | FromDiscord | <haxscramper> and then I will port everything there is to port |
12:57:57 | FromDiscord | <Yardanico> In reply to @arkanoid "Or a wrapper": you can use nimpy to interact with python modules |
12:58:14 | FromDiscord | <Yardanico> but the performance will actually be a bit worse than if you were to call it from python itself because of the FFI |
12:58:24 | FromDiscord | <Yardanico> of course if you have some heavy calculations that don't need networkx you can do them in the nim side |
12:59:13 | arkanoid | Sure, I got the proprotype working in python, and hell yeah it works but can't cope with the large amout of data in time. Networkx is a pure python lib |
12:59:24 | FromDiscord | <Yardanico> well, then using nimpy won't help |
12:59:31 | FromDiscord | <Yardanico> you can try alternative python implementations like PyPy |
12:59:39 | FromDiscord | <Yardanico> PyPy is mostly compatible with CPython and has a JIT |
13:04:55 | arkanoid | I could try, yeah |
13:08:49 | arkanoid | Pypy is not compatible with the modules I need. Best bet to split which code to jit or not. Numba joins the party |
13:08:57 | FromDiscord | <Yardanico> which ones? |
13:08:59 | FromDiscord | <Yardanico> just curious |
13:09:10 | FromDiscord | <Yardanico> afaik PyPy has compat with almost all python modules out there nowadays |
13:09:27 | FromDiscord | <Yardanico> and I guess it's a discussion better suited for #nim-offtopic :) |
13:15:33 | * | rockcavera joined #nim |
13:15:34 | * | rockcavera quit (Changing host) |
13:15:34 | * | rockcavera joined #nim |
13:15:35 | FromDiscord | <tandy> So true↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>) |
13:15:56 | FromDiscord | <tandy> il pray↵(@haxscramper) |
13:41:37 | arkanoid | Yardanico: http://packages.pypy.org/##pandas |
13:41:53 | FromDiscord | <Yardanico> it does work though, this is an outdated list kind of |
13:42:24 | arkanoid | well, pip installing now from scratch (not using conda, but binary from official page) |
13:42:31 | arkanoid | btw, sorry, I'm offtopic |
13:42:49 | FromDiscord | <Yardanico> yeah we have #nim-offtopic for that |
13:47:54 | * | blackbeard420_ quit (Quit: ZNC 1.8.2 - https://znc.in) |
13:48:05 | * | blackbeard420 joined #nim |
13:50:32 | PMunch | @arkanoid, in general if no-one is talking on-topic then straying off-topic in this channel is fine |
13:51:48 | arkanoid | yeah but talking about something that duck types in official nim channel makes me feel guilty |
13:57:25 | * | Vladar joined #nim |
14:36:25 | * | src joined #nim |
14:56:21 | FromDiscord | <lenis> sent a code paste, see https://play.nim-lang.org/#ix=3FYV |
14:56:34 | FromDiscord | <lenis> because, if I move useName to another file the type inference doesnt work, but the code still runs |
14:57:29 | FromDiscord | <enthus1ast> template useName(name\: string) = .... |
14:57:47 | FromDiscord | <lenis> yes ok, but then you have to pass it in no? |
14:57:54 | FromDiscord | <enthus1ast> yes |
14:58:05 | FromDiscord | <lenis> thats not as nice from a DSL perspective |
15:02:59 | FromDiscord | <lenis> sent a code paste, see https://play.nim-lang.org/#ix=3FZb |
15:03:05 | FromDiscord | <lenis> I tried to look through the manual but couldnt find anything |
15:04:49 | FromDiscord | <IsaacPaul> 🙃 |
15:04:56 | PMunch | Hmm, I'm wondering if I should just write documentation on ARC and make up the details I'm unsure about. Then PR that to the repository and see if I can get people to elaborate on this stuff that way :P |
15:05:08 | FromDiscord | <IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3FZd |
15:05:49 | FromDiscord | <lenis> yeah i get that works, but then you have to pass around the context |
15:06:02 | FromDiscord | <IsaacPaul> so you want a global context.. |
15:06:23 | FromDiscord | <lenis> sent a code paste, see https://play.nim-lang.org/#ix=3FZe |
15:06:30 | FromDiscord | <lenis> onClick needs to know what it's being attached to |
15:06:32 | nrds | <Prestige99> I like that approach PMunch lol |
15:06:46 | FromDiscord | <lenis> but having to pass around context makes the DSL much less intuitive |
15:07:11 | FromDiscord | <IsaacPaul> Oh I see what you're doing.. hmm yea idk |
15:07:12 | PMunch | I mean I've been waiting for this documentation ever since ARC was announced.. |
15:07:33 | * | pro joined #nim |
15:09:05 | FromDiscord | <enthus1ast> @lenis\: maybe you can use the with macro https://nim-lang.org/docs/with.html |
15:09:24 | FromDiscord | <enthus1ast> or do it kinda like it |
15:10:25 | FromDiscord | <lenis> hmm yes that might work |
15:12:17 | FromDiscord | <lenis> sent a code paste, see https://play.nim-lang.org/#ix=3FZf |
15:12:17 | FromDiscord | <lenis> something like that? |
15:16:09 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3FZi |
15:16:13 | FromDiscord | <enthus1ast> imho stuff\: string must then be a callback type, |
15:17:31 | FromDiscord | <enthus1ast> but it also works with a template |
15:18:02 | FromDiscord | <enthus1ast> https://play.nim-lang.org/#ix=3FZn |
15:18:33 | * | pro quit (Quit: WeeChat 3.3) |
15:21:31 | nrds | <Prestige99> PMunch: fwiw I don't know anything about arc/orc and just use the default gc. So any additional documentation is welcome on my end :P |
15:22:44 | * | PMunch quit (Quit: leaving) |
15:23:02 | FromDiscord | <enthus1ast> but i guess he's not aktively working on this any more, but you might read into the stuff he did |
15:23:04 | FromDiscord | <enthus1ast> https://github.com/PMunch/genui |
15:24:55 | FromDiscord | <lenis> sent a code paste, see https://play.nim-lang.org/#ix=3FZp |
15:24:56 | FromDiscord | <lenis> In reply to @enthus1ast "https://github.com/PMunch/genui": Ill look at it |
15:26:12 | FromDiscord | <IsaacPaul> In reply to @PMunch "I mean I've been": What kind of questions do you have? isn't it just non-atomic ref bumps. When a reference gets copied +1 when it is erased -1 ? on 0 it goes bye bye |
15:27:40 | FromDiscord | <Yardanico> In reply to @IsaacPaul "What kind of questions": there are also destructors, cursors (copy elision), different hooks :) |
15:27:44 | FromDiscord | <Yardanico> https://nim-lang.org/docs/destructors.html |
15:29:57 | FromDiscord | <IsaacPaul> ah neat |
15:30:28 | NimEventer | New thread by Jackpboy: Implementing a GC allocated seq replacement without magic, see https://forum.nim-lang.org/t/8651 |
15:35:42 | FromDiscord | <lumi> sent a code paste, see https://play.nim-lang.org/#ix=3FZt |
15:36:23 | FromDiscord | <enthus1ast> then you must traverse the ast, and generate code accordingly |
15:36:23 | FromDiscord | <enthus1ast> but there might be other options, i think writing such a macro is not trivial |
15:36:27 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3FZu |
15:36:31 | FromDiscord | <Yardanico> In reply to @lumi "Hello, I'm new to": you can't capture mutable `Foo` in your `Bar` object |
15:36:37 | FromDiscord | <Yardanico> well, you can, but only with view types and those are highly experimental |
15:36:45 | FromDiscord | <Yardanico> because that requires lifetime tracking and stuff |
15:37:30 | FromDiscord | <Kermithos> is there any way to limit how many threads can be created and let new threads wait until the running ones are finished? |
15:38:04 | FromDiscord | <Kermithos> I tried this code: https://github.com/nim-lang/Nim/issues/19166↵↵but I got a Segmentation fault |
15:38:46 | FromDiscord | <lumi> @Yardanico makes more sense, thank you 😄 That compiler error wasn't very clear |
15:39:00 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3FZv |
15:41:25 | FromDiscord | <lumi> `ref` would imply an indirection wouldn't it? |
15:41:44 | FromDiscord | <IsaacPaul> In reply to @Kermithos "I tried this code:": It seems like they're not using a lock around echo? which might be causing their problem. ↵↵The first example here uses a lock: https://nim-lang.org/docs/threads.html |
15:41:47 | FromDiscord | <Yardanico> In reply to @lumi "`ref` would imply an": but `var` would be unsafe without proper lifetime tracking if you think about it |
15:41:51 | FromDiscord | <Yardanico> so yes, just use `ref` for now |
15:42:04 | FromDiscord | <Yardanico> you might experiment with view types but they're still in development |
15:42:29 | FromDiscord | <lumi> I'll stick with the regular features for now 😄 |
15:42:55 | FromDiscord | <lumi> (edit) "😄" => ":D" |
15:44:31 | FromDiscord | <Kermithos> In reply to @IsaacPaul "It seems like they're": already tried removing all echos, still crashing |
15:46:17 | FromDiscord | <Kermithos> sent a code paste, see https://play.nim-lang.org/#ix=3FZz |
15:52:17 | FromDiscord | <IsaacPaul> I tried it with several different compile settings it that works for me.. what version of nim are you using?↵↵Honestly, instead of dealing threads I would use a preexisting scheduler. https://nim-lang.org/docs/asyncdispatch.html perhaps? I'm _assuming_ it uses a thread pool lol. |
15:53:16 | FromDiscord | <IsaacPaul> (edit) "I tried it with several different compile settings ... it" added "and" | removed "that" |
15:53:45 | FromDiscord | <Yardanico> no |
15:53:52 | FromDiscord | <IsaacPaul> damn I'm always wrong xD |
15:54:17 | FromDiscord | <Yardanico> you can use it with threads, but you'll have to manually start dispatcher in each thread |
15:54:22 | FromDiscord | <Yardanico> and distribute tasks between threads |
15:57:09 | FromDiscord | <Kermithos> In reply to @IsaacPaul "I tried it with": afaik this issue only occurs on linux |
15:58:01 | FromDiscord | <IsaacPaul> yea the last suggestion I have is to just try it with the latest version 🤷♂️ |
15:58:39 | FromDiscord | <Kermithos> In reply to @IsaacPaul "yea the last suggestion": yea, already tried a bunch of compiler versions and options |
16:00:11 | FromDiscord | <IsaacPaul> yea the issue on github is also a linux with nim 1.6.0 . Looks like a bug. |
16:08:20 | * | kayabaNerve joined #nim |
16:16:03 | FromDiscord | <tandy> is there a datatype like `seq` but for storing distinct `(int, int)`s? |
16:17:25 | FromDiscord | <Yardanico> just store (int, int) in a seq? |
16:17:32 | FromDiscord | <Yardanico> not sure i understand the question |
16:17:54 | FromDiscord | <tandy> sorry i guess i mean unique values |
16:18:27 | FromDiscord | <IsaacPaul> you mean like a set |
16:19:03 | FromDiscord | <IsaacPaul> https://nim-lang.org/docs/sets.html |
16:20:05 | FromDiscord | <tandy> can u add items to a set ? |
16:21:44 | FromDiscord | <Yardanico> yes |
16:23:03 | FromDiscord | <tandy> hmmokay il try a set then |
16:41:17 | FromDiscord | <lantos> hey do you have to escape echo? like can echo be escaped by some random ascii/characters |
16:44:57 | FromDiscord | <Yardanico> In reply to @lantos "hey do you have": what do you mean?> |
16:45:46 | FromDiscord | <Yardanico> if you want to escape a quote inside a string, use the backslash |
16:45:49 | FromDiscord | <lantos> haha it sounds dumb but like do you need to sanitize stdout? |
16:46:21 | FromDiscord | <Yardanico> ?? |
16:48:39 | FromDiscord | <lantos> sent a long message, see http://ix.io/3FZQ |
16:49:15 | FromDiscord | <Yardanico> it depends on your environment, but this is not a concert for nim |
16:49:22 | FromDiscord | <Yardanico> it's a concern for whatever environment you have |
16:49:32 | FromDiscord | <Yardanico> maybe it can treat stdout output in some specific way |
16:49:35 | FromDiscord | <Yardanico> but generally no |
16:50:16 | FromDiscord | <lantos> mmm, would be the environment but maybe a nim bundle that covers win/lin/mac |
16:50:25 | FromDiscord | <Yardanico> ??? |
16:53:16 | * | kayabaNerve quit (Ping timeout: 245 seconds) |
16:54:48 | FromDiscord | <lantos> I'll google more, from your response probably not 😅 |
16:55:09 | FromDiscord | <IsaacPaul> It's always safe to sanitize and limit user input |
16:56:51 | FromDiscord | <IsaacPaul> echo will do exactly as it's told. I'm _assuming_ there is some sort of buffer limit which probably cuts off text if exceeded. |
16:58:14 | FromDiscord | <Rika> that would be dependent on the environment again, not on nim |
17:00:05 | * | neurocyte0132889 quit (Read error: Connection reset by peer) |
17:00:44 | FromDiscord | <lantos> mmm from looking on SO, I think the most that one could do is spam/use annoying ascii |
17:01:57 | * | neurocyte0132889 joined #nim |
17:01:58 | * | neurocyte0132889 quit (Changing host) |
17:01:58 | * | neurocyte0132889 joined #nim |
17:03:19 | FromDiscord | <Rika> the question doesnt really make sense |
17:03:28 | FromDiscord | <Rika> why are you worried about echo and escape sequences? |
17:03:46 | FromDiscord | <Rika> the worst thing some attacker can do is mess with your terminal or logging systems |
17:04:26 | FromDiscord | <lantos> In reply to @Rika "the worst thing some": mmm, I'm worried about the environment really.↵But this is mainly what I am seeing.↵There is no chance for execution but just someone using annoying input |
17:04:49 | FromDiscord | <Rika> as long as you're not piping output into an interpreter |
17:06:16 | FromDiscord | <lantos> sent a code paste, see https://play.nim-lang.org/#ix=3FZT |
17:06:29 | FromDiscord | <lantos> and fill the terminal with annoying chards |
17:06:31 | FromDiscord | <lantos> (edit) "chards" => "chars" |
17:06:47 | FromDiscord | <Rika> or completely fuck with it yes |
17:06:51 | FromDiscord | <lantos> (edit) "chars" => "chars, unless you had something parsing checking the stdout" |
17:07:01 | FromDiscord | <lantos> huh how so? |
17:07:21 | FromDiscord | <Rika> cursor movement escape sequences |
17:07:26 | FromDiscord | <lantos> its not like they could send escape seqs |
17:07:29 | FromDiscord | <lantos> oh hahaha |
17:07:32 | FromDiscord | <Rika> an attacker might possibly edit "older" lines |
17:07:39 | FromDiscord | <lantos> yeah that is what I was trying to understand |
17:07:40 | FromDiscord | <Rika> are you sure? |
17:07:56 | FromDiscord | <lantos> how would you avoid this? |
17:08:06 | FromDiscord | <Rika> sanitise? |
17:08:11 | FromDiscord | <lantos> yeah |
17:08:48 | * | dv^_^2 joined #nim |
17:08:51 | FromDiscord | <Rika> sanitise, or output to file (files do not execute escape sequences) |
17:09:00 | * | euantorano_ joined #nim |
17:09:07 | FromDiscord | <Rika> idk how to disable terminal escape sequences |
17:09:19 | * | flynn6 joined #nim |
17:09:32 | FromDiscord | <Rika> https://stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python |
17:09:37 | FromDiscord | <Rika> not nim but related nonetheless |
17:10:55 | * | advesperacit_ joined #nim |
17:10:56 | * | rp1 joined #nim |
17:15:50 | * | advesperacit_ quit (Quit: advesperacit_) |
17:16:40 | FromDiscord | <lantos> yeah okay found something that puts the cursor back and overrides text |
17:16:43 | * | rlp10 quit (*.net *.split) |
17:16:43 | * | advesperacit quit (*.net *.split) |
17:16:43 | * | oz quit (*.net *.split) |
17:16:43 | * | dv^_^ quit (*.net *.split) |
17:16:43 | * | flynn quit (*.net *.split) |
17:16:43 | * | euantorano quit (*.net *.split) |
17:16:43 | * | stkrdknmibalz quit (*.net *.split) |
17:16:45 | * | euantorano_ is now known as euantorano |
17:16:45 | * | dv^_^2 is now known as dv^_^ |
17:16:45 | * | flynn6 is now known as flynn |
17:16:54 | FromDiscord | <lantos> feel like that one could be abused hard |
17:17:22 | FromDiscord | <Yardanico> how? |
17:17:57 | FromDiscord | <lantos> logging? like if you were logging the output then a user could set the cursor back and then write over text |
17:18:03 | FromDiscord | <lantos> oh do you mean the example? |
17:18:10 | FromDiscord | <Yardanico> In reply to @lantos "logging? like if you": no that won't work |
17:18:15 | FromDiscord | <Yardanico> if you do "logging" you do it to somewhere |
17:18:17 | FromDiscord | <Yardanico> a file or something |
17:18:20 | FromDiscord | <Yardanico> and you can't overwrite text with that |
17:18:24 | FromDiscord | <lantos> sent a code paste, see https://play.nim-lang.org/#ix=3G05 |
17:18:24 | FromDiscord | <Yardanico> in a file |
17:21:20 | * | arkurious joined #nim |
17:22:55 | * | oz joined #nim |
17:23:53 | * | neurocyte0132889 quit (Quit: The Lounge - https://thelounge.chat) |
17:26:46 | FromDiscord | <Rika> In reply to @Rika "sanitise, or output to": yeah |
17:27:58 | * | neurocyte0132889 joined #nim |
17:27:58 | * | neurocyte0132889 quit (Changing host) |
17:27:58 | * | neurocyte0132889 joined #nim |
17:35:15 | * | lumo_e joined #nim |
17:59:10 | FromDiscord | <lantos> yeah okay, just tried with the logger, if you filelogger yeah it is clear but consolelogger does it which makes sense.↵Thanks 🙂 |
18:11:45 | * | xet7_ is now known as xet7 |
18:12:11 | * | xet7 quit (Quit: Leaving) |
18:12:28 | FromDiscord | <lantos> https://nim-lang.org/docs/strutils.html#escape%2Cstring%2Cstring%2Cstring |
18:13:57 | * | Colt joined #nim |
18:36:38 | * | xet7 joined #nim |
18:56:36 | * | Colt quit (Quit: Leaving) |
18:57:14 | * | Colt joined #nim |
19:01:50 | * | Colt quit (Remote host closed the connection) |
19:02:20 | * | Colt joined #nim |
19:03:27 | * | Colt quit (Remote host closed the connection) |
19:03:29 | * | Colt1 joined #nim |
19:03:42 | * | Colt1 quit (Remote host closed the connection) |
19:06:37 | * | Colt joined #nim |
19:10:30 | FromDiscord | <hmmm> hmmm |
19:10:41 | FromDiscord | <hmmm> my entire program is a side effect |
19:10:49 | FromDiscord | <hmmm> should I be worried 🧐 |
19:13:45 | FromDiscord | <IsaacPaul> yea probably |
19:14:03 | FromDiscord | <hmmm> 😨 |
19:15:03 | FromDiscord | <hmmm> still it's kind of elegant in a weird carcrash kind of way |
19:15:10 | FromDiscord | <hmmm> I'm proud of my little monster |
19:23:13 | FromDiscord | <dabmlfz> sent a long message, see http://ix.io/3G0z |
19:24:41 | * | krux02 joined #nim |
19:40:19 | FromDiscord | <IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3G0D |
19:46:41 | FromDiscord | <IsaacPaul> If your project is not a library/package you could just change the values in nim manually 😛 https://github.com/nim-lang/Nim/blob/0d0c249074d6a1041de16108dc247396efef5513/compiler/extccomp.nim#L251↵↵Or via patchfile? (Don't quote me on this) |
19:47:36 | FromDiscord | <dabmlfz> that doesn't work sadly. I could also change the values in nim but that's even less elegant than the workaround above XD |
19:47:43 | FromDiscord | <dabmlfz> I'll check that issue out, thanks |
20:18:06 | * | terminalpusher joined #nim |
20:29:29 | * | proaxis joined #nim |
20:46:36 | * | proaxis left #nim (#nim) |
21:07:54 | * | terminalpusher quit (Remote host closed the connection) |
21:14:34 | * | src quit (Quit: Leaving) |
21:16:19 | FromDiscord | <hmmm> sent a code paste, see https://play.nim-lang.org/#ix=3G13 |
21:16:46 | FromDiscord | <hmmm> and how do I color the synthax in discord 🤔 , I think I was told but I forgot |
21:17:49 | FromDiscord | <haxscramper> Triple backtick followed by the name of the language |
21:18:10 | * | ozzz quit (Remote host closed the connection) |
21:18:25 | FromDiscord | <hmmm> sent a code paste, see https://play.nim-lang.org/#ix=3G15 |
21:18:25 | FromDiscord | <hmmm> hmm |
21:18:52 | FromDiscord | <hmmm> it looks grey to me 🤔 |
21:23:10 | FromDiscord | <IsaacPaul> In reply to @IsaacPaul "you can also use": ^ |
21:23:46 | FromDiscord | <reilly> sent a code paste, see https://play.nim-lang.org/#ix=3G17 |
21:24:23 | FromDiscord | <reilly> The syntax highlighting that Discord provides for Nim is not very extensive, but it's better than nothing. Just don't expect things to suddenly pop with color. |
21:24:43 | FromDiscord | <hmmm> sent a code paste, see https://play.nim-lang.org/#ix=3G18 |
21:24:44 | FromDiscord | <hmmm> NICE |
21:27:01 | FromDiscord | <reilly> I wish that the syntax highlighting would be improved, but I don't realistically see that happening anytime soon. Frankly, I think we're lucky to have Nim support at all. |
21:27:54 | FromDiscord | <IsaacPaul> In reply to @hmmm "hey bois I kinda": I think because you're getting a copy for `i` |
21:27:58 | FromDiscord | <hmmm> we also need nim lighting on rosetta code |
21:28:34 | FromDiscord | <hmmm> python has it! we can let them boss things around |
21:28:52 | FromDiscord | <hmmm> rust doesn't have it too |
21:29:22 | FromDiscord | <hmmm> isaac the question is how to get around it and massively populate my thingies |
21:30:04 | FromDiscord | <IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3G1b |
21:30:12 | FromDiscord | <IsaacPaul> but there should be a way to do it without turning the object into a ref |
21:30:18 | FromDiscord | <hmmm> ref object |
21:30:26 | FromDiscord | <hmmm> hmmm |
21:30:33 | FromDiscord | <hmmm> never used it |
21:30:55 | FromDiscord | <hmmm> might work lets see |
21:33:13 | * | ozzz joined #nim |
21:33:55 | FromDiscord | <IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3G1d |
21:35:36 | FromDiscord | <hmmm> this is perfect |
21:35:49 | FromDiscord | <IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3G1e |
21:36:37 | FromDiscord | <hmmm> woa is there something called eachThing? this might possibly become my favourite nim word 😊 |
21:37:33 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3G1f |
21:37:51 | FromDiscord | <IsaacPaul> In reply to @hmmm "woa is there something": You can name it whatever you want |
21:38:03 | FromDiscord | <hmmm> ah it's i,v |
21:38:09 | FromDiscord | <IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3G1g |
21:38:39 | FromDiscord | <Elegantbeef> You can also do stuff like this is if the index is important ↵https://github.com/beef331/slicerator/blob/master/src/slicerator.nim#L65 |
21:46:47 | FromDiscord | <that_dude> Doesn't the default iterator use `.items` which is why the mutable one is `.mitems`? |
21:46:58 | FromDiscord | <Elegantbeef> Yes |
21:47:18 | FromDiscord | <Elegantbeef> well actually `for x, y in a` calls `pairs` and `for x in a` calls `items` |
22:04:18 | * | Vladar quit (Remote host closed the connection) |
23:33:35 | FromDiscord | <geekrelief> While working on my TM binding, I put together this macro to help deal with generating repetitive code. https://github.com/geekrelief/genit I'd like to get feedback on it if anyone finds it useful. I'm wondering is there's already a better way to do "inline" templates? |
23:36:06 | FromDiscord | <Elegantbeef> Somewhat interesting but also some what awful 😀 |
23:36:17 | FromDiscord | <geekrelief> hehe yes it is aweful |
23:36:25 | FromDiscord | <geekrelief> (edit) "aweful" => "awful" |
23:36:57 | FromDiscord | <geekrelief> I find it addicting like a bad habit. |
23:37:34 | FromDiscord | <Elegantbeef> Yea macros are fun and addicting |
23:38:10 | FromDiscord | <Elegantbeef> You have practically made `genast` though invokable at base |
23:38:12 | FromDiscord | <geekrelief> My mind says no, but my fingers say yes. |
23:38:15 | FromDiscord | <Elegantbeef> at root\ |
23:38:19 | FromDiscord | <geekrelief> yeah that's the idea |
23:39:06 | FromDiscord | <Elegantbeef> Yea i mean i did some silly stuff recently as well so who am i to judge |
23:39:26 | FromDiscord | <Elegantbeef> drop-2021-11-24\_15.34.24.mp4 https://media.discordapp.net/attachments/371759389889003532/913212244941213747/drop-2021-11-24_15.34.24.mp4 |
23:39:31 | FromDiscord | <Elegantbeef> Stupid macro repl thingy |
23:44:38 | FromDiscord | <geekrelief> In reply to @Elegantbeef "Stupid macro repl thingy": Is that for anything in particular? or just experimenting? |
23:45:52 | FromDiscord | <Elegantbeef> well the idea is for making macro writting less tedious, but idk how useful it'll be |
23:51:36 | FromDiscord | <geekrelief> I see, yeah macros are kind of annoying. I'm trying to make `genit` something in between a template and macro. Please tell me if inline templates are a terrible idea, and if I'm a horrible person for suggesting it. |
23:52:50 | FromDiscord | <Elegantbeef> Well it has a purpose since you use it, but it's quite hard to read |
23:54:27 | FromDiscord | <geekrelief> I was playing around with various ways to make it cleaner. I don't know if it's a syntax issue or what. Simply replacing the slashes with dashes or something else might make it easier to read, but I want those things to stand out. Unfortunately, there's always a tradeoff between conciseness and readability. |
23:54:55 | FromDiscord | <geekrelief> Kind of like regular expressions. |
23:55:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3G1T |
23:56:36 | FromDiscord | <Elegantbeef> the same with the tuples |
23:56:58 | FromDiscord | <Elegantbeef> `it[0]` for your insertion and then `[](it, 0)` for the index operator |
23:57:30 | FromDiscord | <geekrelief> In reply to @Elegantbeef "So my suggestion would": I thought about replacing `str_it` with `$it`, but I didn't want to interfere with intentional usage of `$`, same goes for tuples and indexing. |
23:57:56 | FromDiscord | <Elegantbeef> Sure but if you do the way i suggested it's clean and you dont directly interfere |
23:58:23 | FromDiscord | <Elegantbeef> I guess i messed up the example since it should be `$it` in the first one |
23:58:45 | FromDiscord | <Elegantbeef> You of course need to do the accquoted call, but that's cleaner than these magic variables imo |
23:58:46 | FromDiscord | <geekrelief> I think that might be even more confusing to read. |
23:59:54 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3G1V |