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/
mwgkgk has quit [Quit: Connection closed for inactivity]
daurnimator has quit [Ping timeout: 260 seconds]
frmdstryr has joined #zig
daurnimator has joined #zig
<frmdstryr> I using @fieldParentPtr still the "zig" way to do interfaces or is there something better now?
stripedpajamas has joined #zig
<leeward> frmdstryr: Still the way, unless you want to use a library like https://github.com/alexnask/interface.zig
<frmdstryr> Interesting, thanks
stripedpajamas has quit [Quit: sleeping...]
stripedpajamas has joined #zig
layneson has joined #zig
stripedpajamas has quit [Quit: sleeping...]
ur5us has quit [Ping timeout: 260 seconds]
dongcarl has quit [Ping timeout: 256 seconds]
<frmdstryr> leeward: how far did you get with the msp432?
layneson has quit [Ping timeout: 240 seconds]
craigo has quit [Quit: Leaving]
craigo has joined #zig
daurnimator has quit [Quit: WeeChat 2.8]
<leeward> frmdstryr: Not super far. I generated something with --emit-asm, added a line, and linked it with gnu ld, and it ran. I could probably skip the "add a line" step if I tweaked the linker script, but I couldn't get clang to generate an msp430 executable directly from C code (linker issues).
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
<leeward> I wanted to get llvm to generate something before I went fiddling with linker scripts.
<leeward> On the plus side, Zig can emit a single instruction for `volatile_ptr.* |= 1` while gcc and clang both emit 3.
aerona has joined #zig
stripedpajamas has joined #zig
nikita_ has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
epmills has joined #zig
nikita` has quit [Ping timeout: 246 seconds]
frmdstryr has quit [Ping timeout: 240 seconds]
epmills has quit [Remote host closed the connection]
fraktor has quit [Quit: WeeChat 2.8]
epmills has joined #zig
dongcarl has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
epmills has quit [Quit: Leaving...]
stripedpajamas has quit [Quit: sleeping...]
reductum has joined #zig
aerona has quit [Quit: Leaving]
_whitelogger has joined #zig
vimanuelt has joined #zig
stripedpajamas has joined #zig
B4s1l3 has joined #zig
B4s1l3 is now known as opDispatch
stripedpajamas has quit [Quit: sleeping...]
stripedpajamas has joined #zig
stripedpajamas has quit [Client Quit]
_whitelogger has joined #zig
marnix has joined #zig
cole-h has quit [Quit: Goodbye]
marnix has quit [Ping timeout: 258 seconds]
_whitelogger has joined #zig
<GreaseMonkey> 0.6.0, riscv32-freestanding-none, using QEMU's version of the SiFive-E platform for the time being: currently trying to get the machine trap vector working, and i can either give it a pointer which doesn't exist, or i can give it the address to the function which ends up being null
<GreaseMonkey> never mind i need to somehow align the function
<GreaseMonkey> yeah i needed align(4), problem solved
<leeward> \o/
marnix has joined #zig
nikita_ is now known as nikita`
nycex- has quit [Remote host closed the connection]
nycex has joined #zig
dermetfan has joined #zig
_hl_ has joined #zig
vimanuelt has quit [Quit: Leaving]
marnix has quit [Read error: Connection reset by peer]
<_hl_> A couple days ago I asked here about converting an enum to an error set. I have since (RSI is a pain...) gotten around to implementing that using some comptime hacks if anyone is interested in that sort of thing: https://gist.github.com/he-la/f23aa89611fd573cca380cdb76caf3ea
<_hl_> This is useful for working with C libs that use enums for their error codes
marnix has joined #zig
ur5us has joined #zig
_hl_ has quit [Remote host closed the connection]
waleee-cl has joined #zig
_Vi has joined #zig
scriptdevil has joined #zig
marnix has quit [Ping timeout: 256 seconds]
ur5us has quit [Ping timeout: 260 seconds]
KKRT has joined #zig
marnix has joined #zig
<scriptdevil> a question about standard docs. Is there a reason andrewrk decided to only generate docs for functions which are "reachable" from tests or code? Why not simply generate entries for every function in source files?
<ikskuh> scriptdevil: because the stddocs are based on the semantic analysis of the source
<ikskuh> this means that the docgen does not "see" the unused functions
<ikskuh> the plan is to have multiple analysis runs, merge the results of those and output that as a merged documentation
marnix has quit [Ping timeout: 256 seconds]
_Vi has quit [Ping timeout: 272 seconds]
<ikskuh> so you can see the differences in function signatures between different OSs
<scriptdevil> I saw that in the video from andrewrk. However, why does it need to be based on semantic analysis?
dddddd has quit [Ping timeout: 240 seconds]
<ikskuh> because function signatures differ between OSes
<ikskuh> so you need to evaluate some comptime code
<scriptdevil> Aah - comptime code. That is what I was missing.
<scriptdevil> https://ziglang.org/documentation/0.6.0/std/#std;io for instance doesn't list getStdErr but not getStdOut
<scriptdevil> I understand that comptime is something most other languages don't have to deal with though.
<ikskuh> yep
<ikskuh> but there's nothing keeping you from generating docs from the source only
<ikskuh> there's even the zig parser already in std :)
<scriptdevil> I haven't done much Zig before, but I take it this is a neat "first" project for zig. Will give it a shot
FireFox317 has joined #zig
<ifreund> that would be super neat to sse
<ifreund> s/sse/see/
<ikskuh> uuuh, that would be cool!
marnix has joined #zig
nikita` has quit [Quit: leaving]
nikita` has joined #zig
marnix has quit [Ping timeout: 240 seconds]
frmdstryr has joined #zig
FireFox317 has quit [Ping timeout: 240 seconds]
Barabas has joined #zig
<Barabas> Hello
<ifreund> o7
<Barabas> I see var was changed/removed
<Barabas> Is there some place where I can find important changes?
<Barabas> This is the var 'type' for generic functions
<ifreund> there's been some effort to keep a running changelog here: https://github.com/ziglang/zig/wiki/Master-Branch-Notable-Changes
<Barabas> Cool, thanks
dermetfan has quit [Ping timeout: 260 seconds]
<Barabas> Seeing how it's not easy to replace all my instances of the var type I can see this is a good change =D
<ifreund> Barabas: zig fmt should do that for you
_Vi has joined #zig
<Barabas> Oh... oh well, there wasn't too much that I had to fix
heitzmann has quit [Quit: WeeChat 2.8]
heitzmann has joined #zig
<Barabas> And all my code still works :)
KoljaKube has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
dermetfan has joined #zig
marnix has joined #zig
<Sahnvour> Barabas: zig fmt can do the replacement for you
<KoljaKube> Is there a way of doing early exits with optional types without checking the presence of the value at every step?
<KoljaKube> Basically what I would want to do is `const f: ?Foo = mayFail(); if (f == null) return Err.Fail; useNonOptionalFoo(f);`
<ifreund> const f = foo() orelse return Err.Fail;
<KoljaKube> That too has the success in the middle and the failure at the end
<KoljaKube> Kotlin's compiler makes `foo` non-optional after a `if (foo == null) return`, basically the variable changes its type in the middle of a function
<ifreund> KoljaKube: f is non optional in my example
<KoljaKube> Ohh, sorry
xackus has joined #zig
<KoljaKube> OK, I guess that's the way to do it without magical type changes ;-)
<ifreund> indeed, it's much simpler :D
<KoljaKube> That it is, though maybe not as flexible
<ifreund> how so?
<KoljaKube> Not that I have a great use case for it at hand, but you can put an arbitrary amount of statements between the assignment and the "conversion" in Kotlin
<ifreund> How would that possibly be useful? I don't see it
<ifreund> well, maybe there are some ways to use that, but imo anything that requires that kind of control flow is smelly code
<KoljaKube> As I said, I don't have a great use case for it...
<KoljaKube> It just feels natural. No new syntax to learn, just "I checked here, it can't have changed, so it's definitly a value down here"
<ifreund> I get that, but it's implicit and not really in line with the philosophy of zig imo
marnix has quit [Read error: Connection reset by peer]
<ifreund> it's new semantics not new syntax, which is imo worse
<ifreund> having the simplest semantics possible is critical for readability
<KoljaKube> Yeah, I think so too
<KoljaKube> But the downside is that the "opposite" of `x = xyz(); if (x) |xx| foo else bar` is `x = xyz() orelse bar; foo`
<KoljaKube> Which is not really symmetrical
<KoljaKube> And only works if bar is noreturn I guess
frmdstryr has quit [Ping timeout: 246 seconds]
<ifreund> or of the same type of foo
<ifreund> *as
<ifreund> const num = foo() orelse 42;
<KoljaKube> Sure
<KoljaKube> I'm assuming that bar can also be optional?
<ifreund> yeah as long as the peer type resolution works out
<KoljaKube> So `x = foo() orelse { handleSomeStuff(); null }; domeSomeMoreStuff()` would also work
<KoljaKube> s/dome/do/
<ifreund> yeah, if x is ?u32 or whatever
marnix has joined #zig
<KoljaKube> Other topic. Do those C APIs you use in river also do that callback-functions-get-passed-a-context-pointer thing I am seeing quite often in C libraries?
<KoljaKube> Something like `LibContext* ctx = lib_initContext();` and LibContext's whatEverCallback has the signature `void whatEverCallbackFunc(LibContext*, ActualData*)`
<ifreund> yeah, there's either a void pointer that I need to cast or I'm passed a struct that I can call @fieldParentPtr() on to get my struct
<KoljaKube> Hmm
<KoljaKube> Not sure I completely understand if @fieldParentPtr fits my problem
<ifreund> what API are you trying to use?
<KoljaKube> I only get a pointer to LibContext, which is allocated within the library, and I can't put my own stuff in there
<KoljaKube> I have multiple cases of this, but currently I'm trying to create Wren wrappers
<KoljaKube> https://wren.io/embedding/ - WrenVM* is my LibContext
manikawnth has joined #zig
<ifreund> looks like wren explicitly eschews global state: "Wren has no global state, so all state stored by a running interpreter lives here."
<ifreund> comment on WrenVM in the header
<KoljaKube> Yeah
<ifreund> so I think they don't want your callback to access global state
<KoljaKube> My end goal is having my own zig version of WrenVM with some added stuff, but since I only get that WrenVM*, I'm looking for a way to from Wren* -> ZigWrenVM*
<KoljaKube> My latest thought was copying the whole WrenVM struct data into a struct of my own that starts with a WrenVM member, so that I should be able to safely @ptrCast
<ifreund> yeah that would work
<KoljaKube> Which, if I haven't overlooked something, should work, but feels hacky and needs that copy
<KoljaKube> I guess for @fieldParentPtr to work I would need to control placement of the actual WrenVM struct data as well, right?
<ifreund> though you'd probably need to read some of their code to make sure that doesn't break anything
manikawnth has quit [Remote host closed the connection]
<KoljaKube> Yeah, already doing that
<KoljaKube> So far every function accesses everything through that WrenVM*
<ifreund> if you want to use @fieldParentPtr on WrenVM you need to make a struct that has the WrenVM as a member
<ifreund> then you can call @fieldParentPtr(*MyStruct, "wren_vm_member", wren_vm_ptr) to get a pointer to your struct
<KoljaKube> OK, then I read the documentation right
<KoljaKube> Maybe I could also hijack the allocation callback to place-allocate the VM data into my struct
<KoljaKube> Also slightly hacky though
<KoljaKube> This would all be unnecessary if WrenVM contained just one `void* userdata`
<KoljaKube> Oh.
<ifreund> what global state are you trying to add that you need this struct for?
<KoljaKube> https://github.com/wren-lang/wren/pull/406 - There is userdata, it's just in the config struct
<KoljaKube> I'm mostly just playing around
<KoljaKube> I wanted to wrap the callbacks in zig and not pass around C library pointers
<KoljaKube> And maybe it would be interesting for allocators or somesuch
<ifreund> nice, well looks like that PR solved the issue
<KoljaKube> https://wren.io/embedding/configuring-the-vm.html - No userdata in the documentation
<KoljaKube> This is why up-to-date documentation is important. If it's not documented, I go to the source, but if it's documented, I tend to rely on the docs...
<KoljaKube> It's also why I don't write documentation at work, it makes one indispensable ;-)
<ifreund> depends on the language for me. For C/Zig i just read the soruce
<KoljaKube> C libraries yes, but I'm having a hard time reading libc
<KoljaKube> libc++ as well
<ifreund> yeah I do read man pages for libc, which are pretty great
<ifreund> not a chance reading libc++, I use cppreferenc.com
<KoljaKube> Don't know if you're the application-over-web kind of guy, but my wife used Zeal https://zealdocs.org in Linux, which is a FOSS reimplementation of the Dash documentation browser for macOS
Barabas has quit [Ping timeout: 245 seconds]
<KoljaKube> I think it's pretty neat, especially if you switch between languages more often or have the library documentations available in it
<ifreund> does look neat, though I don't think I switch around enough to justify it
Barabas has joined #zig
<KoljaKube> One advantage is having documentation available offline
<KoljaKube> My commute goes through a Funkloch ;-)
stripedpajamas has joined #zig
cole-h has joined #zig
stripedpajamas has quit [Quit: sleeping...]
layneson has joined #zig
layneson has quit [Ping timeout: 258 seconds]
marnix has quit [Read error: Connection reset by peer]
craigo has quit [Ping timeout: 240 seconds]
marnix has joined #zig
waleee-cl has joined #zig
scriptdevil has quit [Ping timeout: 265 seconds]
Techcable has quit [Quit: ZNC - http://znc.in]
Techcable has joined #zig
Akuli has joined #zig
marnix has quit [Ping timeout: 246 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
marnix has joined #zig
marnix has quit [Ping timeout: 256 seconds]
KoljaKube has quit [Ping timeout: 256 seconds]
<leeward> Heh, reading https://github.com/ziglang/zig/wiki/Why-Zig-When-There-is-Already-CPP,-D,-and-Rust%3F I found this quote: "Zig has no macros and no metaprogramming" which is...dubious. It could be argued that most comptime constructs qualify as metaprogramming. That includes common idioms like `fn Container(comptime thing: type) type { return struct { ... }; }`
<Sahnvour> indeed, probably what is meant here is "template metaprogramming"
cole-h has quit [Quit: Goodbye]
<leeward> It doesn't have a separate language for metaprogramming, which sets it apart from several languages.
<leeward> (not D, but hey, steal the good ideas)
<leeward> Finally got around to updating 5800; turns out the day job is actually pretty good at wearing me out.
marnix has joined #zig
aarvay has joined #zig
stripedpajamas has joined #zig
dingenskirchen has quit [Quit: dingenskirchen]
aerona has joined #zig
dingenskirchen has joined #zig
marnix has quit [Ping timeout: 240 seconds]
stripedpajamas has quit [Quit: sleeping...]
dingenskirchen has quit [Read error: Connection reset by peer]
dingenskirchen has joined #zig
Akuli has quit [Ping timeout: 240 seconds]
<companion_cube> Sahnvour: that looks a lot like templates though, except with a better syntax
<oats> zig homoiconicity when? :P
<oats> hoping zig will eventually be a cleverly disguised scheme dialect
<companion_cube> without even closures, it's a long way away :D
traviss has quit [Remote host closed the connection]
traviss has joined #zig
Flaminator has joined #zig
aerona has quit [Remote host closed the connection]
xackus has quit [Ping timeout: 258 seconds]
aarvay has quit [Quit: Connection closed for inactivity]
dermetfan has quit [Ping timeout: 260 seconds]
waleee-cl has joined #zig
KKRT has quit [Quit: KKRT]
xackus has joined #zig
xackus has quit [Ping timeout: 240 seconds]
_Vi has quit [Ping timeout: 272 seconds]
Barabas has quit [Ping timeout: 245 seconds]
blinghound has joined #zig
<blinghound> I whipped up a little terrain generator using pure zig today
<blinghound> just thought it could be interesting
<blinghound> is anyone else working on a game engine or a graphics based app with zig?
tyler569 has quit [Quit: WeeChat 2.3]
<leeward> blinghound: ifreund is working on a wayland compositor, and fengb made a gameboy emulator. There's a decent amount of game/graphics stuff onhttps://github.com/nrdmn/awesome-zig
<blinghound> leeward thanks for the link, I had an appetite for more zig stuff
<leeward> No problem