<powerofzero>
Is there a nice way to get the maximum (or minimum for signed integers) value of an integer type? Something like maxValue(usize)?
<andrewrk>
powerofzero, std.math.maxInt(usize)
SLWW_ has joined #zig
<powerofzero>
:facepalm: I saw that being used in ripgrep and assumed it was a c interop MAX_INT. Thanks!
SLWW has quit [Ping timeout: 268 seconds]
<kiedtl>
You looked at a Rust project too see how to do something in Zig? I very be confuzzled
<powerofzero>
No, I used ripgrep to search the standard library source code.
<powerofzero>
(zig standard library)
<kiedtl>
Oh, oh, ok
mikdusan has quit [Quit: WeeChat 3.0.1]
<marler8997>
is there a proposal for successdefer that would allow errors inside the block?
mikdusan has joined #zig
powerofzero has quit [Ping timeout: 240 seconds]
jeang3nie has quit [Quit: WeeChat 3.1]
<andrewrk>
I considered an equivalent to D's scope(success) and decided against it
<andrewrk>
not sure if that's what you're referring to
<marler8997>
yeah, I just had a use case where I wanted to do "try foo()" inside a defer, but it only makes sense on successdefer
<marler8997>
since you can't do "try" inside a normal defer
<andrewrk>
I think if you find a case where you would use an entire control flow language feature rarely, it should probably not be a language feature, better to use the existing language tools to model it
<kiedtl>
Hm, can you nest functions in a test case?
<mq32>
you have to reference RGB somewhere to instantiate it
<kiedtl>
I'm not sure I follow you... I just use the struct in a regular function?
<kiedtl>
oh nvm, I see
<kiedtl>
Seems a bit silly imo. The compiler shouldn't be removing structs/methods marked with extern/export even if they aren't being used
<fengb>
The opposite. The compiler won't even look at symbols that aren't referenced
Miaourt has quit [Quit: Bye!]
<kiedtl>
oh, I see
Miaourt has joined #zig
pretty_dumm_guy has joined #zig
<andrewrk>
it can be really handy to have this - for example if you don't depend on fork() then you don't pay for the extra symbols that are exported to make the linker deal with TLS having to do with fork safety
<companion_cube>
Has anyone suggested a `lazy` keyword so that this would be opt in? It's a bit of a footgun
<companion_cube>
Code looking all good until you start using it...
<andrewrk>
I think the time has passed for casual language modification proposals
<ifreund>
+1
<andrewrk>
whole-file-astgen will be able to catch a lot of this stuff. it will be able to tell if you used `export` but it's not even possible to reference it
<andrewrk>
so much so that people will be asking for sloppy mode, and the answer will be no
<companion_cube>
So we're closer to a language spec? :)
[wtf] has quit [Quit: [wtf]]
powerofzero has joined #zig
<powerofzero>
Is there a way to get stdout to be displayed as it happens from a test?
<andrewrk>
somebody was asking about this the other day; can't remember who it was
notzmv has quit [Ping timeout: 252 seconds]
ssiyad has quit [Remote host closed the connection]
<mikdusan>
kiedtl: fyi #8629 has been opened and related to your question: "Is it possible to make zig continue with the test suite even if one test block fails"
<andrewrk>
thanks mikdusan!
<recalloc>
i've been learning zig since the 24th, and I have to say: on the surface, it ticks just about every box that I had issue with C. The only issues I have so far are already being addressed in their own github issues
<andrewrk>
:) we'll get there
SLWW_ has quit [Ping timeout: 268 seconds]
<andrewrk>
the next thing we need is a fast, memory efficient compiler.
<g-w1>
the progress is nice!
<g-w1>
marler8997: why would you want an option to quit on the first failure?
<marler8997>
to eliminate cascading failures
<marler8997>
sometimes, the first error can cause a cascade of other failures that are just red herrings
<g-w1>
makes sense
<g-w1>
not sure i like it though, as you don't control the order of the tests (i think)
<marler8997>
not sure you like an option to quit on first failure? or the proposal?
<g-w1>
it quite make sense as you dont control the order
<g-w1>
like if you get a red herring then it exits, you are now super confused
<marler8997>
you wouldn't get a red herring because you would have exited before you got to it
<g-w1>
the red herring as the first test
<marler8997>
by "red herring", I was meaning, something that failed because of something else
<marler8997>
there are other kinds of red herrings
<marler8997>
but I was saying that this would eliminate red herrings that are caused by the initial failure, and continuing to run the tests instead of exiting
<marler8997>
if a test failed and that's the only test you ran, I don't know how that test could be a red herring...?
<g-w1>
hmm, maybe error.ZigTestFailed would let it continue, but panic would stop it?
<marler8997>
I think an example would help. say test A is corrupts memory, and it causes test B to fail
<marler8997>
if you exit on first failure, you would stop on test A, but if you would continue, it would go on to test B and say it failed as well, even though that test is not broken, it's only broken because test A corrupted it
<marler8997>
so in this case, B is a red herring
ur5us__ has joined #zig
<marler8997>
I see this sort of thing all the time in firmware, you see errors all over the place and it can be hard to track down the real initial error. Sometimes it can be good to tell the system to just quit on the first error so you don't have to play detective to figure out where things initially went wrong
<g-w1>
ok cool, do you think my previous idea of returning an error would let it continue, but panicing would fail it would work?
Akuli has quit [Quit: Leaving]
<andrewrk>
that's fine we can have a bail on first error CLI option for the test runner
<marler8997>
.
<marler8997>
andrewrk, what are your thoughts on splitting the windows bindings in std by the dll they appear in? Do we want to continue this route?
<andrewrk>
check out those stats, it's pretty interesting
<marler8997>
7 MB of tokens !
<andrewrk>
with the self-hosted compiler, that 19 MiB Total ZIR bytes is what gets cached for everything.zig, and then on subsequent builds, Source bytes remain unloaded on disk, and Tokens and AST Nodes do not get computed at all
<andrewrk>
so we end up loading 20 MiB from disk instead of 27 MiB, and skip all the tokenization, parsing, and lowering to ZIR steps
<marler8997>
ah I see, that's cool to see
<marler8997>
what about zigwin32/api/internet_explorer? that's the next biggest one but includes more than just aliases
<andrewrk>
internet_explorer.zig:967:28: error: enums do not support 'packed' or 'extern'; instead provide an explicit integer tag type
<andrewrk>
I'm going to advocate for breaking the language soon to remove support for enums with aliased fields
<marler8997>
aliased field?
<andrewrk>
status quo: the only difference between extern enum(T) and enum(T) is that the extern enum(T) allows field aliases. you're actually unknowingly introducing complexity into the compilation by using extern enum and then not taking advantage of aliased fields
<marler8997>
is the motivation behind removing aliases just because aliases are bad practice? Like, there's no reason to support them?
<andrewrk>
they also complicate comptime reflection code trying to do stuff with enums
<andrewrk>
for example if you try to use std.enums.directEnumArray with an extern enum it ends up being O(N^2) at comptime for some reason
<andrewrk>
the existence of field aliases complicates stuff. defining enums to have a mapping bijection of fields to values makes them simpler and more useful
<marler8997>
would the ".Foo" syntax work with "enum { pub const Foo = ... }" ?
<andrewrk>
no
<marler8997>
the reflection things is one of the issues I remember considering when I looked into @fieldAlias
<marler8997>
my solution to that was to include them in a seperate list outside of normal fields
<marler8997>
dang, there's 1577 instances of enum aliases in win32!
<andrewrk>
and they're all legacy compatibility kludges
<marler8997>
I can't argue with that
<marler8997>
astnodes takes alot more memory in the internet_explorer example
<marler8997>
my guess is it would be even higher percentage in implemenation code
<marler8997>
the win32metadata project is done so weird btw, it also seems very unorganized and unplanned
<marler8997>
they've made some commits that have broken things horribly in the metadata, so it seems like they have no real testing
<marler8997>
for a project like this that has many users, I would think to employ a healthy amount of TDD but it's more like hacks on top of hacks
bitmapper has quit [Quit: Connection closed for inactivity]
<andrewrk>
the ratio of (source bytes + tokens + ast nodes) / Total Zir bytes is nearly identical
<marler8997>
I was just looking at source / ast
<marler8997>
well, that's what my comment was about anyway
<andrewrk>
yeah that's interesting too
<marler8997>
I'm gonna have to go implement logic to detect and de-alias enums now...bleh
<andrewrk>
oh snap this whole time I have forgot to count the main_tokens array into AST Nodes byte count