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/
<mikdusan> the horror of posix reserved names; ending `_t`, beginning `str` `mem` `wcs` `is` `to` and `E`:
<pixelherodev> Had to refactor a lot of code after realizing that *everything* ending in _t is reserved :(
<fengb> It's amazing what could be solved with proper namespacing >_>
<mikdusan> daurnimator: ah thanks 86 pages of productivity!
<pixelherodev> Ugh, good to know
<pmwhite> Thanks for the help guys. This is basically what I ended up doing: `while (!std.mem.allEqual(u8, std.mem.asBytes(&list[i]), 0)) {}`
<daurnimator> pmwhite: what was the std.mem.zeroes error you got before?
<pmwhite> our of bounds pointer access at @sizeOf(T), where T is the parameter passed to std.mem.zeroes.
<pmwhite> I was trying to use it as the sentinal. The function works when it goes at runtime, but when it stands as a sentinel, it has to be comptime.
<daurnimator> pmwhite: I'm confused... please share a sample?
<pmwhite> `var x = std.mem.zeroes(T);` works fine.
<pmwhite> `var xs: [*:std.mem.zeroes(T)]const T = c_function();` gives the error.
<pmwhite> looks like it has something to do with the generated c struct because I'm having trouble making a small repro.
<daurnimator> pmwhite: does `[*:comptime std.mem.zeroes(T)]` help?
<mikdusan> am I missing something? probably. but `var xs: [*:null]?*T =`
<daurnimator> mikdusan: its not a *T but a T
alexnask has quit [Ping timeout: 256 seconds]
<pmwhite> daurnimator: doesn't help. how can I see the translate-c output to see what the generate c struct is?
<daurnimator> pmwhite: option 1. use `zig translate-c` . options 2. dig around in zig-cache/ for cimport.zig
<daurnimator> mikdusan: they're probably using a pattern where a C array is written like: `static const struct foo bar[] = { {"blah", 42}, {"more", 123}, {0} };` and then they need to read through in from zig.
<mikdusan> daurnimator: your suggestion works: `var xs: [*:comptime std.mem.zeroes(Foo)]Foo = undefined;`
<mikdusan> `@compileLog(@TypeOf(xs)` --> | [*:(struct Foo constant)]Foo
<daurnimator> mikdusan: the `comptime` shouldn't be required (theorectically) right?
<mikdusan> it needs a comptime; because it's a value, not a type
<pmwhite> That breaks.
<pmwhite> comptime breaks as well.
<pmwhite> I thought comptime was only used to force a function to be evaluated when it otherwise could be just compiled. Like, it removes the need for the compiler to make a judgement call. Here, it is completely necessary for the call to be made at comptime.
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alexnask has joined #zig
<mikdusan> pmwhite: hmm... removing extern from `extern struct`
jcharbon has quit [Quit: Connection closed for inactivity]
<pmwhite> Yeah, that works, but you can't make translate-c do that.
<pmwhite> Also, I kinda expected for loops to work with sentinal terminated pointers. I guess that would fall under the hidden-function call rule though.
<pmwhite> Is there an iterator at least?
alexnask has quit [Ping timeout: 256 seconds]
<mikdusan> I tried a few variations, bottom line: `_ = comptime std.mem.zeroes(T);` fails when T is `extern struct` with some kind of "out of bounds pointer access" error
_Vi has quit [Ping timeout: 255 seconds]
<pmwhite> Essentially the same error.
<pmwhite> The error happens because of the `@memset` call.
<andrewrk> pixelherodev, mikdusan and to all lurkers: in case it isn't clear, those reserved names do not apply to zig
<andrewrk> pmwhite, if daurnimator's code example is accurate, you shouldn't need to check all the fields, just one of them that is otherwise not supposed to be null
<andrewrk> mikdusan, there are a bunch of cases where an expression is implicitly comptime. one example is in the array length expression. another example is in the sentinel expression. so an explicit `comptime` is not necessary (or if it is then it's a bug)
<pmwhite> Oh, that's true.
<daurnimator> andrewrk: it does apply to gen-h though :)
<andrewrk> good point
return0e has joined #zig
<daurnimator> pmwhite: when you send long messages they come through as matrix links.... can you try to avoid that?
<daurnimator> or I guess it's as good as a pastebin....
<andrewrk> I was going to say, it seems perfect to me
<pmwhite> Wait, really. I had no idea it was doing that. If you'd like me to quit it, I can, but it sounds like it's actually just fine.
<daurnimator> andrewrk: what do you mean "just one of them that is otherwise not supposed to be null"
<andrewrk> daurnimator, in your example, the first field which is presumably a `const char *`
<andrewrk> I doubt the C code is checking all the fields to detect if it's a sentinel
<daurnimator> andrewrk: I just made that example up; I just picked a random type :P
return0e has quit [Ping timeout: 256 seconds]
<pmwhite> I've been confused for a while what the sprintf equivalent for zig is. std.fmt.format seems like it might be it, but I'm completely confused how to use it.
<BaroqueLarouche> Philip White: You're looking for std.fmt.bufPrint
<pmwhite> suprised I missed that. I think allocPrint might actually be what I want.
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 260 seconds]
<fengb> Did bitshifting bound checks change?
halbeno has quit [Excess Flood]
Nilium has joined #zig
<fengb> Ah yes, apparently I was failing to correctly check my bounds
halbeno has joined #zig
halbeno_ has joined #zig
halbeno has quit [Ping timeout: 272 seconds]
<andrewrk> fengb, do you have any perf benchmarks for your project? Im curios if the stream changes had any impact
waleee-cl has quit [Quit: Connection closed for inactivity]
<andrewrk> gonna have to postpone packed struct fixes/improvements until after 0.6.0. sorry folks
_whitelogger has joined #zig
plumm has joined #zig
_whitelogger has joined #zig
<mikdusan> i tried to trick github comments by hand-editing a line-range to ir.cpp so that it shows the code section... but nope. github doesn't like that big file 😠
<andrewrk> If I can store the meaning of a 1.4 MiB C++ code file, GitHub should be able to display it in a web browser
<andrewrk> If I can store the meaning in my head of a 1.4 MiB C++ code file, GitHub should be able to display it in a web browser
<andrewrk> j/k. anyway in zig this is less of a problem since whether functions are in the same file or not has less semantic meaning
mahmudov has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 240 seconds]
<mikdusan> ... just throwing shade at github. My only real gripes are file-size limit, and no darkmode
halbeno_ has quit [Quit: Leaving.]
halbeno has joined #zig
_whitelogger has joined #zig
<fengb> andrewrk: nope, though I could theoretically cobble something together. It would also stress test my parser
<fengb> Lemme see if it can parse my emulator (lol)
mikdusan has quit [Read error: Connection reset by peer]
<fengb> Seems about the same for sync mode. Maybe 2-3% faster
<fengb> Not able to test async cause Mac >_>
<fengb> The new api is a lot easier to get right 👍
<fengb> Trying to find the right &stream was pretty annoying heh
mikdusan has joined #zig
mikdusan has quit [Read error: Connection reset by peer]
_whitelogger has joined #zig
<andrewrk> noted
<plumm> andrewrk: what did you mean for #4427 being self hosted?
<plumm> just implemented in the self hosted version?
<andrewrk> there's a whole mechanism for self-hosting parts of the compiler
<plumm> oh. i added the zig info command but i was gathering a bunch of the info with methods that i don't think are the self hosted variants
marmotini_ has joined #zig
ur5us has joined #zig
marmotini_ has quit [Ping timeout: 268 seconds]
return0e has joined #zig
_Vi has joined #zig
jjido has joined #zig
dddddd has quit [Ping timeout: 258 seconds]
tdc has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mikdusan has joined #zig
alexnask has joined #zig
plumm has quit [Quit: Lost terminal]
ur5us has quit [Ping timeout: 240 seconds]
_Vi has quit [Ping timeout: 240 seconds]
TheLemonMan has joined #zig
<TheLemonMan> fengb, the stdlib has some functions to read varints off a stream
<TheLemonMan> they're stashed in debug.leb, the discoverability is not that great
neceve has joined #zig
neceve has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
<daurnimator> TheLemonMan: many varints are different varints :P
<daurnimator> Also I noticed that there is no stream.writeStruct
neceve_ has joined #zig
neceve_ has quit [Client Quit]
<TheLemonMan> daurnimator, hm? I haven't seen any other varint encoding in the wild
<daurnimator> TheLemonMan: what's debug.leb128? high byte = continuation byte?
<TheLemonMan> yep
<TheLemonMan> signed&unsigned, we use it in the debug info parser
neceve has joined #zig
<daurnimator> utf8-style?
<TheLemonMan> yep
<daurnimator> no I mean: utf8 is a different varint coding to pure high byte = continuation
<TheLemonMan> well the msb is still the discriminant between single-byte and multi-byte
<daurnimator> single byte and multi byte yes... but not an indication of if this is the last byte
<TheLemonMan> you can see utf8 as a leb-encoded value with a sub-encoding applied to its content
<daurnimator> yes. but debug.leb128 would fail at decoding it :P
<TheLemonMan> hmm, you probably can, if you special case the single-byte case
forgot-password has joined #zig
dddddd has joined #zig
_Vi has joined #zig
neceve has quit [Remote host closed the connection]
forgot-password has quit [Quit: leaving]
decentpenguin has joined #zig
neceve has joined #zig
<mq32> > This view will soon be deprecated in favor of the new notifications experience. Learn more about notifications.
* mq32 is sad. New GitHub notification center is horrible
<mq32> does anyone here has a positive experience?
<alexnask> I tried it for a bit and switched to the old one shortly after :p
<mq32> yeah, me too
<mq32> old/current one is much clearer
<daurnimator> old one I have a pattern I know of when to open new tabs and trick it in regards to read-notifications
<daurnimator> it has been pretty awkward in the past
<daurnimator> I think I just need to get used to the new one
<mq32> i read most notification in my mail client
<fengb> The new display is too verbose
<daurnimator> mq32: I just use the mail ones for notifications. people so often fix typos etc that I want to see them on github anyway
<mq32> <fengb> The new display is too verbose
<mq32> yeah, i think there's too much informational noise
jrl has joined #zig
neceve has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
ifreund has joined #zig
bryanhonof has joined #zig
dingenskirchen has quit [Ping timeout: 245 seconds]
ifreund has quit [Quit: WeeChat 2.7.1]
<fengb> `const FifoStream = struct { const OutStream = std.io.OutStream(*Self, Error, write);` be ever so slightly nicer to have anon functions :P
<mq32> fengb: yep!
bryanhonof has quit [Ping timeout: 265 seconds]
<fengb> Anyone know how I can rerun a Github action?
alexnask has quit [Quit: Leaving]
watzon has quit [Quit: watzon]
watzon has joined #zig
watzon has quit [Client Quit]
waleee-cl has joined #zig
dingenskirchen has joined #zig
<andrewrk> huh, TIL rust has a "support tiers" system like zig. I wonder which came first
<andrewrk> "Apple is no longer supporting 32-bit targets, and so, neither are we. They have been downgraded to Tier 3 support by the project."
<TheLemonMan> can't wait 'till Apple drops support for x86 altogether
<andrewrk> ha. what arch would they use instead?
<TheLemonMan> there was some talk about switching to ARM
<TheLemonMan> but deep down I hope for a resurgence of the beloved MIPS
<mq32> TheLemonMan: what about RiscV? But AARCH64 for desktop would be neat, too
<andrewrk> mips was the target arch of my uni compilers course
<andrewrk> we were supposed to generate C code with some arbitrary restrictions, but I thought that was lame so asked the prof if I could output mips instead
<mq32> yeah, here as well ^^
<andrewrk> no offense to nim :P
<TheLemonMan> risc-v is quite nice for embedded stuff because you can mix and match whatever ISA features you need
<shakesoda> andrewrk: apple is expected to be switching macs to arm within the next, like, year
<andrewrk> orly? that is news to me
<shakesoda> i'd be pretty surprised if we didn't see at least one arm mac in 2021, the writing has been on the wall for a while
<fengb> Still just a rumor
<andrewrk> the iphone already uses arm right?
<shakesoda> yes, iphone and ipad have always been arm
<shakesoda> their latest rounds of SoC's are no slackers, it's not even slightly a stretch of the imagination that they'll be able match or beat the performance they're getting out of intel already
<shakesoda> mostly though, they stand to gain a lot of money by not having to pay intel.
<fengb> Their chips are also much better power efficiency
<fengb> But... software
<shakesoda> I suspect all the macos software has worked on arm for a long time, but third party stuff will be a rough transition (again)
<shakesoda> I'll bet anything this is why they have dropped 32-bit though
<fengb> And no more bootcamp D:
<andrewrk> ^ good thing zig supports arm windows
<shakesoda> fengb: well... not for x64 at least
<mq32> shakesoda: I own a Oculus Quest and i'm absolutely astonished about the performance they get out of a mobile GPU
<mq32> and CPU
<fengb> Is arm windows still a thing?
<shakesoda> sure is
<mq32> yep
<shakesoda> mq32: yeah, it's quite amazing how far mobile tech has come
<mq32> yeah
<shakesoda> and the quest SoC is a couple generations old, too
<mq32> VR was like "you need a > 1000$ gaming rig to do at least mediocre VR"
<mq32> and now it's like "yeah, just use this glorified android smartphone! :D
TheLemonMan has quit [Ping timeout: 268 seconds]
* shakesoda has multiple ports to quest in the works
<mq32> oh, neat!
<mq32> you do gamedev for money?
<shakesoda> the one thing i hate about it is that android is utterly terrible to develop for
<shakesoda> mq32: yeah
<mq32> a friend of mine has the "honour" to work with the newest Snapdragon 865
a_chou has joined #zig
<mq32> he said, some colleagues use their mobile phone prototype with the snapdragon and a LARGE cpu cooler to compile their build of the linux kernel
<shakesoda> how many driver bugs are we talking :D
a_chou has quit [Remote host closed the connection]
<mq32> as it's much faster than their i7 laptops :D
<shakesoda> heh, I believe it
a_chou has joined #zig
<Snektron> my uni compiler targeted risc-v
<shakesoda> on this exact note, I want arm workstations to become conventionally available, and the laptop situation is pretty sparse
<Snektron> but personally im still rooting for mill processors
<fengb> My uni targeted Java bytecode -_-
<Snektron> no wait, risc-v was the emulator i wrote
<shakesoda> it's like... get a pinebook pro (not doable currently, because coronavirus), get some expensive snapdragon 8cx laptop, or use some sbc
<Snektron> the compiler course was mips
<shakesoda> fortunately, I happen to love working with sbc's
<Snektron> sadly they had us write a simple pascal clone
<shakesoda> andrewrk: fwiw, zig's excellent support for cross target stuff is a *big* factor that drew me in :)
<shakesoda> zig on all the things!
<mq32> <shakesoda> zig on all the things! +2!
<andrewrk> I was able to compile llvm 10 on pine book
<fengb> RIIZ
<mq32> neat!
<mq32> also, one day we need plan9 support for the compiler *grin*
a_chou has quit [Remote host closed the connection]
<companion_cube> why though? :p
<fengb> Why... not
<fengb> Support all the things
<companion_cube> ah, you mean the OS, not the idea of everything is a file?
<mq32> the OS itself, yes
<fengb> Does anyone run Plan9?
<fengb> I've always been curious
<mq32> i want to take a closer look at plan9 as a user, my latest experience with ACME was awesome
<mq32> their editor is just crazy
<mq32> i'll try to get p9 running on a RPI
TheLemonMan has joined #zig
metaleap has joined #zig
frmdstryr has quit [Ping timeout: 258 seconds]
metaleap has quit [Quit: Leaving]
decentpenguin has quit [Quit: decentpenguin]
mokkalogic has joined #zig
mokkalogic has left #zig [#zig]
marijnfs has quit [Quit: Lost terminal]
frmdstryr has joined #zig
<mikdusan> Snektron: yeah I'd love to see impl of some mill ideas like implicit-zero stack frames, hardware instr for frame alloc, which incidentally also stores return addresses somewhere off-stack
return0e has quit [Ping timeout: 265 seconds]
<TheLemonMan> an off-memory return address stack sounds interesting, does any modern/ancient ISA have that?
Akuli has joined #zig
mahmudov has joined #zig
<fengb> ... we're closer to Y2038 than Y2K. I feel so old
<TheLemonMan> do we have something a-la C static-local variables?
<fengb> `const Foo = struct { pub var static: u32 = undefined; `
<TheLemonMan> hm, that's cool
_Vi has quit [Ping timeout: 240 seconds]
<pixelherodev> Can't wait till PineBook is back in stock :(
<shakesoda> pixelherodev: really makes me wish i jumped on it the first time around
<shakesoda> i was a bit unsure about finances on the last round they were actually in stock :(
txdv has quit [Ping timeout: 268 seconds]
ur5us has joined #zig
<Snektron> i'm still waiting on decent x86 laptops
mikdusan has quit [Ping timeout: 260 seconds]
marijnfs has joined #zig
<mq32> <Snektron> i'm still waiting on decent x86 laptops
<mq32> Lenovo Thinkpad E595
<mq32> at least i'm super-happy with it
marmotini_ has joined #zig
<Snektron> Thanks for the suggestion, but i'll just wait a few months until those new ryzen's hit the shelves
mikdusan has joined #zig
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #zig
<marijnfs> what changed with the BufferedOutStream?
<andrewrk> the vtable is comptime now. the API is easier to use
marijnfs_ has joined #zig
frmdstryr has quit [Ping timeout: 268 seconds]
tdc has quit [Ping timeout: 255 seconds]
marijnfs has quit [Ping timeout: 260 seconds]
<SyrupThinker> Hi, I'm interested in appliying for GSoC and was wondering what scope the self hosted linker should have
<SyrupThinker> Because I could only possibly test Linux (amd64, arm64) and Windows (amd64)
<SyrupThinker> And also what kind of input and output format should be supported
marijnfs_ has quit [Quit: Lost terminal]
<SyrupThinker> Actually nevermind, I've read all issues but the actually relevant one -.-
_Vi has joined #zig
marmotini_ has quit [Remote host closed the connection]
<SyrupThinker> Ok, having actually understood what was actually meant by self-hosted linking (I was getting too exited I guess), I think that this might be too short of a task especially with self-host cache hash already being worked on
<andrewrk> SyrupThinker, https://github.com/ziglang/zig/issues/1535 is actually to create a linker in zig without any dependencies
<andrewrk> the test targets that you have access to would be a great start
<andrewrk> these kind of things can be done piecemeal
<andrewrk> btw just so you know we were not granted GSoC funding, so the Zig project would not be able to pay you for your time
<SyrupThinker> Ah, well I'm interested on working on something regardless :) Might aswell do this short task the if I'm not bound by bureaucracy
<TheLemonMan> lol @ "short task"
<andrewrk> every day I think I'm going to work on a "short task"
<SyrupThinker> I was referring to self host linking, not an actuall full linker ;)
<SyrupThinker> I'm fine doing less exiting helpful stuff, it was just a concern with the requirements, which don't matter if I don't apply for anything
<andrewrk> there's lots of helpful stuff to varying degrees of exciting labeled "Contributor Friendly"
<andrewrk> TheLemonMan, oh nice, I thought you were going to not want your name associated with the ntdll thing
<TheLemonMan> ntdll is still fine, I'm against peeking&poking the undocumented bits
<andrewrk> got it
<TheLemonMan> github diff view is absolutely atrocious for doing code reviews :\
<andrewrk> TheLemonMan, I'm about to audit the std lib and change OS bits time_t to be 64-bit: https://github.com/ziglang/zig/pull/4725
<andrewrk> would appreciate your code review on that when it's done
<andrewrk> it affects arm, i386, mips, powerpc
marijnfs has joined #zig
<TheLemonMan> oh that's gonna be fun
Akuli has quit [Quit: Leaving]
<andrewrk> wow look at this madness
<andrewrk> struct timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); };
<andrewrk> explanation: https://clbin.com/KMOgE
<andrewrk> somebody wants comptime
<TheLemonMan> who needs comptime when you can abuse unnamed bitfields
* mikdusan wonders if the parser allows: `int: 8*(sizeof(......))` :)
<andrewrk> ok I think I understand the situation\
<andrewrk> musl didn't break ABI, but it did change the size of time_t and structs that contain time_t fields. so as far as upgrading goes, #4725 is basically done. but we have our own task to update zig std lib to time64 for these architectures
<andrewrk> which basically amounts to carefully changing the struct ABIs and time_t to i64, and calling time64 syscalls
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<andrewrk> and we can call the time64 variants of musl once that's done. I don't know what glibc's plan is
marijnfs has quit [Ping timeout: 256 seconds]
<wilsonk> andrewrk: Sound might be a little messed up on wine, just so you know. I made up a quick SDL example with square sine audio output..this works on Linux, cross compiles fine (using clashproto dir structure) and runs well on windows, but the sound is garbled using win64. So there might be some issues when using libsoundio also? Not totally sure, but just wanted to mention it in case you try with clashproto again
ur5us has quit [Ping timeout: 260 seconds]
joey152 has joined #zig
ur5us has joined #zig