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/
<squeek502> @justin_smith, you can do something like this (I run this from the build folder of my zig checkout, so the paths are relative to that)
<squeek502> zig test ../lib/std/fs/test.zig --override-lib-dir ../lib --main-pkg-path ../lib/std
layneson has quit [Ping timeout: 265 seconds]
leeward has quit [Remote host closed the connection]
<justin_smith> squeek502: cool, that works, I thought I'd tried this combo before but clearly I got something wrong
leeward has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
leeward has quit [Remote host closed the connection]
xackus_ has quit [Ping timeout: 272 seconds]
nephele_ has joined #zig
<andrewrk> if you remove the "red herring" lib dir in the build folder zig will automatically find the one from your source checkout
nephele has quit [Ping timeout: 240 seconds]
nephele_ is now known as nephele
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
jicksaw has quit [Quit: ZNC is kill]
jicksaw has joined #zig
earnestly has quit [Ping timeout: 258 seconds]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
CodeHz has joined #zig
CodeHz has quit [Remote host closed the connection]
gert_ has quit [Quit: WeeChat 2.9]
squeek502 has quit [Remote host closed the connection]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
gert_ has joined #zig
frett27 has joined #zig
gert_ has quit [Quit: WeeChat 2.9]
frett27 has quit [Ping timeout: 256 seconds]
cole-h has quit [Quit: Goodbye]
ur5us_ has quit [Ping timeout: 260 seconds]
<gonz_> andrewrk & alexnask[m]: Is the idea for Alex to work on zls as part of the core team?
<gonz_> (and things like it)
<andrewrk> gonz_, core team is not a paid position; however it does come with some decision making powers of what gets merged into master branch
<gonz_> Aha
<andrewrk> with more funds we will have more paid hours available to core team members
<gonz_> Find a way to throw money at alexnask[m], please :D
<andrewrk> working on it :)
mmohammadi9812 has joined #zig
mmohammadi9812 has quit [Ping timeout: 272 seconds]
ur5us_ has joined #zig
squeek502 has joined #zig
haliucinas has quit [Remote host closed the connection]
haliucinas has joined #zig
ur5us_ has quit [Ping timeout: 260 seconds]
earnestly has joined #zig
marnix has quit [Ping timeout: 265 seconds]
marnix has joined #zig
dermetfan has joined #zig
simp2979 has quit [Ping timeout: 245 seconds]
dermetfan has quit [Ping timeout: 260 seconds]
dermetfan has joined #zig
xd1le has joined #zig
<gonz_> The discord server is in bad need of moderation when it comes to certain people who insist on being inflammatory in as many conversations as possible all day every day.
<alexnask[m]> It can get tiring sometimes
eagle2com has joined #zig
marnix has quit [Ping timeout: 256 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<Sahnvour> it does
pangey has quit [Ping timeout: 260 seconds]
pangey has joined #zig
dermetfan has quit [Ping timeout: 260 seconds]
<fengb> That one guy again?
<ikskuh> yeo
<pixelherodev> gonz_: there's a reason I stick to IRC these days
<Sahnvour> simply following the activity was a burden so I muted the discord server since a few days
xackus_ has joined #zig
<gonz_> Eventually, if left unchecked, I think the norm will drift towards telling people their arguments have no value, etc.
<ifreund> agree that action should taken, not motivated to do anything myself though as I'm happy sticking to IRC
waleee-cl has joined #zig
<earnestly> IRC is the aslyvm
<Sahnvour> well, if it's community-driven it has to moderate itself
<pixelherodev> Or the mods need to step in
dermetfan has joined #zig
<pixelherodev> Whoa, 6250 is more and more impressive every time I look :P
<ifreund> yeah, it's awesome
<ifreund> look at all that C++ getting deleted :)
<pixelherodev> Yep!
<pixelherodev> The only downside is that I'm *not* working on CBE again until it's merged :P
<pixelherodev> Though it's good to get a break I suppose
<ifreund> yeah, I never really have a shortage of projects I want to work on
<pixelherodev> Who I wouldn't kill for time dilation... or immortality, I suppose. Huh. Voldemort would make a lot more sense if he was an engineer lol.
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
xackus_ has quit [Ping timeout: 260 seconds]
layneson has joined #zig
zippoh has quit [Remote host closed the connection]
zippoh has joined #zig
Akuli has joined #zig
xackus_ has joined #zig
gulli222 has joined #zig
gulli222 has quit [Client Quit]
dermetfan has quit [Ping timeout: 260 seconds]
eagle2com has quit [Remote host closed the connection]
layneson has quit [Ping timeout: 260 seconds]
layneson has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
<ifreund> man, being able to create an opaque type with methods would be make these libwayland bindings i've been poking at way easier and better
mmohammadi9812 has joined #zig
cole-h has joined #zig
philtor has joined #zig
<justin_smith> ifreund: opaque type with methods meaning compile code that doesn't need to know the implementing struct?
<ifreund> well, you would only be able to pass around/use pointers to the struct
<ifreund> we already have @Type(.Opaque), but there's no way do define methods for such types
<ifreund> s/do/to/
nullheroes has joined #zig
<justin_smith> ifreund: I may be missing context, but that sounds like something you could do with a reified interface (you write code that calls the interface, implementor writes an adaptor that works as a backend to said interface)
<justin_smith> that's how java would do it, but they are indirection happy :D
<justin_smith> I guess that's not far from being a dumb vtable
FireFox317 has joined #zig
<ifreund> there should be no dynamic dispatch here
<justin_smith> that's harder to do I guess - the compiler would have to fill in the target functions?
zippoh has quit [Remote host closed the connection]
zippoh has joined #zig
<fengb> Methods are compiler magic that rewrites into static function call
<fengb> foo.bar() is identical to Foo.bar(foo)
<justin_smith> so what concretely would opaque types help you do? if it's not late binding / dynamic dispatch
<alexnask[m]> It would mostly be helpful for C bindings I imagine
<alexnask[m]> When there is some API that only uses pointer-to-structs and the struct's layout itself is opaque for all intents and purposes
<justin_smith> on the level that it would change between dynamic library versions so you couldn't hard code a more direct access when dynamic linking?
<companion_cube> it's also useful to prevent people from depending on implementation details that might change?
mmohammadi9812 has quit [Ping timeout: 256 seconds]
<justin_smith> companion_cube: yeah, that's exactly the sort of thing I'm wondering, what is that "opaqueness" hiding that doesn't already violate C linkage rules, and I don't assume we can break things by avoiding indirection / late binding / dynamic dispatch but I don't know that well enough to be sure
<fengb> The wrapper methods can be static and invoke the extern functions
<fengb> It’s just nice syntax sugar
<fengb> And getting rid of C fake namespaces
<justin_smith> see, to me that's the sort of indirection I was talking about - but it's not "dynamic dispatch" I guess because it's just following a pointer and not a table lookup?
<fengb> Well it might be dynamic linking
<justin_smith> more concretely: you have a struct type with pointers to methods, a given datum would provide an implementation pointing to the functions they use
<justin_smith> that seems like a solution
<fengb> Or it could be statically linked? Either way, they’re not generally considered dynamic dispatch
<fengb> Otherwise any glibc function would be considered dynamic
<companion_cube> justin_smith: ah, I thought it was just on the language level; the compiler and linker would still see everything
<justin_smith> fengb: to me the part that's interesting is the late binding - compiling against the struct of methods (known offsets) plus data struct (opaque pointer) means you can accept alternate implementations right? late binding is useful.
<justin_smith> without arbitrary lookup, it's just following one extra pointer
<fengb> There’s no struct though. It’s hard coded to be a specific method
<fengb> Although Zig would most likely inline the method so it’d be calling the linked function directly
<justin_smith> companion_cube: yeah, I'm probably getting things scrambled here, but I'm very interested in understanding how these things work, and my background knowledge is haphazard so I quickly jump from things I know well to things I'm totally ignorant of here
<fengb> Function declarations are not stored in any table at runtime
<companion_cube> I don't know much either
<companion_cube> but some languages provide a notion of public/private that is only for the programmer
<companion_cube> the compiler can still link to struct offsets, inline, etc.
<justin_smith> fengb: right, sorry, the "struct" was my suggestion of a potentially useful idiom - allowing swapping out of implementations, cost of an extra pointer lookup per "method call" (call of struct function pointer on data item)
<fengb> Oh yeah, that’d be a vtable :P
<alexnask[m]> Yeah, either a vtable or a global offset table for the whole program
<alexnask[m]> If you just want to swap implementations at runtime
<fengb> Stage2 actually does that for incremental compilation
<justin_smith> cool, thanks for humoring me
<alexnask[m]> Yeah, its really interesting, although its not used to swap out stuff at runtime yet
<alexnask[m]> Hot code swapping is planned though
<fengb> I thought hot code swapping was working?
<alexnask[m]> So I imagine it would work in a simialr function just with the code mapped in memory
<alexnask[m]> Is it? Did I miss some big PR? :P
<fengb> I thought Andrew demoed it. Maybe it was just showing off the compilation part
<andrewrk> I have not done a proof of concept of hot code swapping yet
<andrewrk> but I have made the claim that incremental compilation of stage2 is 90% of the work
<andrewrk> I also hinted that an upcoming live coding session would be trying to do a PoC
<fengb> Oh
<andrewrk> I also explained how it would work on a stream if I remember correctly. So I can see how that would get confusing whether it was implemented or not :)
wilsonk has quit [Ping timeout: 272 seconds]
mmohammadi9812 has joined #zig
wilsonk has joined #zig
omglasers2 has joined #zig
<justin_smith> based on my code reading of std so far, it looks like there's no concept of an atomic value (that is, some memory location that the compiler will ensure is always used atomically), just atomic ops and the user needs to ensure a given value is used atomically?
frett27 has joined #zig
<justin_smith> and based on the blurb for "Atomics" in langref, uses of "@fence(...)" should be relevant
a_chou has joined #zig
frett27 has quit [Ping timeout: 246 seconds]
<andrewrk> that's correct justin_smith
<justin_smith> great, thanks
<companion_cube> https://www.youtube.com/watch?v=KeLBd2EJLOU <-- this is a pretty insane talk about atomics
<companion_cube> (in C++, but I imagine zig is exactly the same currently)
<justin_smith> companion_cube: I thought that atomics were a type in c++, but I'm definitely no c++ expert (funny enough I was watching a different Herb Sutter video this morning as background research - I'm trying to implement lock free data structures)
<companion_cube> sure, you have a collection of atomic types
<companion_cube> corresponding to what the cpu supports
<companion_cube> same in rust, btw
<justin_smith> yeah, in zig we are in a more ad-hoc place, where any pointer or integral type can be used atomically, with no compiler enforcement that this is done consistently
<justin_smith> the op is atomic, the value just exists
<justin_smith> closer to what's happening on the hardware level
<andrewrk> I think it can make sense to sometimes operate atomically on memory and sometimes not
<justin_smith> absolutely, but this is interestingly inverse to how we handle pointers - we are stricter and enforce more compile time invariants on pointers (all the operations are still available if you use the right conversions)
<justin_smith> maybe not inverse, because zig / c is the right comparison and I don't know that c enforces atomicity on a static checking level
frett27 has joined #zig
<justin_smith> OK c11 does have atomic on the type level https://en.cppreference.com/w/c/language/atomic
<justin_smith> haha, in c you can create an atomic struct, but accessing a member is undefined behavior
st4ll1 has quit [Ping timeout: 240 seconds]
st4ll1 has joined #zig
xackus_ has quit [Ping timeout: 260 seconds]
decentpenguin has quit [Quit: ZNC crashed or something]
frett27_ has joined #zig
frett27 has quit [Ping timeout: 265 seconds]
frett27_ has quit [Ping timeout: 256 seconds]
nephele has left #zig [#zig]
bbrittain has quit [Quit: ZNC 1.6.3+deb1 - http://znc.in]
decentpenguin has joined #zig
companion_cube has quit [Quit: WeeChat 2.3]
companion_cube has joined #zig
<andrewrk> I think it's important to pay very close attention to atomic operations and they should not look like normal assignments or expressions
<companion_cube> @load(x, Acq), @store(x, y, Rel) ? :)
marnix has quit [Ping timeout: 240 seconds]
<justin_smith> andrewrk: sure, but I think being able to tell the compiler "all operations on this variable need to be atomic to a memory location" would be convenient (even if the operations are not overloaded to look normal like they are in C)
<andrewrk> I think that's worth considering
<justin_smith> I think the way zig treats pointers is a good parallel here, we can ask the compiler to enforce rules that don't neccessarily represent runtime level constraints
mmohammadi9812 has quit [Quit: I quit (╯°□°)╯︵ ┻━┻]
ur5us_ has joined #zig
gpanders has quit [Ping timeout: 272 seconds]
FireFox317 has quit [Ping timeout: 240 seconds]
Akuli has quit [Quit: Leaving]
a_chou has quit [Ping timeout: 265 seconds]
a_chou has joined #zig
joey152 has joined #zig
omglasers2 has quit [Read error: Connection reset by peer]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
agentultra has joined #zig
<agentultra> If I have two values of `u8` and I want to OR them together as you would in C, like "0x2A << 8 | 0xF0" to get 0x2AF0; how do I get that in zig? I get the warning when using `<<` and the same one from the `@shl*` functions...
<justin_smith> agentultra: the first thing I'd try is assigning the first one to a u16, so the shift isn't nonsensical
<justin_smith> well, u16 or larger
<ifreund> 0x2A << 8 | 0xF0 is perfectly valid in zig, and will evaluate to a comptime_int with value 0x2AF0
<justin_smith> but the destination must be at least 16 bits wide surely
<justin_smith> oh, sorry I misread, and that makes sense
<ifreund> yes, agentultra's issue is almost certainly caused by trying to shift a u8 8 bits to the left
<ifreund> you probably want something like const res: u16 = @as(u16, foo) << 8 | bar;
layneson has quit [Ping timeout: 256 seconds]
a_chou has quit [Ping timeout: 272 seconds]
<agentultra> thanks!
rzezeski has quit [Quit: Connection closed for inactivity]
<justin_smith> if I'm using @cmpxchgWeak, and old_value is null, how do I actually detect success?
<justin_smith> it returns old_value on failure, null on success, but null is a valid old_value
<justin_smith> I think the canonical way to do this is return true / false
<justin_smith> I guess I could have a lock that I only use in the case old_value is null, but that feels silly
<justin_smith> correcting myself above, it's technically failure that I can never detect if old_value is null
layneson has joined #zig
<justin_smith> for now, since null is being used as an "empty stack" sentinel, I think I can safely use a pointer to self and have it play the same role (since no element in the stack could be the struct holding the stack, or if it was everything is broken anyway)
<justin_smith> or better I can have a sentinal "bottom of stack" pointer that all instances can share, less hacky
<justin_smith> but then I need a new one for each type...
a_chou has joined #zig
joey152 has quit [Ping timeout: 260 seconds]
layneson has quit [Ping timeout: 256 seconds]
<agentultra> the type coersion did the trick; that's what the C code would do implicitly that I was tring to understand in zig. Nice!
<andrewrk> justin_smith, you can detect failure from cmpxchgweak, not sure why you think you can't
<andrewrk> justin_smith, is it because your T is already optional?