waleee-cl has quit [Quit: Connection closed for inactivity]
shodan45 has joined #zig
dom96 has quit [*.net *.split]
xentec has quit [Ping timeout: 252 seconds]
xentec has joined #zig
ur5us has quit [Ping timeout: 258 seconds]
cole-h has quit [Ping timeout: 252 seconds]
RadekCh has joined #zig
Anzh has quit [Ping timeout: 260 seconds]
earnestly has joined #zig
lemur has joined #zig
retropikzel has quit [Ping timeout: 252 seconds]
ur5us has joined #zig
kshlm has quit [Quit: Idle for 30+ days]
retropikzel has joined #zig
jokoon has joined #zig
l1x has quit [Quit: Connection closed for inactivity]
tnorth has joined #zig
pretty_dumm_guy has joined #zig
RadekCh has quit [Quit: Connection closed]
jokoon has quit [Quit: Leaving]
l1x has joined #zig
paulgrmn_ has joined #zig
ur5us has quit [Ping timeout: 258 seconds]
paulgrmn_ has quit [Ping timeout: 252 seconds]
Anzh has joined #zig
Anzh has quit [Ping timeout: 240 seconds]
Anzh has joined #zig
Anzh has quit [Ping timeout: 240 seconds]
retropikzel has quit [Ping timeout: 250 seconds]
waleee-cl has joined #zig
xackus__ has joined #zig
xackus_ has quit [Read error: Connection reset by peer]
teratorn_ has joined #zig
xackus__ has quit [Ping timeout: 252 seconds]
fireglow has quit [Quit: Gnothi seauton; Veritas vos liberabit]
pretty_dumm_guy has quit [Quit: WeeChat 3.2-dev]
teratorn has quit [Ping timeout: 240 seconds]
paulgrmn_ has joined #zig
<noam>
I know there's been a bunch of comptime proposals. With all the accepted proposals, is it possible for a comptime function to have implicit inputs (e.g. to reference global comptime values or some such)?
<noam>
IIUC, the desire to remove visible execution order means the answer is "no"?
<fengb>
TheLemonMan: I don't have a working *Linux* ppc box. Been running code on my Wii so I can test out freestanding
<mikdusan>
TheLmeonMan: if you are still checking #8421, I have to get some sleep. will check status later.
teratorn_ is now known as teratorn
dyeplexer has joined #zig
aeldemery has joined #zig
marler8997 has joined #zig
<marler8997>
I've got an issue with compiling a Gameboy Advance rom that I'm not sure how to solve, maybe someone has ideas
<marler8997>
I've created a new library based on the existing ZigGBA one, which uses a custom linker script
<marler8997>
the startup code is identified by a link section, and is located in a zig module in the gba library, problem is, how do you force zig to import a library?
<marler8997>
the std library does the same thing, it has comptime { _ = start } in std.zig, which forces start.zig to get imported
<marler8997>
however, what forced "std.zig" to get imported in the first place?
<marler8997>
I'm hoping there is some configuration in build.zig that will allow me to force a module to get imported, so it works just like std.zig
<ifreund>
marler8997: pretty sure that std.zig import is hardcoded in the compiler
<andrewrk>
marler8997, seems like start.zig should unconditionally do `_ = root;` do you see any reason why this is insufficient?
<andrewrk>
wait, that's already the case, since it checks @hasDecl on root
<andrewrk>
let me try to understand the problem statement more
<marler8997>
yeah, we never get far enough to import start.zig
<ifreund>
I think the problem is that someone using this GBA build setup might forget to add the `comptime { _ = @import("foo.zig"); }` to their root source file
<marler8997>
I mean, import gba/start.zig
<ifreund>
which I'm not 100% convinced really needs solving
<marler8997>
do you have a way that forgetting it could cause a good error message?
<ifreund>
marler8997: you said forgetting it produces an invalid rom. Can you trivially check if the produced binary is invalid?
<ifreund>
if so, add a build.zig step to do just that
<marler8997>
sounds possible
<marler8997>
that could get kinda hairy for a library that runs on multiple platforms
<andrewrk>
I think this is related to the idea/use case of having a package be an OS abstraction
<marler8997>
yeah it seems related
<marler8997>
we could create another special package name for this
<marler8997>
for example, we could reserve the "start" package, and allow the user to set it
<marler8997>
or, we could add a command-line option to provide a "start.zig" module?
xackus has joined #zig
LewisGaul has quit [Ping timeout: 240 seconds]
<andrewrk>
I'm open to all of these possibilities
<noam>
Hmm. I think start as a package is a better option
<marler8997>
I'm trying to think if there are use cases where you'd want this behavior on things besides the program entry point
<andrewrk>
noam, top level comptime blocks can reference any other decls. however, note that all comptime mutable state becomes immutable when the variable goes out of scope
* noam
nods slowly
<noam>
but comptime *functions* cannot, right?
<marler8997>
if one were to write say a dynamic library in Zig, and you had exports split amongst multiple files, you use comptime { _ = @import("funcs1.zig); _ = @import("funcs2.zig"); } ??
<marler8997>
*would you use
<andrewrk>
noam, "comptime function" is a bit of a misnomer. there is only functions that execute at comptime, which causes local variables to become comptime mutable state. so, when these variables go out of scope, the comptime data (if references still exist) becomes immutable, and managed by the compiler's static data garbage collector (same as string literals)
<noam>
I'm talking conceptually, not about the implementation :)
<andrewrk>
so am i
<noam>
> managed by the compiler's static data garbage collector
<andrewrk>
marler8997, yes that's currently the way to do it
cole-h has quit [Quit: Goodbye]
<marler8997>
ok, well, that kinda seems like a similar issue
plumm has quit [Remote host closed the connection]
<noam>
andrewrk: the underlying question: every call to a comptime function foo with identical arguments is guaranteed to have an identical result, correct?
cole-h has joined #zig
<noam>
Put differently: the only mutable comptime state a function can access is internal?
plumm has joined #zig
dyeplexer has quit [Remote host closed the connection]
vrdhn has joined #zig
<andrewrk>
marler8997, in C this is solved by putting other source files on the command line (with separate compiler invocations). there's nothing stopping us from doing that in zig, however I think it's better having a root source file and to have the source code decide what other files to import, specifically because it allows you to use comptime logic to selectively import
<andrewrk>
I think in practice status quo is quite reasonable
<marler8997>
interesting
<andrewrk>
noam, a comptime function call may pass a pointer as a parameter, allowing the function call to mutate comptime state outside of the function scope
retropikzel has joined #zig
<noam>
ahhhh right
<andrewrk>
comptime function calls that mutate external comptime state are exempt from memoization
<noam>
Wasn't there the intent to hide execution order eventually?
<marler8997>
here's another idea, what if we included a way to force function to be evaluated but not export it?
<noam>
marler8997: `_ = foo;`?
<noam>
Is there anything in e.g. stdlib that depends on comptime functions being able to receive pointers to comptime mutable state?
<marler8997>
whatever solution we use, I feel like we'd have to be ok with requiring it on helloworld.zig as well
<ifreund>
noam: you want to be able to use std.mem at comptime or not?
<marler8997>
right now Zig is hardcoding std.zig to always be evaluated whether or not it is used, which is why helloworld works without comptime { _ = main; }
<noam>
ifreund: Which functions would need this?
<marler8997>
so if we're saying that we're ok with requiring all users to use comptime { _ = main; }, the why would "std" get special treatment?
<marler8997>
if we find value in not requiring the user to include comptime { _ = main; }, then we would be adding that same "value" to third party libraries as well
<ifreund>
noam: std.mem.copy() for the most basic example
<andrewrk>
marler8997, comptime { _ = main; } wouldn't do anything because it doesn't export anything. if you did export fn main() then it would work and you don't need the comptime
<marler8997>
right, unless you imported the module inside main
<marler8997>
so in my case, comptime { _ = main; } doesn't cause main to be exported directly, but it causes it to be evaluated which causes @import("gba") to be evaluated which in turn causes start.zig to get evaluated...
<marler8997>
it's not a good solution, just thinking out loud at the moment :)
vrdhn has quit [Remote host closed the connection]
<marler8997>
more thinking out loud, what if we made "start.zig" the root module for executables?
<marler8997>
but no, the root module is where the user can configure things
<marler8997>
maybe we should have an "app" module and an "entry" module?
<marler8997>
"entry" is the module that always gets evaluated, "app" is where the user defines "main" and whatever else
<marler8997>
Ok I'm just back to the "start" idea, I think I'm liking that more now
<andrewrk>
what's the "start" idea?
halbeno has quit [Remote host closed the connection]
<marler8997>
reserve the package "start" to contain the module that has the export to start the evaluation chain
<marler8997>
so basically "std/start.zig" would get set to "start" by default, but could be overriden
<andrewrk>
that seems pretty clean but doesn't that effectively move `comptime { _ = @import("gba.zig"); }` to build.zig?
<andrewrk>
is that actually better?
halbeno has joined #zig
<marler8997>
thinking...
<marler8997>
not saying this is the main difference, but this one could be enforced I think, in start.zig, comptime { assert(@import("starg") == @This())) }
<marler8997>
the interface is also a bit more explicit/clear I think
<marler8997>
right now, std/start.zig works because of 2 things, 1) std.zig is always evaluated and 2) there is a _ = start in std.zig
<marler8997>
the issue with gba is we can't really solve 1
retropikzel has quit [Quit: Leaving]
<marler8997>
but with an explicit "start" feature, the "start" package always gets evaluated, so now we don't need #2 in std, which divorces std from the startup code
<marler8997>
I guess I'm becoming convinced that "start" is special enough to warrant an explicit feature like this, rather than relying on the compiler always evaluating std and the _ = start lines in std.zig
tnorth has quit [Ping timeout: 250 seconds]
<andrewrk>
I'm interested in continuing this conversation at some point. Right now I'm going to close IRC and try to get some self-hosted compiler progress done :)
<marler8997>
ok, ttyl then
<ifreund>
enjoy!
<andrewrk>
which, coincidentally, is the part where we make stage2 automatically do `_ = @import("std")` :D
<marler8997>
:) lol
aerona has joined #zig
ki9a has joined #zig
pjfichet has joined #zig
<marler8997>
if we implemented the "start" package, could we remove the hardcoding in the compiler to always import std.zig?
<mikdusan>
freebsd 13.0 release is in progress; notable supported tiers changes:
<mikdusan>
- 32-bit x86 drops to tier 2
<mikdusan>
- 64-bit armv8 (aarch64) bumps to tier 1
jokoon has quit [Quit: Leaving]
wootehfoot has joined #zig
lemur has quit [Quit: Konversation terminated!]
lemur has joined #zig
<g-w1>
how does Module.deletion_set get updated? in performAllTheWork, im trying to get the amount of deleted decls by checking `const deleted_decls = mod.deletion_set.count();` but i dont think its working
<g-w1>
its just giving 0 in performAllTheWork
<g-w1>
*at the end of performAllTheWork
wootehfoot has quit [Quit: Leaving]
<g-w1>
eh, i think `update completed: 1/1 decls modified` is good enough