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/
ur5us has joined #zig
aerona has joined #zig
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<leeward> Is std.ascii the only place with string functions? I went looking for strstr and didn't find it.
dddddd has quit [Remote host closed the connection]
<tdeo> std.mem.indexOf
<leeward> ahah, thanks
<leeward> mmm, a bit different, but I guess I can make it work
<leeward> Oh, wait, I found the wrong function. Much better.
nephele_ has joined #zig
nephele has quit [Ping timeout: 260 seconds]
nephele_ is now known as nephele
dnmllr has joined #zig
marijnfs_ has joined #zig
a_chou has joined #zig
a_chou has quit [Client Quit]
a_chou has joined #zig
a_chou has quit [Remote host closed the connection]
marijnfs has quit [Ping timeout: 258 seconds]
return0e has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
return0e[m] has joined #zig
return0e has quit []
xackus_ has joined #zig
xackus has quit [Ping timeout: 246 seconds]
fraktor has joined #zig
<fraktor> Does the current set of interfaces (say, std.mem.Allocator) use dynamic dispatch after compilation, or is the compiler able to optimize that out?
<fraktor> Assuming that you use std.heap.c_allocator, for instance, and are not determining the allocator at runtime.
<fengb> It's runtime dispatch
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<fraktor> Okay. I know there are a couple of proposals for interfaces that are floating around; would those allow static dispatch?
<tdeo> there is already static dispatch with generics/var
moo has joined #zig
alexjmohr has joined #zig
<fraktor> That's correct, but I'm not sure if most of the standard library uses allocators that way.
aerona has quit [Quit: Leaving]
haliucinas has quit [Quit: leaving]
<fraktor> What's the best way to convert a usize (or really an arbitrary type known at compile time) into a slice of bytes?
alexjmohr has quit [Ping timeout: 260 seconds]
<tdeo> mem.bytesAsSlice
haliucinas has joined #zig
<fraktor> So that takes a slice of bytes and turns it into a slice of a different type; how can I take a value (say f64) and decompose that into a slice of bytes?
<daurnimator> mem.sliceAsBytes
<daurnimator> or really; mem.asBytes
<fraktor> mem.asBytes seems to do what I want. One more question: how can I convert a []u8 to a *[8]u8? I know for a fact the slice is of length 8.
<fengb> slice[0..8]
<fraktor> What if I'm doing something like `slice[offset + 1 .. offset + 1 + @sizeOf(usize)]`?
<daurnimator> only if the length is comptime known
<daurnimator> so better to do: `slice[offset+1..][0..8]`
metaleap has joined #zig
<fraktor> That works well.
<fraktor> What's the best way to turn a comptime int into a comptime string? (or []u8 I guess).
ur5us has quit [Ping timeout: 260 seconds]
dnmllr has joined #zig
st4ll1 has joined #zig
cole-h has quit [Quit: Goodbye]
ifreund1 has joined #zig
meta_leap has joined #zig
metaleap has quit [Ping timeout: 256 seconds]
ifreund1 has quit [Quit: WeeChat 2.8]
ifreund has joined #zig
dermetfan has joined #zig
meta_leap has quit [Quit: Leaving]
andrewrk has joined #zig
<andrewrk> damn I missed Spex_guy's comments
<fraktor> How can I read a line from the terminal? I'm finding references to std.io.readLine, but not finding it in the standard library.
<daurnimator> andrewrk: yeah I also have a reply for them :P
<daurnimator> 1. we can make it lazy so that only if you ask for the size does it actually lock-in the size. and 2. its a maximum, not a minimum.
<andrewrk> fraktor, https://ziglang.org/download/0.6.0/release-notes.html#Standard-Library search for "readline" in this section
<andrewrk> daurnimator, your (1) is astute because that is already how it works :D
<andrewrk> (2) is a good point as well
<andrewrk> it feels weird to write thousands of lines of code without being in a position to run or test them
<andrewrk> (unrelated. just musing about #5307)
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<andrewrk> I'm getting close. but been working on this for several days. feels weird to end each day with many lines changed but nothing to show
<daurnimator> I'm in a similar situation with my chat protocol... I've been unable to write any tests due to its probabalistic nature
<fraktor> andrewrk: I'm a little confused on how to read until a newline; does the File abstraction have a method for that?
<daurnimator> feels like I'm not going anywhere :(
<fraktor> s/abstraction/struct/g
<andrewrk> fraktor, your goal is to read a line from a terminal, yes?
<daurnimator> fraktor: .instream().readUntilDelimiter*
<andrewrk> so here's the deal. a proper solution would be some kind of terminal line reading UI thing like gnu readline (think of python or perl's repl for example). as far as I'm aware no such zig package exists. until it does, this can get you most of the way there: `fs.File.read` and then treat the return value as signifying the end of line
<fraktor> daurnimator: That is exactly what I need.
<fraktor> andrewrk: So the end of the line is EOF?
<andrewrk> no, but the end of read() is the terminal input
<daurnimator> andrewrk: re 1 above: do we have a list of which properties are "lazy" vs not? I didn't know the @sizeOf a frame was a lazy attribute; infact I didn't think we had lazy attributes at all. My mind is going back to https://github.com/ziglang/zig/issues/3806#issuecomment-559904772
<daurnimator> fraktor: pressing e.g. ctrl+d in a terminal sends EOF.
<daurnimator> or if you're doing `./myprogram <somefile` then EOF is the actual end of somefile
<andrewrk> you have to press ctrl+D 2x if you did not previously press return
<andrewrk> daurnimator, the way the language is currently defined, the size of types is not determined until an operation forces the size to be computed
<andrewrk> if you did, for example, `var x: usize = @sizeOf(@Frame(foo));` this would not actually force the frame size of function foo to be computed
<daurnimator> andrewrk: so what about my linked example: > e.g. if I have a pure-storage generic, like ArrayList, then the range of the members doesn't really matter for the implementation of that generic: the only property it cares about at runtime is the size of the type, the rest is only useful at comptime.
<andrewrk> not sure I follow
<daurnimator> --> from a code-gen perspective, `AlignedArrayList(u15, 1)` and `AlignedArrayList(u16, 1)` are the same right?
<andrewrk> ah ok I see where you are going with this
<andrewrk> yes
<daurnimator> andrewrk: and `AlignedArrayList(struct {a: u8, b:u8}, 1)` is too right?
<daurnimator> andrewrk: to what extent does that de-duplication of codegen exist today?
<daurnimator> cause really, `AlignedArrayList` *only* cares about the size of the first argument: not the alignment; not any other property.... right?
<andrewrk> yes. in the upcoming self-hosted compiler we find out that these are the same on a per-function basis, after codegen, and de-duplicate symbols in the executable file, even for debug builds. in stage1, there is deduplication in the llvm optimization passes, but not in debug builds
<andrewrk> during the semantic analysis phase, zig has to analyze each instantiation separately, because the branching comptime logic *could* inspect the type and do something different depending on it
<daurnimator> branching at comptime would be using a property: at which point it becomes non-lazy, and hence needs an extra bit of codegen
fraktor has quit [Ping timeout: 256 seconds]
daex has quit [Ping timeout: 272 seconds]
daex has joined #zig
ur5us has joined #zig
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
ifreund has quit [Ping timeout: 260 seconds]
dingenskirchen1 is now known as dingenskirchen
ifreund has joined #zig
slurpie has quit [Ping timeout: 264 seconds]
dddddd has joined #zig
metaleap has joined #zig
rzezeski has quit [Quit: Connection closed for inactivity]
ur5us has quit [Ping timeout: 260 seconds]
wilsonk has quit [Ping timeout: 272 seconds]
nycex- is now known as nycex
wilsonk has joined #zig
st4ll1 has quit [Ping timeout: 240 seconds]
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
st4ll1 has joined #zig
st4ll1 has quit [Quit: WeeChat 2.8]
Ekho has quit [Quit: An alternate universe was just created where I didn't leave. But here, I left you. I'm sorry.]
Ekho has joined #zig
<Cadey> well, i think i found a program that `zig cc` can't compile
<Cadey> but it might be due to the weirdo build system at play in it
<Cadey> i don't think `zig cc` can build the super mario 64 PC port
<ikskuh> why?
* mikdusan guesses `zig cc` has a space
<ikskuh> hehe
<mikdusan> cmake can't handle it either; the old `export CC="zig cc"` seems to work in a lot of cases; but optionally, CMAKE_C_COMPILER is used to do this as well, the former works with `zig cc`, the latter does not due to whitespace
<daurnimator> Cadey: make a script `zigcc` that contains: `exec zig cc "$*"`
<daurnimator> possibly also with your -target argument
<Cadey> cpp -P -DVERSION_US -DNON_MATCHING -DAVOID_UB -I . -o build/us_pc/level_rules.mk levels/level_rules.mk
<Cadey> Unable to rename object: file system error
<Cadey> make: *** [Makefile:671: build/us_pc/src/engine/graph_node.o] Error 1
<Cadey> ls: cannot access 'build/us_pc/src/engine/graph_node.o': No such file or directory
<Cadey> however clang handles it just fine
<mikdusan> ah a build system using preprocessor as their generic macro processor :)
<ikskuh> isn't that "zig cc -E"?
metabulation has joined #zig
moo has quit [Ping timeout: 260 seconds]
<Cadey> mikdusan: this entire project is a glorious trash fire
<Cadey> i'm amazed it works at all
<mikdusan> the sm64 project, if its anything like 64 PC port, hardcodes gcc toolchain assumptions everywhere; that's going to be a nightmare to deal with
<Cadey> somehow it builds fine with clang
<Cadey> (and runs slightly faster as a result)
<mikdusan> is the 64-PC port the one that's had takedowns?
<mikdusan> unrelated, was playing red eclipse (a free FPS that works on mac) with nephews, and was going to tweak some gameplay settings. nope'd right out of there as soon as I saw how macro happy the codebase was. I can't cope with that :(
<Cadey> specifically binaries have been taken down
<Cadey> the source code seems to be in a legal gray area
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
metabulation has quit [Quit: Leaving]
wootehfoot has joined #zig
waleee-cl has joined #zig
ikskuh has quit [Ping timeout: 258 seconds]
mq32 has joined #zig
mq32 is now known as ikskuh
rappet has quit [Ping timeout: 265 seconds]
rappet has joined #zig
<fengb> andrewrk: you should try out async/await in Javascript. It looks nice (but still has colors)
cole-h has joined #zig
<BaroqueLarouche> resume_me_plzkthx > foo/bar
foobles has joined #zig
<ifreund> "welcome to teh chat server" < I refuse to believe this was a typo
<ikskuh> ifreund: it definitly isn't
<ikskuh> andrewrk is just a memelord :D
dingenskirchen has quit [Remote host closed the connection]
Spex_guy has joined #zig
dingenskirchen has joined #zig
<fengb> bruh
decentpenguin has joined #zig
dddddd has quit [Read error: Connection reset by peer]
rzezeski has joined #zig
slurpie has joined #zig
jfo has joined #zig
<mikdusan> looks like we're going to need to examine a handfull (or more) macos libSystem symbols; _realpath vs _realpath$DARWIN_EXTSN, and fdopen, fopen, getgroups, popen all have similar extensions
alexjmohr has joined #zig
dnmllr has joined #zig
wootehfoot has quit [Ping timeout: 246 seconds]
leeward has quit [Remote host closed the connection]
_whitelogger has joined #zig
pystub has joined #zig
alexjmohr has quit [Quit: Leaving]
alexnask has joined #zig
dnmllr has quit [Ping timeout: 240 seconds]
metaleap has quit [Remote host closed the connection]
metaleap has joined #zig
xackus_ has quit [Quit: Leaving]
metaleap has quit [Remote host closed the connection]
metaleap has joined #zig
wootehfoot has joined #zig
FireFox317 has joined #zig
wootehfoot has quit [Ping timeout: 240 seconds]
dddddd has joined #zig
Spex_guy has quit [Remote host closed the connection]
Spex_guy has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
fraktor has joined #zig
<fraktor> If I have a switch statement that is generating a value to go in a variable, how can I do that while still having one of the branches be a block of code?
<andrewrk> => block_name: { foo; bar; break :block_name value; },
<andrewrk> let's see if I can get this incremental compilation branch into a test-passing state
<andrewrk> then it would be a good time for a live coding stream
<ifreund> hype
slice has joined #zig
<ikskuh> hype++
<BaroqueLarouche> hype += 1
<simontime> hype = hype + 1
<alexnask> hype' := hype + 1
<ifreund> mut hype .= hype + 1
<waleee-cl> ifreund: was that one mentioned?
<waleee-cl> specifically with .=
<ikskuh> ifreund: please!
<ikskuh> (&hype).* += 1
<alexnask> ^ thats the best
<ikskuh> yep
<ifreund> waleee-cl: pretty sure .= came up in 5076 yea
jfo has quit [Quit: WeeChat 2.6]
<BaroqueLarouche> https://tenor.com/Hbdk.gif
<ikskuh> i love Hype Toad
<ikskuh> also, Toad: Treasure Tracker is love
<fraktor> How do string comparisons work? Is there a standard library set of functions for that?
<fraktor> It seems that switching on strings doesn't work (which makes sense, since I imagine it's comparing memory addresses).
<alexnask> std.mem.eql(u8, slice1, slice2)
<ifreund> fraktor: "strings" are treated just like any other memory, so check out std.mem for utilities
<fraktor> That's what I figured. Thanks
decentpenguin has quit [Quit: decentpenguin]
ur5us has joined #zig
dnmllr has joined #zig
pystub has quit [Ping timeout: 256 seconds]
slice has quit [Quit: zzz]
slice has joined #zig
slice has quit [Client Quit]
linuxgemini has quit [Changing host]
linuxgemini has joined #zig
<fraktor> Is there a way to return one of multiple types of error sets?
<foobles> you can make a union of error sets with ||
<foobles> so you can make it return `(FooErr || BarErr)!i32`
<foobles> or someting
<fraktor> That's perfect! Thanks.
slowtyper has quit [Ping timeout: 256 seconds]
FireFox317 has quit [Ping timeout: 258 seconds]
slowtyper has joined #zig
Spex_guy has quit [Remote host closed the connection]
foobles has quit [Remote host closed the connection]
foobles has joined #zig
metaleap has quit [Remote host closed the connection]
metaleap has joined #zig
metaleap has quit [Remote host closed the connection]
metaleap has joined #zig
foobles has quit [Remote host closed the connection]
foobles has joined #zig
ur5us has quit [Remote host closed the connection]
ur5us has joined #zig
dingenskirchen has quit [Remote host closed the connection]
metaleap has quit [Quit: Leaving]
ifreund has quit [Ping timeout: 260 seconds]
<pmwhite> So, comptime can't call inline functions? Which means float parsing t comptime is out?
<pmwhite> Oh, I guess it works if I explicitly label the parameters as comptime.
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<pmwhite> But that's not ideal, because I want to be able to use this function at comptime and runtime.
dnmllr has joined #zig
dermetfan has quit [Ping timeout: 246 seconds]
_whitelogger has joined #zig
wilsonk has quit [Remote host closed the connection]
wilsonk has joined #zig