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/
<nrdmn> Is it possible to have enum or union members with names that entirely consist out of digits?
<alexnask> @"1234" is a valid identifier :)
<alexnask> Ασ ςελλ ασ @"😂"
<alexnask> Woops.. As well as @"😂" *
<nrdmn> huh.. a minute ago zig didn't like that, now it does
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
<andrewrk> alexnask, we can probably get away with all vtable functions required to be comptime-known, right?
<andrewrk> if someone needed to call a runtime-known fn pointer in an interface implementation function, they could do it in their implementation rather than with the vtable pointer itself being runtime known
<alexnask> I think so. My current implementation also makes that assumption atm (it generates a type erased function that casts to the correct type and calls implementation function with always_inline)
<alexnask> Although the requirement for comptime-known functions could also be relaxed for generic functions only
<andrewrk> hmm interesting
<LakeByTheWoods> test-stage2 is failing for me complaining "zig/zig_cpp/libzig_cpp.a: file not found", is anyone else having this issue/should I open one?
<LakeByTheWoods> (or is there something that I goofed up?)
Barabas has quit [Ping timeout: 240 seconds]
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #zig
<andrewrk> LakeByTheWoods, that file is produced by `make`
<LakeByTheWoods> Hmm, looks like it's in zig/build/zig_cpp but it's looking for it in zig/zig_cpp
alexnask has quit [Ping timeout: 265 seconds]
adamkowalski has joined #zig
<adamkowalski> do we have something akin to numeric limits?
<adamkowalski> I want to find the maximum value for a particular type such as f64
<adamkowalski> and the smallest possible value for f64
<adamkowalski> nevermind, we have std.math.maxint and then std.math.f16max, std.math.f32max, etc
<fengb> Smallest float would be negative infinity right? 🙃
<adamkowalski> you laught, but I actually need that as well
<adamkowalski> it doesnt' seem like have std.math.f16_Min
<adamkowalski> fengb: I could also use your help with this: git push --set-upstream origin reduce
<adamkowalski> whoops
<adamkowalski> for that forward function I have a very clear pattern, what tools does zig give me to remove that repetition?
<adamkowalski> the only thing changing from line to line is the type
<fengb> I’ve mostly manually done it the way you did
<fengb> You could try using inline for / if chain but that might be harder to get right
<adamkowalski> dang, yeah I might have to try with inline for, because I have that pattern all over the place
<adamkowalski> I normally would have used macros in something like lisp, but I feel like we have a strong enough meta programming system in Zig it should be possible
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
_whitelogger has joined #zig
<daurnimator> adamkowalski: grab the tag out of `x` and use that
ur5us has quit [Ping timeout: 240 seconds]
knebulae has quit [Ping timeout: 258 seconds]
knebulae has joined #zig
dddddd has quit [Remote host closed the connection]
waleee-cl has quit [Quit: Connection closed for inactivity]
ur5us has joined #zig
ur5us has quit [Ping timeout: 256 seconds]
adamkowalski has quit [Quit: Lost terminal]
_Vi has joined #zig
slowtype1 has quit [Ping timeout: 268 seconds]
alexnask has joined #zig
return0e_ has joined #zig
_Vi has quit [Ping timeout: 272 seconds]
slowtype1 has joined #zig
LakeByTheWoods has quit [Remote host closed the connection]
basedtho has quit [Ping timeout: 268 seconds]
marijnfs has joined #zig
_Vi has joined #zig
slurpie has quit [Ping timeout: 265 seconds]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dddddd has joined #zig
frmdstryr has joined #zig
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 265 seconds]
waleee-cl has joined #zig
dingenskirchen has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
zfoo_ has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
decentpenguin has joined #zig
sammich has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
sammich has joined #zig
AndroidKitKat has quit [Quit: バイバイ〜!]
alichay has quit [Ping timeout: 256 seconds]
terinjokes has quit [Ping timeout: 258 seconds]
terinjokes has joined #zig
dddddd has quit [Remote host closed the connection]
waleee-cl has quit [Quit: Connection closed for inactivity]
<mq32> alexnask, i feel surveilled!
<alexnask> :P
<alexnask> Just checking my github notifications ;)
<mq32> hehe ^^
<mq32> but yeah i think "error{}!noreturn" is pretty expressive and the logic straightforward (imho)
<alexnask> Yes I agree, the intent seems clear to me as well
<fengb> I read that as “error not noreturn”
<mq32> fengb, how do you read "error{}!void" then? ;)
<alexnask> hah was gonna ask this
<alexnask> This should just generate a llvm function that returns the error set and add an unreachable at the bottom of the function imo
<andrewrk> ^ correct
Akuli has joined #zig
_Vi has quit [Ping timeout: 256 seconds]
_Vi has joined #zig
discip has joined #zig
marijnfs has joined #zig
TheLemonMan has joined #zig
<discip> If one wanted to create a linter for Zig, would the std/zig files (ast.zig, parse.zig, etc.) be a good starting point?
<mq32> yeah, i think so. these are used with stage1 as well (if i'm right)
<alexnask> yes zig fmt uses those
<fengb> Pedantic: You mean stage 2. Stage 1 is in C++
<alexnask> Pedantic: stage 0 is in C++, stage 1 is a mix of C++ and zig
<mq32> alexnask: i thought so
<alexnask> zig fmt is implemented in zig as well as stage 1 stacktraces
<mq32> stage0 is full c++, but afaik we compile stuff with stage1
<alexnask> (I think those are the two uses, could be wrong)
<mq32> stage2 would be 100% zig
<discip> Zig fmt is a pretty similiar use-case to a linter so that's promising. Thanks everyone
<alexnask> cheers
discip has quit [Remote host closed the connection]
return0e_ has quit [Remote host closed the connection]
return0e_ has joined #zig
waleee-cl has joined #zig
<mq32> oh neat
<mq32> i'm reading stuff about the ARM calling convention
<mq32> > If the type of value returned is too large to fit in r0 to r3, or whose size cannot be determined statically at compile time, then the caller must allocate space for that value at run time, and pass a pointer to that space in r0.
<mq32> this means that Zigs default behaviour is quite suited for arm with result location and similar
slurpie has joined #zig
zfoo_ has quit [Ping timeout: 240 seconds]
marijnfs has quit [Ping timeout: 256 seconds]
marijnfs has joined #zig
<mq32> ooof
<mq32> how do i call with a new stack?
<mq32> with the new syntax?
<TheLemonMan> what are you doing that needs you to switch the stack?
<mq32> huh
<mq32> TheLemonMan: I want to implement a two-task system on a cortex-m3
<mq32> (in C/C++)
<mq32> but i want to see how stack switching works in thumb
<TheLemonMan> write the task switching code using a piece of asm
<mq32> that's the plan
<mq32> first draw is cooperative, so "save all registers, change sp, return" should be sufficient
<TheLemonMan> using @call will absolutely bite you
<mq32> i just want to see how to change SP :D
<fengb> What's wrong with @call?
<TheLemonMan> `mov sp, rX` ?
return0e_ has quit [Remote host closed the connection]
<TheLemonMan> fengb, #3268
metaleap has joined #zig
<fengb> Does this affect async functions too?
<TheLemonMan> hmm, the "new" async function implementations should just box all the locals in a context structure that's passed around
<fengb> I think andrewrk mentioned using async as a workaround for manually switching the stack
<mq32> TheLemonMan: do you know how to reference another element from inline assembler? looks like symbol names in GCC aren't shared between ASM and compiler?
<TheLemonMan> hm? the inline asm is in the same compilation unit as the other Zig code
<TheLemonMan> where are the other symbols defined?
<mq32> i'm in GCC/C++ right now, not zig (sadly)
<TheLemonMan> you should be able to reference the symbols in the C code and the linker will resolve them
<mq32> yeah i thought so as well :D
<TheLemonMan> hm it compiles just fine here
<mq32> weird, maybe it's the link time optimization stuff?
<TheLemonMan> does the compiler give an error or something?
<mq32> just "undefined reference" in the linker step
<TheLemonMan> is gpu_resumeStackPointer defined in the same file as the asm block?
<mq32> the code snippet is 1:1 from my source
<TheLemonMan> that's extra weird, what compile options are you passing to gcc?
<mq32> -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m3 -O3 -flto -ffreestanding -fomit-frame-pointer -fpack=struct=4 -mfloat-abi=soft -ffast-math -g -gdwarf-2
<mq32> ha, compiles now
<mq32> put the assembler stuff into its own file, now it works
<mq32> TheLemonMan: if i'm reading the docs right, "push {r0-r7,lr}" means that lr is not at the "top" of the stack, but at the position at the start of the pushing?
<TheLemonMan> yeah if I enable the LTO I cannot get it to compile too, for some weird reason it's also spitting a slew of unrelated errors if I do so :\
<mq32> crazy
<mq32> i should file a bug tomorrow
<TheLemonMan> the lr goes last
<TheLemonMan> so at SP-8*4
<mq32> oh wait
<mq32> > Registers are stored on the stack in numerical order, with the lowest numbered register at the lowest address.
<mq32> lr is r14, so it would have the highest address?
<TheLemonMan> oh yeah, it goes "backwards"
* mq32 is feeling professional for actually consulting the CPU docs instead of just asking random dudes in IRC *grin*
<TheLemonMan> I've spent too much time working on non-ARM CPUs, some details are blurry :(
<mq32> yeah, i can imagine
<mq32> and yeah, i'm actually reading the docs! :D
<TheLemonMan> at some point in time I could really tell you every 6502 opcode from its hex value heh
<mq32> heh, neat!
<mq32> i'm not the dude for 6502, and i wasn't alive back then :D
metaleap has quit [Quit: Leaving]
_Vi has quit [Ping timeout: 256 seconds]
daex_ has joined #zig
daex has quit [Ping timeout: 256 seconds]
dddddd has joined #zig
marijnfs has quit [Quit: leaving]
wootehfoot has joined #zig
marijnfs has joined #zig
mahmudov has joined #zig
dddddd has quit [Ping timeout: 256 seconds]
_Vi has joined #zig
mahmudov has quit [Ping timeout: 265 seconds]
mahmudov has joined #zig
dddddd has joined #zig
<mikdusan> hmm do we have anything like an `@asMaybe(T, expr) ?T`
<shakesoda> mikdusan: don't things coerce into optionals anyway?
<shakesoda> I can certainly assign normal things to them
<mikdusan> I want to check if a coerce can happen
<andrewrk> mikdusan, I think that would be a code smell
wootehfoot has quit [Ping timeout: 260 seconds]
<mikdusan> we need a unicode for that
decentpenguin has quit [Quit: decentpenguin]
<fengb> 💩
<mikdusan> well ok. I was thinking like a pinched nose
<fengb> 🤏👃
<fengb> Looks like I'm making fun of the size of the nose
<jaredmm> Oh, that's a nose.
ur5us has joined #zig
<pixelherodev> Hmm, how would one do optional arguments via a tuple arg?
<pixelherodev> @hasDecl(@TypeOf(args), "title") is giving false even when called with `(.{.title = ""})`
<mikdusan> bug?
<mikdusan> `@compileLog(.{ .num = 1 })` output is `| undefined`
<fengb> That's a field, not a decl
<mikdusan> fengb: with the goal :)
<pixelherodev> Oh right!
<pixelherodev> fengb, thanks!
<marijnfs> I solved the serializer issue I was having like this: https://godbolt.org/z/J6RrHg Is that the way to do it?
<mq32> marijnfs, why are you using a slice of streams?
<mq32> marijnfs: i would code it like this: https://godbolt.org/z/k9y4pV
<mq32> except that i would additionally pass the buffer allocator from the outside to line 14 init()
<pixelherodev> Working on a simple GUI wrapper over Sokol + Nuklear for Zig while I take a short break from ZigIRRat to avoid burnout
<marijnfs> mq32: interesting
<marijnfs> the std.BufferOutStream and Serializer don't need a deinit?
<mq32> pixelherodev: don't overdo yourself
<marijnfs> I wanted to keep it local to avoid that overhead, and then the issues started
<mq32> it didn't compile with deinit() "function not found"
<mq32> "it compiles" is not a good indicator of "my code is right", especially in zig
<mq32> your code did never call "my_serializer.deinit()" → you never deinitialized your buffers, ... and also never freed the memory
metaleap has joined #zig
<alexnask> you can use std.testing.testing_allocator for testing, it will detect leaks
<mq32> oh yeah
<mq32> this is such a great feature
<marijnfs> mq32: ah your right, so it didn't even try to compile that function
<mq32> yep
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
dingenskirchen has quit [Client Quit]
dingenskirchen has joined #zig
<nrdmn> if I have an `extern enum(u8) { .A = 1, .B = 2 }` and write 3 to it, would that be UB?
wilsonk has quit [Ping timeout: 258 seconds]
<andrewrk> nrdmn, it would make the value undefined, unless the enum is non-exhaustive: https://ziglang.org/documentation/master/#Non-exhaustive-enum
<andrewrk> undefined values cause undefined behavior under well-defined cincumstances
<andrewrk> *circumstances
<nrdmn> andrewrk: is this necessary for extern enums?
Akuli has quit [Quit: Leaving]
<andrewrk> all enums including extern enums are exhaustive by default
<pixelherodev> mq32, I know, that's why I'm doing this :)
<pixelherodev> If I have a few projects and I swap between them, *and they have real purposes*, I can get work done
<pixelherodev> If I focus on too many projects or too few, I burn out on all of them
<pixelherodev> ZigIRRat is meant to (hopefully) become a part of stage2 eventually (or at least, part of *a* Zig compiler, even if not upstream)
<pixelherodev> The GUI library is for a game I'm making
<pixelherodev> I was going to just use Sokol directly but I hate *hate* low-level graphics
<pixelherodev> I can *do* it, but not *well*
<pixelherodev> So if I make a simplistic high-level wrapper and avoid touching it, and that wrapper happens to be useful, might as well publish it
<pixelherodev> Also planning on finally following up on the Zig post I wrote months back
wilsonk has joined #zig
marijnfs has quit [Ping timeout: 260 seconds]
marijnfs has joined #zig
<marijnfs> Hmm Why am i getting: Code Generation [925/1600] std.array_list.AlignedArrayList(std.build.LinkObject,Build Dependencies...Unrecognized glibc version: 2.31.0 unrecognized C ABI
<andrewrk> glibc 2.31 support was added in 3ff2381042104d0626545fbc655cb6d8a04ccd0b (march 4th)
<andrewrk> the issue for using the newest-supported glibc version when the detected version is unavailable is https://github.com/ziglang/zig/issues/4487
<marijnfs> andrewrk: ah thanks, can I somehow change the target or something? Or just wait for a fix
metaleap has quit [Quit: Leaving]
<andrewrk> the fix has been in master branch for 5 days - you should be able to git pull or download a master build
<TheLemonMan> andrewrk, I think I'm hitting bug in the caching mechanism
<andrewrk> you have piqued my interest
<marijnfs> andrewrk: ah your right, my cmake-prefix was screwed up
<TheLemonMan> if you compile the same file twice, the first time with `zig build-exe -mcpu cortex_a8+thumb_mode -target thumb-freestanding --cache off file.zig` and after that as `zig build-exe -mcpu cortex_a8 -target thumb-freestanding --cache off file.zig` you can see that compiler_rt and c are not recompiled due to the different flags
<TheLemonMan> this way you end up with a mix of arm and thumb code in the second binary
<andrewrk> yikes
<TheLemonMan> I don't really know why thumb-freestanding keeps producing ARM code :\
<TheLemonMan> if I force the thumb code generation with +thumb_mode it works correctly
<andrewrk> TheLemonMan, do we need to enable +thumb_mode by default for the thumb architecture?
<andrewrk> in this case, why do we even have a thumb architecture, seems like it should just be a cpu feature
<TheLemonMan> no idea, I remember that specifiying thumb-freestanding was enough to get thumb code
<mikdusan> don't know if related... seem to recall way back someone mentioning that compiler_rt args when passing mcpu stuff not consistent but never tracked it
wilsonk has quit [Ping timeout: 260 seconds]
wilsonk has joined #zig
AndroidKitKat has joined #zig
<marijnfs> Where does @import search, can I add zig 'include' directories to the zig builder?
<andrewrk> marijnfs, you want addPackagePath
<marijnfs> andrewrk: I indeed want that
<andrewrk> whatever name you choose will be available with @import("name")
<TheLemonMan> andrewrk, this LLVM PR https://reviews.llvm.org/D33448?id=100371 seems to suggest that +thumb_mode should be added by default if the target triple says so
<marijnfs> andrewrk: that's pretty sweet
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<andrewrk> TheLemonMan, per-function basis! it looks like cpu features / architecture might be something we need to support overriding at a per-scope level
AndroidKitKat has quit [Remote host closed the connection]
<mikdusan> andrewrk: if I enable --verbose-llvm-cpu-features, build an exe with `-mcpu native` .... then build again with `-mcpu native-avx` should I expect to see the "+avx" change to "-avx" ?
<andrewrk> mikdusan, yes
AndroidKitKat has joined #zig
<andrewrk> mikdusan, it might be e.g. avx2 that is dragging avx back in because avx2 implies that you also have avx
<mikdusan> ah ok there's some inter-relation
<andrewrk> what about with native-avx-avx2
<mikdusan> still no joy. tried { -avx-avx2, -avx2-avx }
<andrewrk> the next thing to double check is in stage2.zig that cache_hash is getting populated correctly
<andrewrk> (you are using zig and not zig0 right?)
<mikdusan> correct
<mikdusan> yeah I'm not getting compiler_rt rebuilding on any `-mcpu native` or absence of, or `mcpu native-avx2` changes
<mikdusan> I'll look further. sounds like this is what LemonDoood is hitting
<andrewrk> oh another thing to check as well, that `zig builtin` is affected by those flags
<andrewrk> zig builtin -mcpu=native-avx
AndroidKitKat has quit [Quit: バイバイ〜!]
<andrewrk> I can reproduce this actually. my `zig builtin` is not removing avx or avx2 with -mcpu=native-avx-avx2
<mikdusan> yeah no joy. it's not even parsing for correctness the toggles. I put in a bogus one, no error
<andrewrk> ok so not a cache error then
<andrewrk> looks like a problem in CrossTarget.parse
<andrewrk> huh weird, that's a recent regression. it used to print the list of cpu features with descriptions if you typod
AndroidKitKat has joined #zig
<mikdusan> here's a hint: if I use the `-target` option on then -mcpu features are checked
<andrewrk> I see the logic flaw in stage2.zig:682
<andrewrk> but it's still not removing avx/avx2
wootehfoot has joined #zig
return0e_ has joined #zig
<BaroqueLarouche> ohhh interface language feature is in the work :)
return0e_ has quit [Ping timeout: 256 seconds]
slurpie has quit [Ping timeout: 255 seconds]
<frmdstryr> Can someone explain this one to me https://godbolt.org/z/H8x8Sz
<alexnask> I would personally prefer using the same initialization syntax as other containers instead of something like @implement
<alexnask> Like `OutStream { file }` (and have the compiler typecheck and pass the appropriate functions as well)
<fengb> frmdstryr: the compiler can’t infer nested switches
<frmdstryr> fengb: ah, ok, will do it another way then, thanks
<alexnask> You just need to @as the integer literal in this case
<fengb> I think the longterm fix is to cascade the result location type into nested conditionals
<andrewrk> fengb, it can, but there are some complicated cases that have bugs
Snetry has quit [Ping timeout: 255 seconds]
Snetry has joined #zig
alexnask_ has joined #zig
marijnfs has quit [Remote host closed the connection]
alexnask has quit [Ping timeout: 265 seconds]
slurpie has joined #zig
<andrewrk> alexnask_, that branch is just a rough sketch. I'll be sure to put it up for review when I feel like I have a workable plan
<alexnask_> Sure, I understand :) Just saying
alexnask_ is now known as alexnask
<andrewrk> that syntax needs 3 components: (1) comptime interface value (2) runtime context value (3) comptime vtable
<andrewrk> not sure if this is going to work, this is exploring allowing interfaces to have inferred error sets
<nrdmn> oh well, looks like I get to change a lot of lines in std/os/uefi because of the non-exhaustive enum syntax
<nrdmn> it didn't exist when I wrote most of the code
<andrewrk> when you wrote the code, all enums were exhaustive