ChanServ changed the topic of #zig to: zig programming language | | be excellent to each other | channel logs:
ur5us_ has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
brzg has joined #zig
earnestly has quit [Ping timeout: 240 seconds]
HEX0 has joined #zig
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
cole-h has quit [Client Quit]
cole-h has joined #zig
cole-h has quit [Quit: Goodbye]
v0idify has joined #zig
mokafolio has quit [Ping timeout: 240 seconds]
fireglow has quit [Ping timeout: 240 seconds]
v0idifyy has quit [Ping timeout: 268 seconds]
osa1_ has joined #zig
osa1 has quit [Ping timeout: 260 seconds]
mokafolio has joined #zig
craigo has joined #zig
<v0idify> what's the common way to replace interfaces in zig?
<v0idify> usecase: have an arraylist that can contain many types but i only need to expect certain functions in those types
<v0idify> the only way i can think of is having a switch statement for every time i want to use some of the functions
<g-w1> you can do an struct that has a fn field for a fn pointer like Allocator does.
<v0idify> g-w1, doesn't that waste memory though? it's almost nothing but it sucks
<v0idify> because fn pointers consume memory
<g-w1> I assumed the optimiser would optimise it out, but I agree it is not optimal
<v0idify> i should be able to do something like iterating a union(enum) and calling the function inside it but i'm not sure if that would work?
<g-w1> i mean union(enum) wastes space if the fields are all not the same size
<v0idify> struct { type: enum, thing: *union } this wouldn't waste space but i'm not sure how I need to implement it?
<g-w1> i still think it will waste space if all the union fields are not the same size
<v0idify> oh right
<v0idify> well it needs to somehow be a pointer to any of the types
<g-w1> so *void?
<v0idify> yes but that's not typesafe :P
<v0idify> and i would probably need to do the matching myself
<g-w1> yeah
<v0idify> well i'll stop bikeshedding this problem because this is probably too much of a microoptimization for my code that i haven't even written yet lol
brzg has quit [Quit: leaving]
chivay has quit [Ping timeout: 272 seconds]
<mipri> union(enum) over different pointer types, so they all take up the same space (a pointer) and it's still typechecked and convenient. I'd just worry that the indirection is more expensive than the saved memory
<v0idify> mipri, i thought about that approach but i would still need to iterate through each type. what is indirection though?
<mipri> pointer indirection. if you thought about it already, I must be missing something. I've only read a little bit of the backlog.
<v0idify> i have no clue what performance issues that might have, i'll look it up, thanks
chivay has joined #zig
dingenskirchen has quit [Ping timeout: 246 seconds]
johnLate has quit [Ping timeout: 246 seconds]
johnLate has joined #zig
dingenskirchen has joined #zig
oafs is now known as oats
ralucas has joined #zig
earl has quit [Ping timeout: 240 seconds]
earl has joined #zig
ur5us_ has quit [Ping timeout: 240 seconds]
<marler8997> fyi, I'm in the market for BASH/SHELL scripts I can port to my new stitch langauge for testing and guiding the feature design. Let me know if you have anything you think would be useful
ralucas has quit [Remote host closed the connection]
sebonirc has quit [Ping timeout: 264 seconds]
<andrewrk> marler8997, I don't have a working implementation, but I want one that notifies me when a long running command finishes
<braket> marler8997: shameless plug if ya want: It lets you swap out file contents without having to mark up the original file. I use it mainly to change app colors but you can swap out any section of a file.
<marler8997> braket this looks like a perfect example I can port
<braket> woo!
<braket> it's a little long though lol. if you have any questions feel free to ask
<marler8997> 600 lines is nothing
<braket> of bash? I start trembling around 100
<marler8997> lol, fair point
<marler8997> but you're put it into nice modular functions
<braket> i tried to put lots of comments too cause i always forget how to write bash after like a week lol
<marler8997> bash has so many features and so much syntax, it's like the opposite of Zig in alot of ways
<braket> im just waiting for colorless functions in bash
<braket> tired of echo and async-echo
knebulae has quit [Read error: Connection reset by peer]
waleee-cl has quit [Quit: Connection closed for inactivity]
sord937 has joined #zig
cole-h has joined #zig
<marler8997> will work on it here: only have the environment variables so far but this will be a great help in implementing my prototype
LanceThePants has quit [Ping timeout: 245 seconds]
tnorth_ has joined #zig
sawzall has joined #zig
TheLemonMan has joined #zig
<TheLemonMan> andrewrk, you may be interested in
<TheLemonMan> (iirc you wanted something to warn you when a long-running command has finished)
<TheLemonMan> that's perfect for compiling stage1 heh
<andrewrk> neat!
hidayat has joined #zig
gonz__ has joined #zig
Wolf481pl has joined #zig
mgxm_ has joined #zig
betawaffle_ has joined #zig
euantorano_ has joined #zig
shurane_ has joined #zig
yrashk_ has joined #zig
Xena has joined #zig
lanodan_ has joined #zig
Sahnvour_ has joined #zig
jmiven_ has joined #zig
ashby has joined #zig
urluck_ has joined #zig
mgxm has quit [*.net *.split]
shurane has quit [*.net *.split]
betawaffle has quit [*.net *.split]
jmiven has quit [*.net *.split]
Cadey has quit [*.net *.split]
Wolf480pl has quit [*.net *.split]
yrashk has quit [*.net *.split]
gonz_ has quit [*.net *.split]
tdeo has quit [*.net *.split]
companion_cube has quit [*.net *.split]
euantorano has quit [*.net *.split]
lanodan has quit [*.net *.split]
JoshAshby has quit [*.net *.split]
bodie_ has quit [*.net *.split]
urluck has quit [*.net *.split]
Sahnvour has quit [*.net *.split]
mgxm_ is now known as mgxm
gonz__ is now known as gonz_
urluck_ is now known as urluck
shurane_ is now known as shurane
yrashk_ is now known as yrashk
euantorano_ is now known as euantorano
companion_cube has joined #zig
tdeo has joined #zig
notzmv has quit [Ping timeout: 264 seconds]
earnestly has joined #zig
pafmaf[m] has quit [Quit: Idle for 30+ days]
vazub[m] has quit [Quit: Idle for 30+ days]
hidayat has quit [Quit: Connection closed]
notzmv has joined #zig
jmiven_ is now known as jmiven
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
Piraty has quit [Ping timeout: 256 seconds]
Piraty has joined #zig
fireglow has joined #zig
cole-h has quit [Ping timeout: 256 seconds]
betawaffle_ is now known as betawaffle
knebulae has joined #zig
xackus_ has joined #zig
HEX0 has quit [Quit: WeeChat 3.0.1]
tnorth_ has quit [Ping timeout: 240 seconds]
TheLemonMan has quit [Remote host closed the connection]
notzmv has quit [Ping timeout: 256 seconds]
Xena is now known as Cadey
notzmv has joined #zig
teratorn has quit [Ping timeout: 240 seconds]
teratorn has joined #zig
osa1_ is now known as osa1
sebonirc has joined #zig
notzmv has quit [Read error: Connection reset by peer]
Guest44840 has joined #zig
Guest44840 has quit [Remote host closed the connection]
notzmv- has joined #zig
notzmv- is now known as notzmv
TheLemonMan has joined #zig
nycex has joined #zig
nycex- has quit [Ping timeout: 268 seconds]
leon-p has quit [Quit: leaving]
hnOsmium0001 has joined #zig
zags has joined #zig
ashby is now known as JoshAshby
<zags>, any suggestions on improving that with respect to the duplicate return expressions? I'm sure I'm missing something basic.
<zags> I was kinda looking for the equivalent of :)
<dutchie> why bother checking isDigit? just call parseInt and return the string variant if it fails
<dutchie> parseFloat*
<zags> because Zig's parseFloat accepts "+" as a number
<zags> which is a symbol in what this is part of
<dutchie> ah
<zags> most languages I use fail if "+" is input by itself
<TheLemonMan> PR welcome
<zags> for succeed or parseFloat? :)
<dutchie> i remember parseInt had that wart, but it got fixed in master
<dutchie> not sure if parseFloat similarly got fixed
<zags> I see
<zags> i'm on master and + == 0.0
<TheLemonMan> fix parseFloat, write a test, get the fuzzy warm feeling of having contributed to OSS
<zags> sure, still my original question stands
<braket> i gotchu
<TheLemonMan> no questions, only answers
<braket> does this work?
<zags> huh, does if (std.fmt.parseFloat(f64, input)) |num| { work when parseFloat returns an error?
<ifreund> no
<g-w1> you need an else |e| block
<ifreund> no that doesn't work either
<zags> ok, that's the part I was missing, thanks guys
<braket> oh right it doesn't
<g-w1> ifreund: why?
<ifreund> (you'd need to ditch the optional capture)
<g-w1> ah
<ifreund> oh nevermind, there is no optional that should work
<zags> yes it works
<zags> when I combine errors and optionals, these things fall apart
<zags> braket: thanks for the code, do you think "if (succeed parseFloat(f64, input)) |num| {}" would be worthwhile sugar? Probably not, but that was kinda what I was looking for instead of try
<zags> that could unpack optionals as well I think?
<zags> nah, icky
<ifreund> yeah where do you handle the error?
<TheLemonMan> fix parseFloat and you'd have no duplicated code anymore
<zags> this is for when you're only interested in the success case, like with parseFloat I only care if it succeeds, else do something else
<zags> TheLemonMan: parseFloat is a red herring, I'm asking more generally
<g-w1> else |_| {}
<g-w1> is there something in the File api that allows me to chmod it?
<ifreund> I think adding a language feature to make ignoring errors easier would be a very hard sell
<zags> Yeah I think you're right haha
<TheLemonMan> the answer is no, the if expression has only one type so it's either !T or ?T
<v0idify> how do i `if (no error) { do thing }` ?
<v0idify> so the inverse of catch
<v0idify> oh.
<v0idify> nevermind
<TheLemonMan> v0idify, with an empty if body and an else?
<v0idify> langref.html#if
<zags> v0idify: that's what succeed was haha
<ifreund> g-w1: I don't see any chmod/fchmod bindings in the std yet
<v0idify> i didn't know that if handled error values
<ifreund> (you should totally add them)
<g-w1> ok
<zags> ifreund: though, would "if (succeed expr) |val|" really make it much easier to ignore errors than adding "else |_| {}" ? At least the code is clear about you ignoring errors :)
<zags> With else, you have to read on to realize the error is being ignored
<zags> With "if (std.fmt.parseFloat(f64, val)) |num| {" I can't tell if I'm ignoring error or dealing with an optional
<v0idify> how do i get values inside an anonymous union(enum)?
<ifreund> v0idify: i don't understand what you mean by "get values"
<ifreund> zags: Where does the control flow go if the expr evaluates to an error?
<g-w1> hmm, i wonder how stage2 chmods stuff
<zags> ifreund: you could have an else |err| ?
<g-w1> yes
<v0idify> ifreund, i don't know how to explain it but i don't need it rn so it's fine
<zags> ifreund: yeah I see your point, nvm
<TheLemonMan> by creating the files with the right mode, I guess
<g-w1> ah, I am creating a file, so Ill try that
<ifreund> g-w1: std.fs.File.Mode
<braket> zags, you were using `std.ascii.isDigit` to see if an input string had like a + in them right?
<g-w1> works thanks
<braket> cause i think it accepts + too
<TheLemonMan> that's not true?
<braket> oh wait wait zags was checking the first character
<zags> braket: parseFloat succeeds on "+" as input
<braket> nvm nvm lol
<zags> parseInt does the right thing
<zags> I'll make an issue
<zags> unless I can fix the code
<TheLemonMan> g-w1, wrt enabling zig fmt --check in the CI, have you thought of adding that as a pre-commit hook?
<g-w1> that would be only local right?
<g-w1> my reasoning is that if some unformatted code gets in the repo, then it makes the diffs dirty
<TheLemonMan> yep, you can either apply zig fmt on the changed file or have it abort the commit if --check fails
<TheLemonMan> I'm with you on that, I hate unformatted code
<g-w1> i mean its not bad if the diffs are dirty, just clutter since my editor auto-formats code
<TheLemonMan> it _is_ bad when you review a PR
<g-w1> yeah
<TheLemonMan> IIRC github can be coaxed into ignoring the whitespace changes, but I never remember how to do that
<zags> click the tool icon
<zags> the "Hide whitespace changes"
<zags> can be done on cmd line as well
<ifreund> andrewrk: well shit, looks like glibc 2.33 might be causing issues even though zig now properly falls back to 2.32
<ifreund> I got a bug report about linking failing from someone trying to build river on arch:
<zags> TheLemonMan: here's a beauty: git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero -
<TheLemonMan> I usually CBA to download the diffs locally
<TheLemonMan> but I'll stash that in my gitconfig, thanks
<zags> CBA?
<TheLemonMan> cannot be arsed
<zags> haha
lanodan_ is now known as lanodan
<ifreund> yeah, I don't really either unless I need to build them, in which case I git fetch upstream pull/9999/head:9999
<zags> i take it I'm supposed to run zig fmt before making a stdlib PR?
<ifreund> yup
<zags> thx
craigo has quit [Ping timeout: 264 seconds]
<zags> i've built master, made a change in the std lib. How do I rebuild now? make zig doesn't do anything
<zags> pardon the noobiness, haven't made changes to the compiler/std yet
<zags> just zig build?
<ifreund> yup, --help to see all the options
<ifreund> zig build alone will just build self-hosted, you probably want to run tests though
<zags> yeah i do
<ifreund> I usually just run zig test /path/to/file/i/changed.zig to test simple things quickly
<zags> good tip
<zags> hm, so after zig build, the build/zig isn't updated, but I get a new one in zig-cache. Trying to run tests on that results in
<zags> error(module): TODO: analyze test decl
<zags> error: no entry point found
waleee-cl has joined #zig
<ifreund> the one in zig-cache is the (incomplete) stage2 compiler, you should keep using the one in build/zig
<zags> hm, that one doesn't get updated when I rebuild
<zags> after changing the stdlib
<ifreund> if you change something the stage 1 compiler depends on on the std and run make it should rebuild
<ifreund> otherwise it doesn't need to
<zags> i change something in fmt, no rebuild occurs
<zags> i changed something in fmt, no rebuild occurs
<zags> ifreund: actually, I get "error(module): TODO: analyze test decl" even when using "build/zig" on a stdlib file, hmm
<g-w1> do `mkdir build; cd build; cmake .. {flags}; make; ./zig test ../lib/std/fmt.zig`
<zags> wait, wtf, I edited the wrong file haha. The file is in both lib/zig/std and lib/std
<zags> what gives
<ifreund> why do you havea lib/zig folder?
<zags> no idea
<zags> i just cloned and make'd
<g-w1> its where its installed
<g-w1> did you makedir build first?
<zags> yeah
<g-w1> hm
<ifreund> did you do make install . or something?
<zags> maybe i managed to screw something up anyway, i'll restart if this isn't supposed to happen
<ifreund> that seems likely
<zags> ifreund: nope
<zags> mkdir build, cd build, cmake, make according to shell history
<g-w1> you shouldn't even need the latest compiler. just do `zig test file` since you didn't change the compiler
<g-w1> s/latest/to build
<zags> zig test on my own file works, but zig test ../som/std/lib/file fails with the above errors
<g-w1> output of `which zig`?
<g-w1> it fails with TODO analyze test decl???
<g-w1> just download the latest zig off the website and use it.
<TheLemonMan> you are somehow using the stage2 compiler?
<zags> g-w1: D'OH i was using a slightly older master, ./zig test works
<zags> which zig indeed points to another checkout haha
<zags> amateur hour
<g-w1> ok, well good that it works now :D
<zags> anything else I need to consider beyond fmt before making a PR? branch naming standard or anything like that?
<TheLemonMan> write a test!
<TheLemonMan> or more than one
<zags> yeah, i've expanded the existing parseFloat test
<TheLemonMan> then you're good to go
<zags> thanks :)
Akuli has joined #zig
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
cole-h has joined #zig
zags_ has joined #zig
zags has quit [Ping timeout: 256 seconds]
zags_ has quit [Quit: leaving]
riba has joined #zig
zags has joined #zig
riba has quit [Ping timeout: 265 seconds]
zags has quit [Ping timeout: 245 seconds]
<andrewrk> ifreund, damn! I'll take a look
<ifreund> appreciate it :)
<andrewrk> my plan is to use a distro with the newer glibc, check out zig 0.7.1 sources, and then see what patch on top of that would fix it, then apply that to master branch
<TheLemonMan> andrewrk, did you (or mikdusan) managed to find the problem with mips/riscv and LLVM12?
<andrewrk> not yet
<andrewrk> one of the problems is a missing math function which is no problem
<andrewrk> but I also observed a linker error. let me pull it up again...
<TheLemonMan> yeah, that's pretty tame
ed_t has quit [Quit: Leaving]
<andrewrk> ld.lld: error: test.o:(.rodata.str1.1): offset is outside the section
<andrewrk> on behavior tests, mips-linux-none, debug
<TheLemonMan> great, I'll give that a spin
<g-w1> is there any documentation on the c abi struct layout? it seems like there is no padding when everything is aligned by 2 bytes. (I am trying to understand elf and it seems std.elf uses extern)
<g-w1> or is that all I need to know?
<TheLemonMan> the padding depends on the type sizes and offsets
<g-w1> ok
<g-w1> i think ill try implementing bswapAllFields for the elf backend
<ifreund> andrewrk: opened #8144 to track the glibc thing
<andrewrk> thank you!
<TheLemonMan> speaking of elf.zig, #7763 is still in the PR queue
<g-w1> i like that
<andrewrk> merged
<TheLemonMan> easy peasy lemon squeezy
<g-w1> do you think I should put byteswap in std.math? or somewhere else?
<andrewrk> byteswap is a memory operation, not math
<g-w1> ah, std.mem?
<ifreund> g-w1: you can find links to read the ABI specs here:
<g-w1> oh wait @byteSwap exists
<TheLemonMan> g-w1, we already have littleToNative (and friends)
* g-w1 facepalms
<g-w1> ifreund: thanks
ur5us_ has joined #zig
craigo has joined #zig
marijnfs has joined #zig
Piraty has quit [Quit: ---]
Piraty has joined #zig
zags has joined #zig
nycex- has joined #zig
nycex has quit [Ping timeout: 268 seconds]
ky0ko has joined #zig
cCCCCcccccCCc has joined #zig
Akuli has quit [Quit: Leaving]
<zags> is there a stringbuffer type of thing in zig std, or do I just use ArrayList(u8) ?
<ikskuh> use ArrayList(u8)
<ikskuh> it even has .reader() and .writer()
<zags> aye, will do
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
sord937 has quit [Quit: sord937]
olabaz has joined #zig
olabaz has left #zig ["WeeChat 2.3"]
<v0idify> will zig have typescript/hare style unions? like: (Type | u32) and return 42; or return Type{...} instead of union(enum)
<v0idify> they could also essentially replace Error unions to some degree
<ikskuh> v0idify: i don't think so
<ikskuh> (u32|u32)
<ikskuh> what about this
<v0idify> oh yeah those use-cases wouldn
<v0idify> wouldn't work
<fengb> In Typescript, that's semantically identical to u32
<v0idify> (Type|struct{kind:enum{Thing,OtherThing},value:u32)
<v0idify> and closing bracket which i forgot
<v0idify> i can see how it's worse in some use cases but better for most imo
<v0idify> or, keep current unions and add "anonymous unions"
<v0idify> how are non-enum unions useful? i can't think of a use case
<ikskuh> non-enum unions?
zupss has quit []
<v0idify> normal, non-tagged unions
<fengb> If you know the tag ahead of time, there's no need for the program to keep track
<fengb> In release-fast, this is faster (but UB if you access the wrong one)
<v0idify> fair enough
<fengb> You can emulate it with extern union or packed union, except those don't have helpful safety checks in debug mode
<v0idify> still, i believe anonymous tagged unions could be useful
<fengb> (Also they're pretty strict about memory layout, whereas a plain union doesn't care)
ky0ko has quit [Remote host closed the connection]
Kenaryn has joined #zig
<Kenaryn> Hello computalional people. Please where is the link to internationalization topic to add a new translation?
<Kenaryn> regarding to the zig web site I mean.
ky0ko has joined #zig
<ikskuh> you can make a PR here
riba has joined #zig
amk has quit [Read error: Connection reset by peer]
amk has joined #zig
riba has quit [Ping timeout: 264 seconds]
ur5us_ has quit [Ping timeout: 240 seconds]
<Kenaryn> Thanks buddy.
xackus_ has quit [Ping timeout: 276 seconds]
earnestly has quit [Ping timeout: 245 seconds]