ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
wootehfoot has quit [Ping timeout: 260 seconds]
ryuukk__ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
frmdstryr has joined #zig
<CmdrCrisp> Hey all, I'm just getting started with Zig (like... today) and thought I would try to get dearImgui up and running. Could someone give me a hint on how Zig declares a variable as a pointer to a c-abi struct?
a92 has quit [Quit: Leaving]
<JoshAshby> I don't know if this is "correct" or the zig way, but when I was setting up dear imgui I was just using std.mem.zeroes(<c struct>), since the structs I was working with were all being initalized by dear imgui/glfw later on
<JoshAshby> slightly unrelated to your question but are you on mac? I recently tried to use both dearImgui (via cimgui) and nuklear from zig on macOS and I believe I'm hitting https://github.com/ziglang/zig/issues/6675 or a related issue :/ haven't had much time to dig into it though, yet
<CmdrCrisp> @joshashby thanks for picking up my Q. I'm not working on a mac, Linux is my daily driver. I think I asked the wrong question in any case. At a learning example, I'm trying to translate https://github.com/peko/cimgui-c-example/blob/master/src/main.c in to zig. The unitialized pointers to structs (lines 27-29) are throwing me for a loop.
xackus has quit [Ping timeout: 240 seconds]
cole-h has joined #zig
jj__ has quit [Quit: Leaving]
jj__ has joined #zig
jj__ has quit [Client Quit]
jjsullivan1 has joined #zig
benjif has quit [Quit: Leaving]
<JoshAshby> ah, well I'm out of my element unfortunately as I don't have a ton of experience using C from Zig either. sorry :s that said I have found that making use of zig translate-c as well as looking at Andrews projects that use libs like glfw helpful, while you wait for someone better equpied to get back to you: https://github.com/andrewrk/tetris https://github.com/andrewrk/zig-vulkan-triangle
<CmdrCrisp> Thanks for the hints. I'm slowly cutting through my issues. In the mean time, i'm getting used to the build system. Feels a bit like CMAKE.
x2C25 has quit [Ping timeout: 264 seconds]
gel_babana has joined #zig
ryuukk_ has joined #zig
kristoff_it1 has quit [Ping timeout: 260 seconds]
gel_babana has quit [Ping timeout: 258 seconds]
lucid_0x80 has joined #zig
CmdrCrisp has quit [Ping timeout: 260 seconds]
Kingsquee has quit []
waleee-cl has quit [Quit: Connection closed for inactivity]
tempnicksimp has joined #zig
<tempnicksimp> hey, I've got a question about comptime semantics
<tempnicksimp> If you `zig build` this, you don't get any comptime errors, even with the invalid value.
<tempnicksimp> but the unreachable code will crash with the stacktrace and all at runtime
<tempnicksimp> if I make the return type `comptime_int` it catches it at comptime, but is putting a comptime block around the for going to search for any invocation of the function and ensure it's valid?
<tempnicksimp> What's being evaluated at comptime in this case, if it doesn't check for places where you call the function?
Kingsquee has joined #zig
<daurnimator> not sure about your question tempnicksimp; but your names_and_vals looks a lot like an enum
<tempnicksimp> I initially tried an enum.
<tempnicksimp> The issue is I also wanted to print the name and whatnot in the example this is simplified from
<tempnicksimp> I simplified it to help illustrate the abnormality.
<tempnicksimp> But in my actual use case I'm printing window messages and their numbers etc.
<tempnicksimp> So it being available as a string is already happening, such that making an enum would be redundant.
<tempnicksimp> I didn't see anything in the docs about getting returning a name for a given value (the reverse of an enum?) like a tag or anything, so I went with the anonymous struct instead.
<daurnimator> Use `std.fmt`
<tempnicksimp> I tried messing with `fmt.format` (I think it was)
<tempnicksimp> how would you suggest using the lib for that?
<daurnimator> tempnicksimp: you might be looking for @tagName
<tempnicksimp> I saw tagName, but I didn't know how to get that printed
<tempnicksimp> fn print_win32_message(u_msg: std.os.windows.UINT) void {
<tempnicksimp> format?
<tempnicksimp> shit, couldn't put that in code block
<tempnicksimp> anywho, that's the way I was posting the window message and number etc.
<tempnicksimp> It's a mess but I'm playing around.
<daurnimator> tempnicksimp: you may need to convert your integer to an enum with @intToEnum
<tempnicksimp> Oh, that sounds good.
<tempnicksimp> I'll try that.
<tempnicksimp> With that said, to clarify the original example was just an inquiry about how comptime works.
<tempnicksimp> So the assignments within the for loop and what not don't look to the calls to see if the unreachable code is reached for each call?
<tempnicksimp> with a `comptime_int` return it does seem to do that, but putting the comptime block around the for doesn't seem to have that effect.
<tempnicksimp> What's going on semantically?
ask6155 has joined #zig
<daurnimator> tempnicksimp: TBH I don't really understand why we didn't get some error about hitting unreachable at comptime
<tempnicksimp> That's exactly what I would expect
<tempnicksimp> I thought about putting up an issue, but I wanted to be sure I wasn't misunderstanding.
<daurnimator> sounds like it could be a bug.... but it may be by design... need someone more knowledgeable to answer
xd1le has quit [Read error: Connection reset by peer]
<daurnimator> tempnicksimp: FYI you can put the `comptime` at the call site. e.g. `_ = comptime name_to_val("invalid");`
<tempnicksimp> as well as you can return a comptime int
<tempnicksimp> then the function will be evaluated as a expression, which is more ergonomic switching over.
<tempnicksimp> (although in this case I'll be switching back to an enum anywho)
xd1le has joined #zig
rx_ has joined #zig
lucid_0x80 has quit [Ping timeout: 258 seconds]
<tempnicksimp> went ahead and bit the bullet on making an issue in case it's a bug after all https://github.com/ziglang/zig/issues/6802
x2C25 has joined #zig
rx_ has quit [Quit: Konversation terminated!]
endragor has joined #zig
xd1le has quit [Remote host closed the connection]
<endragor> Hi! I've got a couple of newbie questions, would appreciate if someone could answer. 1) stdlib exports math and atomic functions when you build a dynamic library. Is there a reason for that? 2) How do I make `zig build` produce executable in a predictable location? By default it's in an obscure folder under zig-cache/o/
xd1le has joined #zig
earnestly has quit [Ping timeout: 240 seconds]
ask6155 has left #zig [#zig]
<daurnimator> endragor: where do you see 1)?
<daurnimator> endragor: 2) you need to use `.install()` I think. which installs it to what you set in .setOutputDir
<endragor> daurnimator: thanks! (1) can be seen with `nm`, `objdump`, `readelf` or any other tool that may print exported symbols. You will already see these symbols if you just run `zig build-lib -dynamic empty.zig` on an empty file. I also noticed these functions are explicitly marked with `export` in the stdlib, so it seems to be on purpose.
cole-h has quit [Ping timeout: 260 seconds]
ask6155 has joined #zig
_whitelogger has joined #zig
ask6155 has left #zig [#zig]
ask6155 has joined #zig
marnix has joined #zig
ask6155 has left #zig [#zig]
ask6155 has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
lucid_0x80 has joined #zig
decentpenguin has joined #zig
<daurnimator> endragor: I thought that was only the case for the wasm target and not others?
<daurnimator> endragor: and are these functions in compiler-rt? or elsewhere?
<endragor> daurnimator: It seems that has to do with debug mode. When compiling with ReleaseFast, the library exports only what I expect it to. But debug build contains symbols from c.zig and compiler-rt.
ask6155 has left #zig [#zig]
moinstar has joined #zig
ask6155 has joined #zig
tane has joined #zig
lucid_0x80 has quit [Ping timeout: 240 seconds]
ask6155 has left #zig [#zig]
<danyspin97_> Is there any news on a 0.7.0 version?
<Michcioperz> Andrew got sudden problems with his landlord
<Michcioperz> is last thing i know
<endragor> Does Zig intend to provide the tools necessary to build a fiber-based job system? Or should I not look at async/await capabilities for that? It seems it solves some parts, but not the others - for example, calling functions with non-Async callconv and expect them to work within the fiber context (yield execution where needed, while extending the current stack instead of allocating a new one).
xd1le has quit [Remote host closed the connection]
<danyspin97_> Michcioperz: Ah I see
earnestly has joined #zig
<daurnimator> endragor: yes. std.event.Batch is that system.
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
<tempnicksimp> Is there a way to handle the undefined behavior case of trying to convert an interger which isn't represented in the enum?
<tempnicksimp> the enum just looks like
<tempnicksimp> ```
<tempnicksimp> ... how do you do multilines in Kiwi o_o
<tempnicksimp> m
<tempnicksimp> the github said you could do alt+enter
<tempnicksimp> const u_msgs = enum(c_uint) {
<tempnicksimp> ...
<tempnicksimp> looks like that
<daurnimator> tempnicksimp: add a `_` item to your enum to make it "non-exhaustive"
skuzzymiglet has joined #zig
<tempnicksimp> so that switch is happening at compile time
<tempnicksimp> non-exhaustive will effect this undefined behavior?
<daurnimator> non-exhaustive means that other non-listed values may exist and are not undefined behaviour
<tempnicksimp> okay, so it will just give it a bad value and I'll get else at the end of the switch?
<tempnicksimp> It says it doesn't fail.
<tempnicksimp> Does that mean it just is still a member of the enum?
<tempnicksimp> I was a bit confused by the wording
<daurnimator> it's a catch all for not-a-member of the enum
<daurnimator> like, if you have a u8, and define a=1, and b=2... _ is all of the other values (0 and 3-255)
<tempnicksimp> Oh, I see.
<tempnicksimp> Thanks
<daurnimator> tempnicksimp: it's most often used in situations where a library/hardware says "1 is function X; 2 is function Y; we may add more in future"
<tempnicksimp> Yeah, I was wondering both about the type of the unlisted values and how it would be formatted
<tempnicksimp> interesting
<tempnicksimp> @tagName is useful as well
x2C25 has quit [Ping timeout: 260 seconds]
<tempnicksimp> Yeah, I'm looking at that now, it is a lot of code tho.
<tempnicksimp> thanks!
<tempnicksimp> (again ;p )
<daurnimator> tempnicksimp: looks like you should add 49405 to your enum :)
<tempnicksimp> can't
<tempnicksimp> not documented ;(
<tempnicksimp> or rather I can but it's `unknown_message`
<tempnicksimp> welcome to windows
<daurnimator> doesn't matter if its not documented....
<tempnicksimp> I'm not covering the case.
<tempnicksimp> It's some system message, is there a good reason to add it?
<tempnicksimp> (in principle)
<daurnimator> so that users can handle it
<tempnicksimp> ... what do I name it?
xackus has joined #zig
<tempnicksimp> I have no idea what Windows is using the message for.
<daurnimator> great question. suprisingly I don't get any google results searching for it
<tempnicksimp> I grepped the entire reactos codebase as well
<tempnicksimp> the last couple messages left undocumented have been a wild goosechase.
<daurnimator> so we're probably left with learning it from windows debugging symbols; or from someone that's willing to pollute their mind (and future contribution ability) by reading the windows leaked source code
<tempnicksimp> that's actually interesting, if you gave a reasonable name to it based off the leaked source, could they get you for that at all?
<tempnicksimp> Their api exposes the message itself.
<tempnicksimp> > windows debugging symbols
<tempnicksimp> sounds particularly difficult, WinDBG gives you help on this?
Kingsquee has quit []
tane has quit [Ping timeout: 260 seconds]
<endragor> daurnimator: regarding std.event.Batch - that doesn't solve my needs. I'd like something similar to Windows fibers API, but cross-platform: https://docs.microsoft.com/en-us/windows/win32/procthread/fibers . There you can yield to another fiber from any function, you don't need special calling conventions. The problem with Zig is that, as I understand, you can only call non-async functions with either @asyncCall, which requires a new
<endragor> stack, or "synchronously", which doesn't allow them to yield.
<daurnimator> endragor: hmm?
<daurnimator> endragor: @asyncCall(foo, ....)` is syntax for a special use-case of `async foo()`. ignore that builtin for now.
<daurnimator> endragor: in zig, calling an async function *turns you into an async function*
<daurnimator> (unless you use the special keyword `nosuspend`, which is an assertion; ignore that for now)
<endragor> daurnimator: "turns into an async function" means "changes calling convention", right? So what if I want functions from dynamic libraries to be able to yield? They have to have .C calling convention.
rzezeski has quit [Quit: Connection closed for inactivity]
wootehfoot has joined #zig
<daurnimator> endragor: yes. and so that tells you that you need some way to indicate to the scheduler (whatever that is) when you are yielding and how to resume
rzezeski has joined #zig
xackus has quit [Ping timeout: 260 seconds]
<endragor> daurnimator: With Windows API the scheduler itself is a fiber that others may yield to. It then may decide which fiber to execute next. Internally the fiber state is shared via thread-local storage, as I understand. So there is no similar abstraction in Zig? I mean async/await is similar, yes, but requires a new calling convention. It seems I should go with something like https://github.com/paladin-t/fiber
wootehfoot has quit [Read error: Connection reset by peer]
<daurnimator> endragor: so that might answer "how to yield" (though maybe it doesn't say what to yield *to*); but it doesn't say how we register ourselves for resumption
<endragor> daurnimator: yeah that should be a part of the scheduler API that is built on top of fibers
skuzzymiglet has quit [Ping timeout: 264 seconds]
<daurnimator> endragor: while you could build a zig scheduler on top of that; the std lib builds on top of lower level primitives
kristoff_it1 has joined #zig
<endragor> daurnimator: yeah I was wondering if this low-level primitive exists in Zig. I'm planning to use the C version of fibers with Zig scheduler on top of it.
CmdrCrisp has joined #zig
<daurnimator> endragor: (I don't think this is the status quo; but its where I think we're going): zig considers NtWaitForMultipleObjects to be the only true primitive on windows
riba has joined #zig
frmdstryr has quit [Ping timeout: 260 seconds]
wootehfoot has joined #zig
riba has quit [Ping timeout: 240 seconds]
tane has joined #zig
ryuukk__ has joined #zig
ryuukk_ has quit [Ping timeout: 260 seconds]
skuzzymiglet has joined #zig
osa1 has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
klltkr has joined #zig
endragor has quit [Remote host closed the connection]
xackus has joined #zig
Patrice_ has quit [Ping timeout: 272 seconds]
ryuukk_ has joined #zig
ryuukk__ has quit [Ping timeout: 260 seconds]
hnOsmium0001 has joined #zig
frmdstryr has joined #zig
<ryuukk_> where can i find list of types for @typeInfo ?
<ryuukk_> i have trouble figuring what to use for fixed size slices
TheLemonMan has joined #zig
<TheLemonMan> so...arrays?
<ryuukk_> i don't know that is why i ask
<TheLemonMan> when in doubt ask the compiler
<TheLemonMan> @compileLog(@tagName(@typeInfo(T)))
<ryuukk_> thanks
<TheLemonMan> there's no documentation for the inner typeinfo fields, you have to either read some other code in the stdlib or ir.cpp
<ryuukk_> i wish VSCODE would allow go to source when i ctrl click to @ stuff, just like it does with other stuff
<TheLemonMan> oh wait, check out builtins.zig
cole-h has joined #zig
<ifreund> yes, std.builtin.zig is what you want
<ifreund> look at the TypeInfo definition
<ikskuh> heya TheLemonMan o/
<TheLemonMan> sup ikskuh
<TheLemonMan> how's life treating y'all?
* ikskuh has just handed over his old flat to the landlord
<ikskuh> i now officially moved to the new location
<ikskuh> less stress, more zig!
<BaroqueLarouche> For great justice!
<ikskuh> i'm learning on how to implement a event loop in zig right now :)
<ikskuh> pretty good experience
<TheLemonMan> noice, noice
<ikskuh> and it's embedded HW
<ikskuh> and my main annoyance is that Writer.write enforces error handling :D
Kena has joined #zig
virkony has joined #zig
<Kena> Hello computer people, do you know why `@typeInfo` is written in camelCase and `@TagType` is in PascalCase? is it a voluntary asymmetry?
<ikskuh> heya
<ikskuh> @TagType returns a type (UpperCase) wheras @typeInfo returns a normal value
<ikskuh> it just follows the style guide that types are PascalCase and functions are camelCase
<ifreund> this convention is applied to all functions, e.g. std.ArrayList() vs std.debug.print()
<Kena> Thank you buddy, you're kind.
<Kena> It would be REALLY helpful if the documentation were to be enhanced with some definition of the concepts, like enum, struct, union. One sentence to explain what it is, another to explain its use case and a third to tell us what are its strenghts and weaknesses.
<ikskuh> Kena: right now the docs are strongly programmer-focused
<ikskuh> if you are a newbie, you might want to check out https://ziglearn.org/ :)
<Kena> Because in the current state, even read entirely 2 times the official doc doesn't provide a sufficient level to begin to code for a complete beginner. A lot of concepts are swept under the rug and many mecanics make assumptions regarding to the reader's expected priorabilities
<ikskuh> yeah, true
<Kena> *prior abilities.
skuzzymiglet has quit [Ping timeout: 260 seconds]
<ikskuh> this is a known problem
<ikskuh> but right now the focus is on "making the language stable"
<ikskuh> but yeah, these are just excuses *grin*
<tane> currently, only looking at std lib source files is of real help and even there I failed to see any function that, e.g., turns a string into a std.fs.Dir
<ikskuh> tane: std.fs.Dir.openDir :D
<ikskuh> used with cwd()
<Kena> Yeah that make sense that trying to seduce noobies is pretty overrated. That is nos the kind of people who will be quickly involve as contributors ... :/
<tane> ikskuh, yeah... so how about an absolute path?
<ikskuh> pass in an absolute path ;)
<ikskuh> std.fs.cwd().openDir("/", …)
<ikskuh> Kena: that's not what i wanted to say ;)
<ikskuh> the language is still in flux and the docs need to be updated a lot
<virkony> There is defer and errdefer. Is there any "success defer"? I.e. execute only if not returning error
<ikskuh> virkony: no, there was a proposal to do so, but it was discovered that successdefer isn't required
<virkony> ikskuh: where do I find proposals archive?
<Kena> Allright, so if it's known I suppose it's already encouraging.
<tane> ikskuh, thank you (I don't get how this is even remotely intuitive :D)
* virkony tried github before asking, but unsuccesfully
<ikskuh> tane: i don't think it's intuitive as well
<ikskuh> Kena: right now, the docs are also horrible to write 🙈
<Kena> is it because of a inadequate generation tool you mean?
<ryuukk_> ikskuh: Kena: right now the docs are strongly programmer-focused, non programmer use zig?
<ryuukk_> telling people to check ziglearn when it is also very incomplete is bad thing to do
<ryuukk_> better just say: doc is not finish
<ikskuh> ryuukk_: ziglearn contains more info and is more in flux :)
<ryuukk_> and this should be written at the top of the doc, so people know what to expect
<ikskuh> sobeston is also happy to hear when there is stuff missing :)
<ryuukk_> - Work in Progress - should be at the top, a red banner, otherwise poeple who come in to check the language will be very disapointed, like me
<TheLemonMan> send a few grands this way and I'll write all the docs you want
<ryuukk_> it is not about money
<ryuukk_> it is about your intention with the language and the doc
<ikskuh> ryuukk_: oh. that won't help
<ikskuh> people don't read the banners anyways
<virkony> I only found mention on IRC logs that refer to lack of examples. Example of code for successdefer from CppCon 2015 by Andrei Alexandrescu: https://youtu.be/WjTrfoiB0MQ?t=2600
<ryuukk_> if you want people to use, tell them what is the actual state of things
<TheLemonMan> for me it is, writing docs is boring and I prefer code
<ryuukk_> write code that generates it
<ikskuh> doesn#t help ;)
<ikskuh> you cannot generate docs out of thin air
<TheLemonMan> that's where neural networks come into play
<ikskuh> you can only make writing docs easier
<ryuukk_> well if you want to make a language for the world, you gotta document it
<ikskuh> true
<ikskuh> i don't think anyone objects here ;)
<ryuukk_> otherwise you'll keep answser same questions forever on IRC
<ikskuh> but i think focusing on docs is right now wasted energy
<ikskuh> and the core devs should focus on making the language stable
<ryuukk_> it is not about focusing on doc
<bfredl> documentation by GPT-3?
<ryuukk_> it is about putting commong info on it
<ryuukk_> where is energy spent right now?
<ikskuh> ^= kristoff_it1 you could do this
<TheLemonMan> bfredl, great idea for a startup
<ikskuh> ryuukk_: making the language stable and creating the self-hosted compiler
<ryuukk_> why need self hosted compiler when LLVM works right now?
<bfredl> just use a few fataruma projections.
nyaayaya is now known as Yunree
<bfredl> the forth projection should be: auto-generated docs
Yunree is now known as Nyaayaya
Nyaayaya has quit [Quit: byeee~]
<ikskuh> ryuukk_: because not everyone has 10 GB of RAM to compile stuff
<ikskuh> self-hosted compiler will be correct, well planned
<ikskuh> fast
<ikskuh> memory-efficient
<ikskuh> stage1/llvm version is just "it barely works"
ask6155 has joined #zig
Nyaayaya has joined #zig
<TheLemonMan> I've always heard that unused ram is wasted ram, we should use even more memory
<ikskuh> less CI for everyone!
<tane> TheLemonMan, that explains a lot :<
Nyaayaya has quit [Client Quit]
Nyaayaya has joined #zig
Nyaayaya is now known as yunree
yunree has quit [Client Quit]
Nyaayaya has joined #zig
<bfredl> lol the kernel is supposed to take care of that by itself
<bfredl> by using unused ram as disk cache. no ram cell untouched.
<ikskuh> ^=
<ikskuh> having 32G RAM and only needing 2 is just glorious disk speed
<bfredl> or just mmap all the things
wootehfoot has joined #zig
<bfredl> I do this with my huge numpy vectors. python has never been that fast without virtmem pressure..
<TheLemonMan> > python has never been that fast
<TheLemonMan> ftfy
<bfredl> a (non-anon) mmap is bascially an allocation with free extra swap. and COW logic kernel side if you want it.
<bfredl> like you know, the kernel can solve problems for you. if you just ask it nicely.
<ikskuh> bfredl: sadly, i can't :(
<bfredl> becuz you write the kernel?
<ikskuh> hah
<ikskuh> kinda
<ikskuh> embedded hardware
<ikskuh> "baby" steps on LPC1786 with zig
<bfredl> that's nice
<ikskuh> i know the platform by heart now, i wrote two demos on it already
<ikskuh> in C++
<ikskuh> but now i want to get get the full power out of the hardware with zig
<ikskuh> and i'm using a event loop async/await implementation on embedded
<ikskuh> which is nice
Kena has quit [Remote host closed the connection]
dimenus has joined #zig
<bfredl> yes. async/await with exact static mem alloc is nice for sure.
<ikskuh> yeah
<ikskuh> i now have three tasks in parallel
<ikskuh> "blink the screen"
<ikskuh> "render some graphics"
<bfredl> while c++ standard be like "it might allocate on the heap, or not allocate. Who knows? :DD"
<ikskuh> :D
<ikskuh> EventLoop.waitForRegister(u32, &lpc.LPC_SSP0.SR, TNF, TNF);
<ikskuh> ↑ zig awesomeness in a nutshell
Nyaayaya is now known as yunree
<bfredl> zig had me att build.zig. like clang+cmake except a sane build config lang :D
<ikskuh> heh
<ikskuh> build.zig is really nice
<ikskuh> zig build -DReleaseSmall flash terminal
<ikskuh> okay
<ikskuh> my screen blinks, the display gets filled with some color patterns, and i can communitate via serial port
<ikskuh> all in parallel, linear tasks
<bfredl> soon i am gonna convince the neovim dev community to make neovim depend on zig :D
<bfredl> probably after the first usable stage2 release
ask6155 has left #zig [#zig]
Kena has joined #zig
yunree has quit [Quit: byeee~]
<Kena> Please does `[]const u8` represent a immutable array of bytes or an array of immutable bytes?
osa1 has quit [Remote host closed the connection]
<Nypsie[m]> A slice of immutable bytes
nyaayaya has joined #zig
<Kena> therefore, the length can vary is that right?
<ikskuh> []const u8 is a pointer+length to dynamic number of immutable u8s
<Kena> I didn't know it was a slice, I thought it was an array.
<Nypsie[m]> Arrays have a size known at compilation time
<Kena> Allright, thanks for explaining it to me.
Patrice_ has joined #zig
<Nypsie[m]> No problem :)
<ifreund> arrays are values, slices are pointers
<frmdstryr> Was going to make an issue but though I'd ask here... is there any reason why std.mem doesn't use SIMD for things like std.mem.indexOf or has it just not been implemented?
<ikskuh> i think it's just not yet implemented
<TheLemonMan> because LLVM vectorizer is awesome
<ikskuh> aaaaaaaah
<ikskuh> StackTrace.format: var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
<ikskuh> well……
osa1 has joined #zig
<frmdstryr> TheLemonMan: Does code need to be written so it'll vectoriize it automatically? Eg https://github.com/h2o/picohttpparser/blob/master/picohttpparser.c#L149
<frmdstryr> I'm guessing the repeated DOIT() 8 times is so the compiler vectorizes that?
<TheLemonMan> yeah, sometimes you have to help the compiler with some hints
<TheLemonMan> oh you asked about std.mem implementations, those suffer from the extensive use of slices
lucid_0x80 has joined #zig
AceNovo has joined #zig
waleee-cl has joined #zig
<tane> hey ikskuh, mind if I send you a PM?
<ikskuh> always welcome
AceNovo has quit [Quit: Konversation terminated!]
AceNovo has joined #zig
skuzzymiglet has joined #zig
<tempnicksimp> as I'm messing around with opening windows and whatnot on my PC, I seem to be leaking memory or otherwise leaving a crudload of it on standby, I cleared it out on windows with RAMMap, but while `zig build-exe` works fine, `zig build` seems to still fail with an OutOfMemory error when it uses the std lib's arena alloc.
<tempnicksimp> first time I had this issue it was a one-off and I ended up restarting my PC at some point.
<tempnicksimp> Is there a reason it can't use the freed memory?
frett27 has joined #zig
<TheLemonMan> arena free is mostly a no-op
<TheLemonMan> unless you're trying to free the very last allocation you've made
Patrice_ has quit [Ping timeout: 260 seconds]
<tempnicksimp> I'll pastebin the stack trace when I call `zig build`
wootehfoot has quit [Quit: Leaving]
<tempnicksimp> I may have misread, looks like `AccessDenied`?
frett27 has quit [Ping timeout: 265 seconds]
<frmdstryr> Is there any plans to have something like "zig build run --watch" that'll rebuild & run when a file changes?
decentpenguin has quit [Ping timeout: 260 seconds]
<Nypsie[m]> Stage 2 already has --watch, which is used for hot reload. Currently it requires a manual "update" command, but in the future other tools can make requests to this to trigger recompilation, or even get semantic information
<frmdstryr> That'll be nice, thanks for the info.
<Nypsie[m]> No problem :)
decentpenguin has joined #zig
<ryuukk_> a draft of my experience with zig https://gist.github.com/ryuukk/f9cf9cd7e5e913dca5fe3d6b8d029681, i probably shouldn't share it since it is just me ranting over frustration, but i feel like i should still share it, so there it is
Techcable has quit [Quit: ZNC - http://znc.in]
<ryuukk_> it is not complete, things are missed, hopefully i'll complete it over time
<Nypsie[m]> I think it's good to share it. How we experience it, may not be the same for everyone else :)
Techcable has joined #zig
Piraty has quit [Quit: ---]
Piraty has joined #zig
AceNovo has quit [Quit: Konversation terminated!]
AceNovo has joined #zig
AceNovo has quit [Read error: Connection reset by peer]
frett27 has joined #zig
AceNovo has joined #zig
AceNovo has quit [Client Quit]
osa1 has quit [Ping timeout: 246 seconds]
AceNovo has joined #zig
<TheLemonMan> tempnicksimp, yep, the error trace is a bit of a mess right now
<tempnicksimp> I just want to compile ;-;
<TheLemonMan> you're getting an AccessDenied error somewhere when something tried to rename a file
<tempnicksimp> it seems to have cleared, yeah, it does seem to only happen around the time that I have no free memory
<tempnicksimp> but that may be a coincidence.
<tempnicksimp> I wasn't using windbg last time I had this error
<tempnicksimp> but I am not so that's likely what's stopping it from accessing whatever it needs to access
klltkr has quit [Ping timeout: 240 seconds]
<TheLemonMan> but zig build shouldn't eat all your ram, it shouldn't suck this much
mattnite has joined #zig
<tempnicksimp> yeah, again, to be fair, I am opening and closing windows and probably leaking something somewhere or otherwise doing some shenanigans that aren't helping, with that said after I clear standby memory I've still had issues with access, even after switching on windows developer mode.
<tempnicksimp> "closing" I should say unceremoniously crashing all over.
<tempnicksimp> looks like windbg can't open source files if they aren't c/c++
<tempnicksimp> debugging with symbols is pain
<g-w1> does the self hosted compiler support debuginfo
<g-w1> ?
<TheLemonMan> no
<g-w1> ok
<TheLemonMan> it only supports a small chunk of DWARF
<g-w1> ok
klltkr has joined #zig
<nyaayaya> > `std.info.log("my message"), i can't, i have to add .{} at the end, why? i don't know but i hate it, it makes me type more, 3 characters, that are all annoying to type and all different`
<nyaayaya> yeaah, it's a bit confusing
lucid_0x80 has quit [Ping timeout: 240 seconds]
<ikskuh> nyaayaya: because zig doesn't have variadic arguments
<ikskuh> you either need a different function (like logNoArgs) or something
<pixelherodev> I agree with some of the points raised, I just don't consider them problems. e.g. requiring `.{}` is a bit of a pain, but it makes the code more explicit and more readable, so I'm willing to take the minor annoyance when writing code
<ikskuh> or you pass in empty arguments
<ikskuh> streams have writeAll and print as two different functions
<ikskuh> log doesn't have those, i think because it's not really usual to just log a message without additional information
<dutchie> i would like better type inference about stuff like the `return -1` point, but i assume that's coming when stage2 is more complete
<ikskuh> "return -1" should work in all cases
<ikskuh> the problem is "return if(c) a else b"
<dutchie> yeah that's the one i've run into
<ikskuh> that the information about the return value isn't bubbled into the if
<dutchie> or the same thing with switch
<ikskuh> yeah
<ikskuh> seems to work though
<nyaayaya> ikskuh: mhm, and I think it's good that Zig doesn't have them, but maybe it wouldn't be so bad to create two different functions :(
<ikskuh> there's nothing from stopping you to add those and create a PR :)
<TheLemonMan> well fuck, the FreeBSD CI started hanging
<nyaayaya> huh
<nyaayaya> (oh no, I am using FreeBSD)
<dutchie> i have only tried it with 0.6.0 not master though
marnix has quit [Ping timeout: 260 seconds]
<ikskuh> dutchie: ah, yes
<TheLemonMan> dutchie, without a single @as cast how should the compiler infer you want a u8?
<ikskuh> TheLemonMan: from the return type into the switch prong into the if
<TheLemonMan> nyaayaya, it's only the CI server that goes belly up every now and then
<ikskuh> you can bubble in a "wanted target type"
marnix has joined #zig
<TheLemonMan> hm? I see a switch full of comptime_int branches
skuzzymiglet has quit [Ping timeout: 260 seconds]
<ikskuh> yes
<ikskuh> but that switch has a target type
<ikskuh> so each switch prong must coerce to this type anyways
<dutchie> L35 also is maybe a clearer example
<ikskuh> return X;
<ikskuh> you know that X must coerce to std.meta.ReturnType(F)
<ikskuh> so when you have a "return switch() { }"
<TheLemonMan> now you're messing with me, where's the return type?
<TheLemonMan> that switch has no type annotations!
<ikskuh> you know that each prong must coerce to the return type of the function
<ikskuh> TheLemonMan: i'm talking about coercion logic
<ikskuh> here's a example that could be implemented
<TheLemonMan> oh, I was talking of dutchie's example
<ikskuh> also dutchie's example has this
<ikskuh> as each prong has a "destined" type which you can infer the wanted type
<ikskuh> which is the return type of the function
<TheLemonMan> const d = switch (...) { <- where's the destination type for the switch?
<ikskuh> it has none
<ikskuh> doesn't mean inferring can work in more places
<CmdrCrisp> Hey All, sometimes, while looking at a zig string, i see a "c" prepended to it, like: c"Some Kind of String". Does that indicate it is a c-string?
<ikskuh> CmdrCrisp: that's pre 0.6 code
<ikskuh> we changed how strings work which deprecated "c-strings"
<ikskuh> strings once were array literals
<ikskuh> where "hello" was equivalent to [_]u8 { 'h', 'e', 'l', 'l', 'o' }
<ikskuh> this has now changed with a update
<ikskuh> strings are now const pointers to zero-sentinelled arrays:
<g-w1> what was the reasoning behind this change?
<ikskuh> "hello" is now &([_:0]u8 { 'h', 'e', 'l', 'l', 'o' })
<ikskuh> g-w1: flexibility
<g-w1> ok
<ikskuh> zig introcuded sentinels for arrays and slices
<ikskuh> you can now express that the last item must be a certain value
<ikskuh> for example:
<ikskuh> [3: 0xFFFF]u16 { 1, 2, 3 }
<ikskuh> this is an array of (byte)size 8
<g-w1> cool
<ikskuh> having len 3
<ikskuh> but encoding in the type system that after the three elements, a 0xFFFF is guaranteed
<ikskuh> this is really cool
<ikskuh> as you can now encode c-strings in the type system:
<ikskuh> "[*:0]const u8"
<ikskuh> "pointer to unknown length elements, but guaranteed to be terminated by a 0
<mattnite> you can also make null terminated slices: [:0]const u8
<ikskuh> yeah
<ikskuh> this is really a huge advantage over other type systems
<g-w1> yeah. i saw that from last weeks zig showtime about pointers. cool!
<g-w1> ohh. zig showtime is soon. cool
<mattnite> yeah dawg
wootehfoot has joined #zig
<ikskuh> oh shite, completly forgot!
<ikskuh> nice, i can watch it
<ikskuh> i thought it ran already
<g-w1> its usually on sat but this week on sun
marnix has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
<kristoff_it1> Showtime is live, we start in 15m https://twitch.tv/kristoff_it
wootehfoot has quit [Read error: Connection reset by peer]
<Kena> I don't understand why `return -1` would be incorrect. `-1` is valid value for a i32 type, right?
<ikskuh> return -1; is okay :)
<ikskuh> there's some special cases when stuff is nested
tane has quit [Quit: Leaving]
Kingsquee has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
skuzzymiglet has joined #zig
AceNovo has quit [Quit: Konversation terminated!]
AceNovo has joined #zig
<nyaayaya> ;w;
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
notpiika has quit [Ping timeout: 260 seconds]
ryuukk__ has joined #zig
ryuukk_ has quit [Ping timeout: 260 seconds]
demizer has joined #zig
notpiika has joined #zig
<jabb> heyo, does the fact that this not work a side effect from some compiler checks missing? https://gist.github.com/gruebite/58e2f683d7028adc32b987d43f429f47#file-register-zig-L44
<jabb> i'm getting errors regarding function reference crossing function call boundary when uncommenting those lines
notpiika_ has joined #zig
notpiika has quit [Ping timeout: 260 seconds]
<jabb> looking below you can see it i'm calling it in the struct declaration. i'd like to know if this is expected behavior so i can continue to use this pattern
<jabb> and what the different between the two is
dimenus has quit [Quit: WeeChat 2.9]
mattnite has quit [Remote host closed the connection]
<jabb> the exact error: zig:615:13: error: 'deinitialize' not accessible from inner function>>deinitialize(ptr, parts);>>.zig:613:60: note: crossed function definition here>>pub fn f(context: *c_void, parts: *Particles) void
<jabb> f being the wrapped function
<jabb> wrapping*
squeek502 has joined #zig
<CmdrCrisp> @ikskuh, Thanks for the answer earlier about the strings. That clears it up
<ikskuh> you're welcome :)
<CmdrCrisp> @ikskuh, if I can pick your brain, do you know the reason behind continuing to use null-term strings as opposed to pascal-style?
<ikskuh> the answer is c compatibility
<CmdrCrisp> Referring me to some kind of post is more than enough, but C-Strings are such a source of headache in C.
<ikskuh> slices are "pascal style strings"
<ikskuh> c-style is sentinel strings
<ikskuh> [:0]const u8 is … both at the same time
<ikskuh> []const u8 is pascal style (pointer + length)
<ikskuh> [*:0] const u8 is c style
<jabb> i fixed it by adding `comptime` to the function params in the wrapper function. my only question now, is it legal to @field a function declaration and passing that around?
<ikskuh> jabb: @field(a, "b") is equivalent to a.b
<ikskuh> everything allowed to a.b is doable with @field
<jabb> this is crazy awesome then
<ikskuh> @field(Type, "decl") is the same as Type.decl
<ikskuh> yes, it is
<ikskuh> it allows a lot of crazy stuff
<jabb> i'm taking a type and tacking on a "Context" to a NAME declaration so I can get a substruct to automatically cast to
<jabb> i'm registering types by name that can be instantiated with their own type in like 3 lines of code
<jabb> did you see my above link, ikshuh?
<ikskuh> nah, i'll take a look
<ikskuh> oh, your gruebite from discord?
<jabb> yep!
<jabb> who are you?
<ikskuh> MasterQ32/ikskuh/xq/mq32
<ikskuh> chose one :D
<jabb> oooo
<ikskuh> ikskuh is vocalization of xq
<ikskuh> :D
<jabb> nice. i think we're both waiting for godot
<jabb> (c abi)
<ikskuh> heh, true :D
<ikskuh> your code is still optimizable!
<jabb> i removed the wrapped stuff
<jabb> so that is pre comptime adding
<jabb> it looks nice now, lemme edit
<ikskuh> inline for(std.meta.fields(System)) |fld| { if(@hasDecl(SYST, fld.name) { @field(system, fld.name) = @field(SYST, fld.name); } } }
<ikskuh> this should do the same
<ikskuh> copy everything from SYST to System what is declared as a field in System :D
<jabb> updated
<jabb> that is absolutely insane
<ikskuh> it's the power of comptime
<jabb> it's like compiling dynamic code statically
<ikskuh> yep
<jabb> i can piece together types and have them be fast static types
<jabb> hoooooly mackerel
<ikskuh> wait until you discover @Type()
<jabb> ...
* jabb discovers
<ikskuh> because writing structure definitions is lame
<ikskuh> let the code write your structures for you :D
<jabb> oh my god
<jabb> this is way better than any macro system i've seen
x2C25 has joined #zig
<jabb> in terms of ergonomics and simplicity
skuzzymiglet has quit [Ping timeout: 256 seconds]
<jabb> can i modify a typeInfo at comptime? how do build these without borrowing from an existing type to @typeInfo
<ikskuh> see std.meta.ArgsTuple for example
<ikskuh> or std.meta.Tuple
<jabb> :O
<jabb> can i ever program in another static language again without feeling crippled?
<ikskuh> no
<jabb> damn, thought so