<< 24-01-2023 >>

00:14:47*lumo_e quit (Ping timeout: 255 seconds)
00:16:42FromDiscord<sa-code> Hey all. Here's an implementation of python's fsspec in nim https://github.com/sa-/filesystem_concept/blob/main/src/filesystem_concept.nim
00:17:00FromDiscord<sa-code> If you have a look, feedback would be appreciated
00:17:19FromDiscord<T0lk1en> Hey guys how do you add nim syntax highlighting to Melvin
00:17:31FromDiscord<T0lk1en> Neovim
00:19:28FromDiscord<T0lk1en> I tried installing the package manager and installing the nim syntax package but that doesn’t seem t
00:19:32FromDiscord<T0lk1en> To work
00:20:39FromDiscord<jtv> In reply to @sa-code "If you have a": Feedback on what? There's 20 lines of stubbing and proxying existing local calls, and nothing else, so it's hard to give feedback.
00:21:50FromDiscord<sa-code> In reply to @jtv "Feedback on what? ": If there's no feedback then that's fine too
00:24:04FromDiscord<sa-code> if anyone is interested in creating an s3/gcp client for this feel free to do it in a new repo or add it here
00:27:23FromDiscord<Elegantbeef> Yea there's not much to say, it's a concept that doesnt even make much sense
00:27:33FromDiscord<Elegantbeef> `sizes` for instance will not work without `views`
00:27:56FromDiscord<Elegantbeef> `: openarray[int]` is not capable of being instantiated
00:28:40FromDiscord<T0lk1en> In reply to @T0lk1en "Hey guys how do": Any help appreciated
00:28:59FromDiscord<Elegantbeef> https://github.com/alaviss/nim.nvim works for me
00:29:34FromDiscord<T0lk1en> See that the thing. I can’t seem to install the plug manager
00:29:46FromDiscord<T0lk1en> Even when I run the script
00:29:49FromDiscord<Elegantbeef> https://github.com/junegunn/vim-plug#neovim
00:30:00FromDiscord<Elegantbeef> https://github.com/junegunn/vim-plug#usage
00:37:45FromDiscord<Elegantbeef> If that still doesnt work, what have you done, and what OS are you on
00:38:16FromDiscord<Nilts> How would I go about making a non recursive node visitor. The errors are making me think recursion is bad.
00:38:50FromDiscord<T0lk1en> In reply to @Elegantbeef "If that still doesnt": It worked after reboot. I’m on Linux ofc
00:38:58FromDiscord<T0lk1en> Linux
00:39:06FromDiscord<Elegantbeef> Linux
00:39:08FromDiscord<Elegantbeef> Linux
00:40:01FromDiscord<jtv> What's wrong w/ Linux? It needs the magic reboot to fix far less than every other OS 🙂
00:40:17FromDiscord<jtv> I mean, beyond user experience, of course
00:40:40FromDiscord<huantian> Still needs it tho
00:40:44FromDiscord<huantian> Looks at you nvidia drivers
00:43:09FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4m2X here's a simple BF traversal
00:43:15FromDiscord<Elegantbeef> breadth first i should write
00:43:31FromDiscord<Elegantbeef> Really should stop writing abrv.
00:44:07FromDiscord<Elegantbeef> There are many ways to traverse a graph
00:46:38FromDiscord<jtv> Breadth first generally requires much more state management and is mostly frowned upon for those reasons except for the few problems where it's clearly the right way to go for the problem you're trying to solve
00:47:36FromDiscord<jtv> If you're getting errors with your recursion, then you are doing something wrong unless your tree depth is enormous, in which case you're probably doing something wrong 🙂
00:48:50FromDiscord<Elegantbeef> Stack go boom
00:49:22FromDiscord<Nilts> In reply to @jtv "If you're getting errors": i don
00:49:32FromDiscord<Nilts> (edit) "don" => "don't think anything is wrong"
00:50:00FromDiscord<Nilts> (edit) "wrong" => "wrong, except for the fact that there should be closer to 500 recursions, not 2000"
00:50:34FromDiscord<Elegantbeef> Are you just changing your algo cause of Nim's default stack call limit?
00:50:44FromDiscord<jtv> What's the data you're working with that's nested 500 nodes deep???
00:50:57FromDiscord<Elegantbeef> In before it's a cyclical graph
00:51:13FromDiscord<jtv> If it's a cyclical graph you're probably not doing a good job detecting the cycles.
00:51:31FromDiscord<Nilts> In reply to @Elegantbeef "In before it's a": what is a cyclical graph
00:51:46FromDiscord<jtv> Cycle == circle
00:51:52FromDiscord<Elegantbeef> A graph that points to itself in a circular manner
00:52:43FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4m2Y
00:53:12FromDiscord<Elegantbeef> Simmered down to that example
00:53:20FromDiscord<Nilts> In reply to @jtv "If it's a cyclical": probably not, it's not even a graph, and the visitor is being used for an interpreter, thats why it goes so dep
00:53:25FromDiscord<Nilts> (edit) "dep" => "deep"
00:54:51FromDiscord<jtv> "It's not a graph", what does that mean? It sounds like it is not a tree, and not a DAG, but when you're talking about navigating around links between objects, all that's left is a graph (the most general thing)
00:55:30FromDiscord<jtv> Would be good to get some more detail to be able to help
00:55:36FromDiscord<Nilts> In reply to @jtv ""It's not a graph",": i am so confused.
00:55:52FromDiscord<Nilts> In reply to @jtv "Would be good to": what kind of detail
00:55:57FromDiscord<Elegantbeef> We're even more confused
00:56:06FromDiscord<Elegantbeef> Use your words to explain exactly what you're doing and what's wrong
00:56:17FromDiscord<Elegantbeef> Hell even giving the type definition goes a long way
00:57:53FromDiscord<Nilts> In reply to @Elegantbeef "Use your words to": I'm trying to git rid of really deep recursions for jump stmts in my interpreter, and i don't know how i would go about doing it.
01:02:59FromDiscord<jtv> I've written many, many, many interpreters over the last 30+ years, and I'm hard pressed to come up with anything in any of those implementations that would merit the depth of recursion you're talking about, so I'd still say it's way too light on detail to be helpful. We'd need something more concrete.
01:04:52FromDiscord<Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4m31
01:05:31FromDiscord<jtv> Only if you're implementing jump with a function call which nobody ever would
01:06:12FromDiscord<Elegantbeef> A jump target likely should be either an address in bytecode or your ast data
01:06:48FromDiscord<jtv> Function calls are there to save and restore context via a stack. If you don't need that, why pay the price?? You're just wasting CPU and memory
01:07:38FromDiscord<Elegantbeef> Do you compile to bytecode?
01:07:51FromDiscord<Elegantbeef> What's your current operating mechanism
01:09:27FromDiscord<jtv> I suspect from the description it's like a lot of early basic interpreters, just REPL loops, parsing line by line, and some state?
01:09:41FromDiscord<Elegantbeef> Yea that's what i figure aswell
01:09:52FromDiscord<Elegantbeef> Which to that i say "Implement a proper interpreter"
01:10:26FromDiscord<jtv> Yeah, there's a reason nobody's written an interpreter of any merit like that since the early 80's 🙂
01:11:13FromDiscord<jtv> But even then, "jump" is just "load this memory address instead for the next instruction"
01:12:00FromDiscord<Nilts> In reply to @Elegantbeef "A jump target likely": how do i addr ast data and how would implement this.
01:12:05FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4m32
01:12:22FromDiscord<Elegantbeef> Well I'd not suggest the using AST data
01:12:29FromDiscord<Elegantbeef> I'd suggest compiling to byte code
01:12:50FromDiscord<Nilts> In reply to @Elegantbeef "I'd suggest compiling to": that is a compiler, not a interpreter
01:12:57FromDiscord<Elegantbeef> Nope
01:13:04FromDiscord<jtv> No most interpreters use byte code
01:13:09FromDiscord<Elegantbeef> Bytecode is used by all the popular interpreters
01:13:30FromDiscord<Elegantbeef> Compiling your code to byte code is the sensible thing. Your VM turns into a basic CPU practically
01:13:45FromDiscord<Elegantbeef> You have a group of built in operations that the users use to do things
01:14:10FromDiscord<Elegantbeef> A bytecode interpreter very much is "you own little CPU project"
01:14:43FromDiscord<Nilts> In reply to @Elegantbeef "Bytecode is used by": I'm trying to make a "basic" interpreter. Not something like your describing, I don't have nearly enough skill to do a full-blown one
01:14:55FromDiscord<Elegantbeef> Everyone has the skill too
01:15:06FromDiscord<Elegantbeef> https://craftinginterpreters.com/
01:15:28FromDiscord<jtv> I mean, if you still parse each statement into a tree, you can just execute out of the tree without a VM, but that's really not that scalable a solution
01:15:51FromDiscord<Elegantbeef> It's slow and also a memory hog 😄
01:16:06FromDiscord<Elegantbeef> Not being scared of byte code is much easier imo
01:17:11FromDiscord<jtv> No, it's not slow if it's interactive, and saves the cost of generating the byte code that isn't likely to get reused. But it's not good for general purpose stuff, no
01:17:36FromDiscord<Nilts> I guess asking this server help is out of my scope for this project. I have some sense of how this interpreter would work, i have no idea how bytecode works
01:17:42FromDiscord<Nilts> (edit) "I guess asking this server ... help" added "for"
01:18:09FromDiscord<jtv> Well, if you tell me more about how you're representing code and your execution model, I can probably help
01:19:16FromDiscord<Nilts> In reply to @jtv "Well, if you tell": sorry for my stupidity but what is an execution model and what do you mean by "how you're representing code"
01:19:43FromDiscord<jtv> Just tell me about how your interpreter actually works, what you're doing under the hood.
01:20:11FromDiscord<jtv> Am I typing in code and hitting enter? And then what do you do once I hit enter?
01:20:13FromDiscord<jtv> ETC
01:20:36FromDiscord<Nilts> In reply to @jtv "Just tell me about": I visit an ast node, and if needed enter a new scope and execute children and sometime return a value.
01:20:41FromDiscord<Nilts> In reply to @jtv "Am I typing in": no
01:21:10FromDiscord<jtv> So you are parsing an entire file into a tree, and then trying to execute directly out of the tree.
01:21:15FromDiscord<Nilts> (edit) "no" => "no, your typing out a file"
01:21:19FromDiscord<Nilts> yes
01:22:28FromDiscord<jtv> So do you have a node that represents the entry of a loop, then?
01:22:46FromDiscord<jtv> And when you get to it, you evaluate the condition, and then maybe go down the tree?
01:22:48FromDiscord<Nilts> In reply to @jtv "So do you have": like the flag or jump block?
01:23:38FromDiscord<jtv> Your AST for that loop, what does it look like?
01:26:12FromDiscord<jtv> By the way, looking closely at the code, it's an infinite loop, you jump to your target in both branches
01:28:20FromDiscord<jtv> But a jump should never require a function call in any interpreter. If you're evaluating out a tree, your 'current node' starts at the top of the loop. It's got a series of children you execute in order, and then when you have no more statements on that list, you go back to the loop node, bump your counter if it has those semantics built in, evaluate the condition, and either to it again or move on to the next statement "after" the loop.
01:29:03FromDiscord<jtv> You might be deep in a sub-tree, but if you design things right, you can just set the "current node"
01:29:08FromDiscord<Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4m36
01:29:34FromDiscord<jtv> And if you don't design things right, if you have a jump up to a loop top, you can always use an exception to do that.
01:30:09FromDiscord<Nilts> In reply to @jtv "And if you don't": what do you mean?
01:30:57FromDiscord<jtv> so you probably have some handleStmtList() that calls FlagStm() that calls StmtList() that calls... down to where you get to the jump.
01:31:39FromDiscord<jtv> If you're executing out of a tree like this and you're doing it that way, you can, when you enter flagStmt(), do a try: block
01:32:11FromDiscord<jtv> Then the jump can throw an exception, which will unwind your call stack back to the FlagStmt node
01:32:34FromDiscord<jtv> At which point, the node can look at whatever arg you passed in an exception to see what to do
01:33:28FromDiscord<jtv> Generally if you do it that way, arbitrary jump labels aren't a great idea, best to use higher-level loop nodes and "break" and "continue" to labels, so they're easily modeled through exception handling
01:34:26FromDiscord<Nilts> In reply to @jtv "Generally if you do": I was going to say, what you were suggesting was more fit to break or contiune
01:34:33FromDiscord<Nilts> (edit) "contiune" => "continue"
01:36:58FromDiscord<jtv> Well, you can still do arbitrary labels, just unwind and let something else take care of it. With jmp you'd normally unwind to the function call, and then start walking from the target node. Or, you don't need to use recursion to change where you are in your tree state, you just use a loop and move your pointer into it.
01:38:35FromDiscord<jtv> But like Beef said, unless you really know what you're doing, it's actually EASIER and generally more efficient to just walk the tree once and generate byte code, even if each node type is it's own instruction in your VM.
01:39:06FromDiscord<jtv> You only do one tree walk that way, and the rest of it is just a stack and a pointer to the current instruction
01:39:22FromDiscord<jtv> You don't have to use some 3rd party VM that's overly complicated or optimized
01:40:15FromDiscord<Nilts> In reply to @jtv "But like Beef said,": Wait so most interpreted languages are like this?↵`Code -> Compile (to bytecode) -> run on VM`
01:40:25FromDiscord<jtv> Yes
01:40:30FromDiscord<Nilts> so isn't that just java
01:40:45FromDiscord<Elegantbeef> Is lua just java?
01:41:17FromDiscord<jtv> You could look at it another way... you're basically converting your tree into an array of instructions and data, and then using a stack to walk it in a much more managable way
01:41:17FromDiscord<Nilts> In reply to @not logged in "so isn't that just": ( I thought java was compiled)
01:41:31FromDiscord<Elegantbeef> Welcome to word semantics
01:41:44FromDiscord<Elegantbeef> 'compiled' is a loose term to "Moving down to lower level"
01:41:50FromDiscord<jtv> Java is COMPILED JVM byte code is "interpreted"
01:42:10FromDiscord<Nilts> In reply to @jtv "You could look at": then it's the same as a compiler, just one compiles machine code and one compiles to byte code
01:42:21FromDiscord<jtv> At some point, SOMETHING looks at an instruction, and some data, and does work based on it.
01:42:28FromDiscord<jtv> You're already compiling to a tree
01:42:34FromDiscord<jtv> And interpreting from the tree
01:42:39FromDiscord<jtv> 🤷
01:43:04FromDiscord<jtv> We're just saying you should have a much better IR that's more suited to the interpreting piece
01:43:26FromDiscord<Elegantbeef> Intermediate representation
01:44:13FromDiscord<jtv> compilers take code and produce output that is meant to run on some abstract machine. It might be physical hardware, or it might just be the code you're using to walk your tree
01:44:19FromDiscord<jtv> But still, it's what you're doing.
01:44:27FromDiscord<Nilts> I just had a realization moment. All programming languages are this:↵`Zero or more Compiler -> Interpreter`
01:44:37FromDiscord<jtv> Yes correct.
01:45:16FromDiscord<Elegantbeef> Virtual machine afterall is synonymous for "pretend CPU"
01:45:37FromDiscord<jtv> Or, more precisely, there are multiple transformations that lead to code that can be executed on some virtual machine, but you can always then translate it to some other machine 🙂
01:45:45FromDiscord<Nilts> So how would i go about the whole bytecode thing.
01:45:48FromDiscord<jtv> Just your virtual machine is an ad hoc tree walk
01:46:17FromDiscord<Elegantbeef> Wasm based CPU when
01:46:30FromDiscord<Nilts> whut
01:48:49FromDiscord<jtv> Hmm, hard to explain simply I'm looking around for code I might be able to hand you. But it's nothing tough
01:49:13FromDiscord<jtv> Maybe a simple example. Let's say you have a PLUS node. You're walking the tree to generate code, you get to the plus node
01:49:17arkanoidif I have a const array, can I still use myarr[0].unsafeAddr to make it available in linked C code?
01:49:49FromDiscord<jtv> Your generated code for plus could be: evaluate the LHS, pushing it onto the stack. evaluate the RHS, pushing it onto the stack. Pop two values and add them
01:50:08FromDiscord<jtv> And leave the result on the stack
01:50:21FromDiscord<Elegantbeef> Dont think so arkanoid
01:50:39FromDiscord<jtv> So if you have (2+2)<-ADD->(2+2)
01:50:47FromDiscord<Nilts> In reply to @jtv "Maybe a simple example.": I know exactly where i would put this. Also wtf is LHS RHS also what is "stack"
01:50:47FromDiscord<jtv> Where the middle one is the top of your tree
01:50:55FromDiscord<jtv> lhs == left hand side
01:50:58arkanoidElegantbeef, ok. Thanks
01:51:00FromDiscord<jtv> rhs = right hand side
01:51:32FromDiscord<jtv> So you get to that first add-node, and you will generate the code for the left hand side, first. you get to that second node on the left,
01:51:34FromDiscord<jtv> It's another +
01:51:43FromDiscord<jtv> It goes down to the 2 which is an immediate
01:51:50FromDiscord<jtv> Your code for that is "push 2 onto the stack"
01:52:00FromDiscord<jtv> Then you go the right of that left hand plus
01:52:06FromDiscord<jtv> You push another 2
01:52:24FromDiscord<jtv> (i.e., you output something to say to do those things
01:52:56FromDiscord<jtv> And then, once you've done that, you output something that says, "take two numbers from the top of the stack, add them, and put the result on the stack"
01:53:02FromDiscord<jtv> That's probably your "ADD" instruction
01:53:17FromDiscord<jtv> So like I said, one instruction per tree-node generally can work
01:53:54FromDiscord<jtv> You'd end up with data in an array that's: [PUSH 2, PUSH 2, ADD, PUSH 2, PUSH 2, ADD, ADD]
01:54:14FromDiscord<jtv> And then you'd execute from the top of the array 🙂
01:54:27FromDiscord<Nilts> In reply to @jtv "So like I said,": but then how is this different the just interpreting the ast
01:54:40FromDiscord<jtv> The stuff in the array is now "byte code" 😉
01:54:49FromDiscord<Nilts> In reply to @jtv "You'd end up with": so (2+2)+(2+2)
01:54:52FromDiscord<jtv> And you can now just jump around the array
01:54:55FromDiscord<jtv> You have no more tree
01:55:02FromDiscord<jtv> Just a stack for pushing and popping
01:56:01FromDiscord<Nilts> In reply to @jtv "And you can now": ohhhh, so advanced flattening. Is there any good reason then to have an ast tree? Or should the parsed data go directly to bytecode
01:56:02FromDiscord<jtv> Yes, was trying on my phone to show the tree you'd typically have for (2+2)+(2+2) yes
01:56:21FromDiscord<jtv> It's always best to do one phase at a time.
01:56:39FromDiscord<jtv> Get an AST. Even if you could go directly to byte code, it'll make things harder to debug
01:56:56FromDiscord<jtv> And if you ever want to optimize, a tree is easier to work with for most optimizations
01:57:09FromDiscord<jtv> Trees are bad for execution 🙂
01:57:28FromDiscord<Nilts> 👍 thanks alot! I went from 0 understanding to some understanding!
01:58:50FromDiscord<jtv> No problem. I'm around plenty if you need more help. I've taught compilers and languages at the uni level more than a few times, so if we both have the time and patience, I know how to help people on these things reasonably well
02:00:10FromDiscord<Nilts> In reply to @jtv "No problem. I'm": I probably will, should i ping you if i need help on this topic?
02:00:59FromDiscord<jtv> Sure, but I'm generally either on discord or I'm not going to see it till I am 🙂
02:01:08FromDiscord<jtv> But you're welcome to do so
02:24:01FromDiscord<T0lk1en> https://www.reddit.com/r/nim/comments/10juowv/cant_get_syntax_highlighting_neovim/?utm_source=share&utm_medium=ios_app&utm_name=iossmf
02:24:06FromDiscord<T0lk1en> Can someone help me out
02:24:15FromDiscord<T0lk1en> Been going at this for 48 hours
02:24:49FromDiscord<Elegantbeef> I was trying to help
02:24:51FromDiscord<Elegantbeef> You never gave any more information
02:26:00FromDiscord<T0lk1en> I’m not sure what to give
02:26:11FromDiscord<T0lk1en> Plug install works(sometimes)
02:26:24FromDiscord<T0lk1en> I gave the package I’m trying to plug
02:26:44FromDiscord<T0lk1en> I’m on artix Linux
02:27:10FromDiscord<Elegantbeef> What's your `init.vim` look like?
02:27:18FromDiscord<T0lk1en> Lemme get it rq
02:29:19FromDiscord<T0lk1en> Syntax on
02:29:27FromDiscord<T0lk1en> Set expand tab
02:29:31FromDiscord<T0lk1en> Set number
02:29:48FromDiscord<T0lk1en> Set shiftwidth=2
02:30:02FromDiscord<Elegantbeef> So you didnt add the plugin
02:30:09FromDiscord<T0lk1en> Call plug#beginin()
02:30:29FromDiscord<T0lk1en> Plug ‘(plug name)’
02:30:38FromDiscord<T0lk1en> Call plug#end()
02:30:43FromDiscord<Elegantbeef> ...
02:30:51FromDiscord<Elegantbeef> You do not make it easy to help you
02:30:52FromDiscord<T0lk1en> I called it
02:30:55FromDiscord<Elegantbeef> Paste your config on a file
02:31:08FromDiscord<T0lk1en> Aight
02:32:12FromDiscord<T0lk1en> My bad
02:36:17FromDiscord<T0lk1en> https://media.discordapp.net/attachments/371759389889003532/1067271594390589461/init.vim
02:37:01FromDiscord<Elegantbeef> Ok so you then did `:PlugInstall!`?
02:37:25FromDiscord<T0lk1en> yes
02:37:53FromDiscord<Elegantbeef> Did it error?
02:37:58FromDiscord<Elegantbeef> Was there any output?!
02:38:25FromDiscord<T0lk1en> no it doesnt error
02:38:33FromDiscord<Elegantbeef> So then you opened a `.nim` file
02:38:39FromDiscord<T0lk1en> but when i source init i get this error
02:38:42FromDiscord<Elegantbeef> And was there any issue or did it error
02:38:53FromDiscord<T0lk1en> yes i open a nim file and get no syntax highliting
02:39:03FromDiscord<T0lk1en> https://github.com/alaviss/nim.nvim
02:39:06FromDiscord<T0lk1en> im using this
02:39:33FromDiscord<T0lk1en> /bash: syntax: command not found↵bash: init.vim: line 7: syntax error near unexpected token `('↵bash: init.vim: line 7: `call plug#begin()'
02:39:44FromDiscord<T0lk1en> i get this error when trying to source
02:40:37FromDiscord<Elegantbeef> Why are you using bash on init.vim?
02:40:51FromDiscord<T0lk1en> im not
02:40:55FromDiscord<T0lk1en> im running
02:41:03FromDiscord<T0lk1en> /source init.vim
02:41:11FromDiscord<Elegantbeef> Why?
02:41:18FromDiscord<Elegantbeef> `nvim test.nim`
02:41:33FromDiscord<T0lk1en> lemme see
02:41:55FromDiscord<T0lk1en> wtf
02:42:01FromDiscord<T0lk1en> it works now i guess
02:42:05FromDiscord<T0lk1en> thanks?
02:42:06FromDiscord<T0lk1en> lol
02:42:44FromDiscord<Elegantbeef> ...
02:43:12FromDiscord<T0lk1en> i think it had somethinf to do with the file i was working onm
02:51:47*argonica joined #nim
03:37:19*rockcavera quit (Remote host closed the connection)
03:37:37FromDiscord<Iliketwertles> sent a code paste, see https://play.nim-lang.org/#ix=4m3o
03:37:39FromDiscord<Iliketwertles> code in a sec
03:39:40FromDiscord<Iliketwertles> sent a code paste, see https://paste.rs/Utx
03:39:50FromDiscord<Iliketwertles> (edit) "https://play.nim-lang.org/#ix=4m3p" => "https://play.nim-lang.org/#ix=4m3q"
03:40:00FromDiscord<Iliketwertles> https://media.discordapp.net/attachments/371759389889003532/1067287624424882297/passwordmababoer.nim
03:41:22FromDiscord<Iliketwertles> code is ugly ik
03:43:28FromDiscord<jtv> Well, the default mode for open is fmRead
03:43:33*sugarbeet joined #nim
03:43:33FromDiscord<jtv> And you're trying to write to it
03:43:38FromDiscord<Rika> Was going to say
03:43:39*sugarbeet left #nim (#nim)
03:44:08FromDiscord<jtv> you need to open as fmReadWrite; and then are you appending? Or overwriting? Because you need to deal w/ the old data too
03:45:51FromDiscord<Iliketwertles> In reply to @jtv "you need to open": appending on a new line
03:46:51FromDiscord<jtv> So definitely open(filename, fmReadWrite)
03:52:45FromDiscord<Iliketwertles> still getting the error
03:55:17FromDiscord<Iliketwertles> now its not even writing the first string to the file
03:56:36FromDiscord<Iliketwertles> https://media.discordapp.net/attachments/371759389889003532/1067291804707328030/screenshot_2023-01-23-225658.png
03:56:42FromDiscord<Iliketwertles> kinda lied but still
04:00:32*arkurious quit (Quit: Leaving)
04:12:14*pbsds quit (Quit: The Lounge - https://thelounge.chat)
04:13:28FromDiscord<Iliketwertles> i think it got it working
04:13:56*argonica quit (Quit: Leaving)
04:14:14*pbsds joined #nim
04:22:34FromDiscord<Iliketwertles> well
04:23:48FromDiscord<Iliketwertles> broken https://media.discordapp.net/attachments/371759389889003532/1067298649115209789/screenshot_2023-01-23-232406.png
04:24:52FromDiscord<Iliketwertles> https://media.discordapp.net/attachments/371759389889003532/1067298917424828456/passwordmababoer.nim
04:33:27FromDiscord<Girvo> Is there a nim-only key-value file store library floating around? Searched on nimble but only seemed to find C wrappers
04:37:29FromDiscord<T0lk1en> Yo I’m on Linux and when I try to compile a program that has an installed library it can’t seem to see it. I have the path set in bashrc. Any suggestions
04:41:43FromDiscord<T0lk1en> It says cannot open file: sysinfo
04:41:57FromDiscord<T0lk1en> Which is the package I’ve installed
04:47:59FromDiscord<m4ul3r> In reply to @Girvo "Is there a nim-only": https://nim-lang.org/docs/tables.html
04:51:10FromDiscord<Girvo> In reply to @m4ul3r "https://nim-lang.org/docs/tables.html": Sure, though it needs to be serialised in/out to a file too 🙂 figured I'd ask if there was something existing already
04:51:42FromDiscord<m4ul3r> In reply to @T0lk1en "Yo I’m on Linux": if you installed with nimble and made no config modifications, should be in `~/.nimble/pkgs`
04:52:37FromDiscord<T0lk1en> In reply to @m4ul3r "if you installed with": Yeah it’s there. It’s just that when I compile the program it doesn’t “see” it
04:53:06FromDiscord<m4ul3r> In reply to @Girvo "Sure, though it needs": Nim has a std/marshal, might work?
04:53:59FromDiscord<m4ul3r> Are you compiling as root?
04:54:50FromDiscord<T0lk1en> Yes
04:56:16FromDiscord<m4ul3r> Then you probably don't have the nimble package installed for root, it will search under `/root/.nimble/pkgs`
04:56:25FromDiscord<T0lk1en> Ah
04:57:07FromDiscord<T0lk1en> That was it thanks
04:57:31FromDiscord<T0lk1en> Clever clever
04:58:48FromDiscord<m4ul3r> yeah there's many different ways to go about setting that up, I would just compile as user and then chown it to root if it needs to be owned by root
04:59:22FromDiscord<T0lk1en> I just sudo nimble
04:59:29FromDiscord<T0lk1en> I guess that isn’t the best way but whatver
05:00:25FromDiscord<m4ul3r> it works, will just install packages at two different locations
05:05:09FromDiscord<T0lk1en> Yeah
05:32:44FromDiscord<Array in ∀ Matrix> @T0lk1en do u need to run the program as root?
05:33:21FromDiscord<T0lk1en> For some reason yes. It’s read only when opened without sudoedit
05:33:41FromDiscord<T0lk1en> I wouldn’t know why tho
06:15:31*argonica joined #nim
07:03:25*ltriant quit (Ping timeout: 252 seconds)
07:18:56*om3ga quit (Ping timeout: 260 seconds)
07:19:06*om3ga joined #nim
07:22:23*azimut quit (Ping timeout: 255 seconds)
07:30:52*argonica quit (Quit: Leaving)
07:42:16*byanka__ joined #nim
07:42:25*PMunch joined #nim
07:45:39*byanka_ quit (Ping timeout: 260 seconds)
07:49:28*FromDiscord quit (Ping timeout: 256 seconds)
07:50:21*FromDiscord joined #nim
08:07:15*argonica joined #nim
08:46:08*argonica quit (Quit: Leaving)
10:20:12PMunchHmm, I have a macro which takes a symbol and generates a proc with that name. Now I want to log something in this generated proc with the name of the proc attached
10:20:19PMunchWhat would be the best way of doing that?
10:20:40PMunchJust putting the name in backticks in a string literal didn't work
10:33:11FromDiscord<demotomohiro> @PMunch How about to use `strVal` proc in macros module? https://nim-lang.org/docs/macros.html#strVal%2CNimNode
10:33:32FromDiscord<Rika> https://nim-lang.org/docs/system.html#astToStr%2CT
10:33:42FromDiscord<Rika> Or that sure
10:43:47PMunchastToStr is nice, means I don't need to have an extra macro to call strVal
10:43:54PMunchAnd I don't have to import macros
10:50:34*ltriant joined #nim
11:51:33Amun-Rais there a difference between func foo(T: type Obj) and func foo(T: typedesc[Obj])?
12:11:24PMunchAmun-Ra: https://forum.nim-lang.org/t/7891
12:11:58PMunchBasically `type Obj` is `typeof(Obj)` which returns `typedesc[Obj]` if I understood this correctly
12:13:56FromDiscord<Rika> its not recommended to use `type` in this context anymore
12:14:01FromDiscord<Rika> always use typedesc
12:55:39om3gaHi! how one would set name of thread using system/threads?
13:05:08PMunchom3ga, what do you mean?
13:05:56FromDiscord<Rika> threads have names?
13:07:04PMunchYou can name them in both Windows and Linux it seems
13:07:13PMunchBut I don't think Nim has this wrapped anywhere convenient
13:07:44om3gaPMunch: it's possible to set the name for specific thread
13:08:58om3gausing pthreads for example, if Im not mistaken function called pthread_setname function does that
13:12:40PMunchom3ga, doesn't appear to be wrapped in Nim unfortunately
13:13:04PMunchWhich means you have to do it yourself if you want to use it
13:13:47*pbsds6 joined #nim
13:13:59*dv^_^8 joined #nim
13:15:48*Lord_Nightmare2 joined #nim
13:17:16*crem1 joined #nim
13:19:12om3gaPMunch: thanks, I will try to import it
13:20:15*mal``` joined #nim
13:20:36*pbsds quit (*.net *.split)
13:20:37*Lord_Nightmare quit (*.net *.split)
13:20:37*dv^_^ quit (*.net *.split)
13:20:39*crem quit (*.net *.split)
13:20:40*mal`` quit (*.net *.split)
13:20:40*pbsds6 is now known as pbsds
13:20:40*dv^_^8 is now known as dv^_^
13:20:40*Lord_Nightmare2 is now known as Lord_Nightmare
13:22:14PMunchDamn it, my Vim just suddenly decides to stop supporting PgUp/PgDown..
13:29:51FromDiscord<Phil> To be on the safe side, if I do a custom exception, I should inherit from `CatchableError` right?
13:37:59Amun-Radepends, do you need such a broad type?
13:38:36Amun-RaI usually inherit from ValueError (if I encounter value I didn't expect)
13:41:19FromDiscord<Phil> In reply to @Amun-Ra "depends, do you need": Not really, just trying to find a general "thing", I guess its better to inherit from the fitting "parentError" if yours is a specification of it.
13:41:26FromDiscord<Phil> (edit) "specification" => "specific sub-case" | "it." => "it"
14:06:11Amun-RaI'd use CatchableError in this case
14:54:57*azimut joined #nim
15:39:38*arkurious joined #nim
15:55:53FromDiscord<deech> This might be of interest, it's a specific case of a team deciding not to adopt Nim due to issues around style insensitivity. Ironically this person was nervous not because of Nim's stance on sensitivity but because of the RFC to remove it. At this point it might be worth issuing an official set of immutable identifier equality rules that are no longer up for discussion, perhaps even with Nim 2.0. https://github.com/ziglang/zig/issues/14228
16:05:21FromDiscord<Gumbercules> Leave it to dom to suggest changes that scare people away....
16:05:43FromDiscord<Gumbercules> or entire companies rather
16:07:40FromDiscord<deech> It's not the fault of the person to brought it up but it should be closed with some official resolution.
16:12:16FromDiscord<Gumbercules> They could have helped provide that resolution though...
16:12:56FromDiscord<Gumbercules> but it's another loose thread and I imagine at this point since Andreas doesn't care, the answer is it will not be removed
16:13:14FromDiscord<Gumbercules> (edit) "but it's another loose thread and I imagine at this point since Andreas doesn't ... care," added "seem to"
16:13:21FromDiscord<Nerve> What in the heck is going on here? I am genuinely baffled. I use exported `const` tables all over the rest of this project and I have no clue why this error is only appearing here. https://media.discordapp.net/attachments/371759389889003532/1067477214792261652/table_type_error.png
16:13:53FromDiscord<Gumbercules> In reply to @Nerve "What in the heck": is `chan` a distinct int or something?
16:13:59FromDiscord<Gumbercules> (edit) "distinct int" => "`distinct int`"
16:14:06FromDiscord<Nerve> Nope, it's a string from a `seq[string]`
16:16:00FromDiscord<Gumbercules> did you `import tables` into that module?
16:16:01FromDiscord<Nerve> (edit) "Nope, it's a string from ... a" added "`channels` which is"
16:16:18FromDiscord<Nerve> Holy smokes you're right
16:16:26FromDiscord<Nerve> I keep forgetting `[]` is a proc
16:16:37FromDiscord<Nerve> NOT a universal syntax feature
16:17:17FromDiscord<Gumbercules> yeah, but this is nice since you can overload it
16:17:29FromDiscord<Nerve> Indeed
16:17:45FromDiscord<Gumbercules> glad we got it sorted 🙂
16:19:29FromDiscord<Gumbercules> In reply to @deech "This might be of": might also be better to bring this up in #internals so it doesn't get drowned out in the noise
16:19:30FromDiscord<Nerve> Also how can you split statements/expressions/strings over multiple lines? I have a few long ones
16:19:53FromDiscord<Gumbercules> strings you can use `"""`
16:20:51FromDiscord<Gumbercules> https://github.com/Tail-Wag-Games/frag/blob/master/src/gfx.nim#L1048-L1049
16:20:58FromDiscord<Nerve> What if it's supposed to be a single-line string but I need to define it across multiple lines?
16:21:50FromDiscord<Gumbercules> I imagine you need to do the `"\n" & "string continues here"`
16:21:59FromDiscord<Gumbercules> maybe parens would work, let me try in the playground
16:24:05FromDiscord<Gumbercules> sent a code paste, see https://paste.rs/ZIf
16:25:14FromDiscord<Nerve> oh, commas can be used to split lines?
16:25:18FromDiscord<Nerve> well
16:25:24FromDiscord<Nerve> that's just `echo` I imagine
16:25:37FromDiscord<Gumbercules> yeah echo takes a `vararg[string]` I think
16:26:08FromDiscord<Nerve> Well, guess I have a 183 column line for now
16:26:51FromDiscord<Gumbercules> 😄
16:26:58FromDiscord<Gumbercules> there's probably a way I'm not aware of
16:27:11FromDiscord<Gumbercules> I don't do a ton of string manipulation with Nim though
16:30:29FromDiscord<Gumbercules> also @deech I know you brought it up in internals already, but this seems like such a silly reason to choose language X over language Y
16:31:31FromDiscord<Gumbercules> even if find and replace didn't exist, I'd be concerned with a lot of other aspects of the PL before style insensitivity became a sticking point
16:31:44FromDiscord<Gumbercules> maybe it's more an admonishment of Nim's development process
16:31:49FromDiscord<Gumbercules> (edit) "maybe it's more an admonishment of Nim's development process ... " added "/ transparency"
16:31:50FromDiscord<deech> In reply to @Gumbercules "also <@271498588981297157> I know": I don't think it is. In fact I'm personally not a fan of style insensitivity. I have a couple of posts in that thread but they are buried.
16:31:51FromDiscord<Phil> `Warning: See corresponding Defect; OverflowError is deprecated [Deprecated]`↵This warning means you should use OverflowDefect, correct?
16:32:31FromDiscord<Gumbercules> In reply to @deech "I don't think it": I will look for them
16:32:35FromDiscord<Phil> Though Defect is compile time and this nimforum code seems like a runtime error =/
16:33:39FromDiscord<Phil> Wait, yeah OverflowDefect is the wrong move, ValueError is the intended upgrade path, nevermind
16:33:58FromDiscord<Gumbercules> In reply to @Isofruit "Wait, yeah OverflowDefect is": what a helpful warning then
16:34:35FromDiscord<Phil> Eh, the warning is just that OverflowError is deprecated, the code can't know that the try-except that the OverflowError was used in doesn't throw an OverflowError anymore but a ValueError
16:35:20FromDiscord<Gumbercules> yeah but the suggestion is worthless in this case
16:35:29FromDiscord<Gumbercules> it might as well just say `warning: OverflowError is deprecated`
16:40:02FromDiscord<Phil> Just to be on the safe side: The nimforum has a ton of "imported and not used" warnings. Are there any hidden mechanisms that would allow the module to show up as "not used" even though it actually is used?↵Karax/JS backend stuff mostly
16:41:01FromDiscord<Phil> Nevermind, yes there are, when blocks, damnit
16:41:09FromDiscord<Gumbercules> In reply to @Isofruit "Just to be on": compiling with certain static conditionals?
16:41:14FromDiscord<Gumbercules> yeah that
16:41:28FromDiscord<Gumbercules> but I mean that's fixable - just move the import under the `when` block
16:41:32FromDiscord<Gumbercules> or `static` block
16:41:40FromDiscord<Phil> Yeah but that means I can't just blindly throw away imports
16:41:43FromDiscord<Phil> Is the main thing
16:41:50FromDiscord<Gumbercules> truth
16:41:58FromDiscord<Gumbercules> you could blindly throw away the nimforum project
16:42:23FromDiscord<Gumbercules> that'd be my suggestion 🙂
16:48:02FromDiscord<Phil> Meh, it's not the greatest thing ever written but realistically it's not going to get thrown away period.
16:48:17FromDiscord<Phil> So might as well do a bit of maintenance
17:00:40FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4m6z
17:29:10*argonica joined #nim
17:41:42*argonica quit (Remote host closed the connection)
17:42:48*argonica joined #nim
17:43:22*argonica quit (Remote host closed the connection)
17:44:23*anddam quit (Quit: WeeChat 3.7.1)
17:44:30*argonica joined #nim
17:45:28*jmdaemon joined #nim
18:01:39*jmdaemon quit (Ping timeout: 260 seconds)
18:04:00*jmdaemon joined #nim
18:07:59*argonica quit (Quit: Leaving)
18:14:16*anddam joined #nim
18:34:12FromDiscord<auxym> yeah from my understanding the IO stuff (open, readfile, etc) won't be in system anymore starting with 2.0 you'll have to import std/syncio
18:44:14*genpaku quit (Read error: Connection reset by peer)
18:48:43*genpaku joined #nim
18:51:12*argonica joined #nim
19:40:45*jmdaemon quit (Ping timeout: 255 seconds)
19:42:28*jmdaemon joined #nim
19:47:16*argonica quit (Quit: Leaving)
20:09:06*jmdaemon quit (Ping timeout: 255 seconds)
20:38:25*argonica joined #nim
21:35:28FromDiscord<MartinSkou> Any way to get std/terminal to behave nonblocking?
22:06:36FromDiscord<Elegantbeef> You're best to look at Illwill or Nimwave for that
22:11:31FromDiscord<debris> Hi all! I'm trying to write a toy interpreter for a concatenative dynamically typed language that's similar to forth but I'm not really sure how to implement a dynamically typed environment hashmap/stack/array. Is there an endorsed way to do this in Nim? I'd assume it's not something usual since Nim is type safe...
22:11:56FromDiscord<Elegantbeef> You'd use something like `std/json`'s `JsonNode`
22:12:09FromDiscord<Elegantbeef> Where you use an object variant for the primitive part of your types, then compose them for the complex types
22:12:55FromDiscord<debris> Thank you, I'm going to try that, although json does feel a bit overkill to me.
22:13:08FromDiscord<Elegantbeef> I'm not saying use json
22:13:16FromDiscord<Elegantbeef> I'm saying make a data type like JsonNode
22:13:40FromDiscord<debris> Oh, sorry, I misunderstood. Okay then.
22:40:00*argonica quit (Quit: Leaving)
22:43:32*azimut quit (Ping timeout: 255 seconds)
22:44:45*azimut joined #nim
22:44:58FromDiscord<michaelb.eth> is there a way to tell nim to print stacktraces to stderr instead of stdout?
23:07:39FromDiscord<m4ul3r> Interesting I'm getting `nan` as a float with multiplying with something like `0 0 / 0.92042`
23:11:52FromDiscord<m4ul3r> nvm - i figured it out. My last floats were 0 without realizing
23:13:20FromDiscord<michaelb.eth> actually, nvm, I had a misunderstanding... the stacktrace is already getting printed to stderr but the program is exiting the terminal's alternate screen upon crash so I didn't it
23:13:40FromDiscord<michaelb.eth> a `2>` redirection takes care of that