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/
CantrellD has joined #zig
CantrellD has quit [Read error: Connection reset by peer]
<plumm> gonz_ file an issue?
ur5us has quit [Ping timeout: 252 seconds]
layneson has quit [Quit: WeeChat 2.8]
curtisf has joined #zig
ur5us has joined #zig
<curtisf> I'm finally upgrading from zig 0.4.0 --> 0.6.0 and wondering about a "slice literal". I'm getting an error from this line of code:` const space_class = CharacterClass.fromList([_]u8{ ' ', '\t', '\n' });`
<curtisf> saying that I need to take `&` to coerce the array into a slice. My question is, is that slice going to still be valid after the containing function returns? Would the array be on the stack or in static space?
<fengb> No it’s never safe to return slices (or pointers) like that
<fengb> Wait... it might be if it’s const
<fengb> If it’s a variable, it’ll be on the stack and be broken yeah. If it’s const it probably would work since it should be in the data section
<curtisf> I guess that seems a little spooky to rely on... is there a way to require "this expression should be (comptime and) located in data and not on the stack"?
<alexnask> The u8 array will always be in static data in this case
<alexnask> Since all elements are constant values
<curtisf> I guess something like this could guarantee it? https://gist.github.com/CurtisFenner/364c3d47c94ca43156f634d219f9977e
<curtisf> or is just (&comptime x) enough
<alexnask> Here is an example with arrays of strings: https://godbolt.org/z/CL3EBZ
<andrewrk> curtisf, they `comptime` keyword is enough
<andrewrk> curtisf, note that in 0.4.0, zig was implicitly taking the address behind your back, so the level of safety here remains the same. if anything it has increased, since you are now more aware this is happening
<andrewrk> for example in 0.4.0 if any of the array elements were runtime known, that pointer would expire when the function returns
<curtisf> Yea, the error just made me think about this more, which I appreciate.
<curtisf> If it _was_ runtime, when exactly does the 'lifetime' of the array expire? end of containing block? end of expression? end of statement?
<fengb> End of block
<curtisf> Cool, that's what I was hoping
<curtisf> Oh no, I'm hitting a new compiler crash. Too much comptime lol
nephele_ has joined #zig
nephele has quit [Ping timeout: 256 seconds]
nephele_ is now known as nephele
kevsmith has joined #zig
<alexnask> curtisf, can you link to the code?
<curtisf> I'm working on shrinking it
aerona has joined #zig
<alexnask> ok cool
<curtisf> I'm assuming you won't appreciate a 700 line test case ;)
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 272 seconds]
<Cadey> andrewrk: how complete is zig translate?
<Cadey> i'm half considering trying it on the super mario 64 code
dddddd has quit [Ping timeout: 246 seconds]
<andrewrk> Cadey, it's probably not up to that task
<andrewrk> that would be a fun motivating use case though
<Cadey> the sm64 pc port code does some insane things
<andrewrk> maybe try to get Vexu excited about the idea :)
<Cadey> i saw an ifdef case that ended during a function definition
<Cadey> like
<Cadey> ifdefing functions entirely while in the middle of another function
<andrewrk> that part is no problem for zig
<andrewrk> it would be an unimplemented translation such as bit fields
<andrewrk> ...that would be problematic
<Cadey> well
<Cadey> guess what this game uses all over the place
<Cadey> :D
curtisf has quit [Remote host closed the connection]
<andrewrk> haha
curtisf has joined #zig
<Cadey> it also does some funky stuff like an implicit cast from an array to an integer
<curtisf> Wow, I got this crash very small. ...though the assert message is slightly different than when I started
foobles has quit [Remote host closed the connection]
<curtisf> alexnask: If you're still interested in looking https://gist.github.com/CurtisFenner/3048d048a225e232329575ba36bb8783 I'm only on 0.6.0 so it is possible this has already been fixed, though I didn't find that particular line number when searching github issues
<curtisf> If someone wouldn't mind reproducing ^ on master I can file a GitHub issue
return0e_ has joined #zig
return0e has quit [Ping timeout: 260 seconds]
Biolunar has quit [Ping timeout: 240 seconds]
Biolunar has joined #zig
<andrewrk> curtisf, confirmed repro on master. thanks for the small test case
<curtisf> Is there a type for "I want a comptime _array_ but I don't care about its size"? Or are you just supposed to use a comptime slice?
curtisf has quit [Remote host closed the connection]
xackus_ has joined #zig
metaleap has joined #zig
xackus_ has quit [Ping timeout: 256 seconds]
benjif has quit [Ping timeout: 272 seconds]
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 264 seconds]
<andrewrk> today I worked on self-hosted incremental compilation. I think this is going to work extremely well...
<andrewrk> hopefully will have something to demo on a stream within a few days
<andrewrk> as it turns out, LSP, hot code swapping, and incremental compilation is all kinda the same problem
aerona has quit [Quit: Leaving]
return0e has joined #zig
return0e_ has quit [Read error: Connection reset by peer]
ur5us has quit [Ping timeout: 260 seconds]
st4ll1 has joined #zig
cole-h has quit [Quit: Goodbye]
<tdeo> very exciting
pystub has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
pystub has quit [Ping timeout: 260 seconds]
frett27 has quit [Ping timeout: 260 seconds]
frett27 has joined #zig
wootehfoot has joined #zig
gazler has joined #zig
wilsonk has quit [Ping timeout: 246 seconds]
st4ll1 has quit [Quit: WeeChat 2.8]
wilsonk has joined #zig
hspak has quit [Quit: Ping timeout (120 seconds)]
hspak has joined #zig
Biolunar has quit [Quit: leaving]
<ikskuh> andrewrk: can you explain how "Hot code swapping" is supposed to work?
dermetfan has joined #zig
<ikskuh> I really love that feature in C# with "edit & continue" and it would be absolutely awesome to have this in zig
slurpie has quit [Ping timeout: 264 seconds]
dermetfan has quit [Ping timeout: 256 seconds]
dermetfan has joined #zig
dddddd has joined #zig
<gonz_> I would settle for consistent symbol availability on Windows without "edit & continue" :P
<gonz_> And watch window support, etc.
<gonz_> Neither of which is currently a thing.
<ikskuh> isn't gdb working on windows?
<alexnask> Idk about gdb but lldb works fine in my experience
<gonz_> I've tried WinDBG, VS, WinDBG via VSCode, RemedyBG and some other ones I basically never expected to work anyway.
<gonz_> alexnask: Does LLDB work for x64 on Windows?
<gonz_> As far as I heard it doesn't, which is a no-starter.
<alexnask> It works, at least for clang/clang-cl or llvm compiled executables
knebulae has quit [Quit: Leaving]
redj_ has joined #zig
moo has joined #zig
<gonz_> Not from what I'm seeing here
<gonz_> No watch window support, etc., none of the symbols available
wootehfoot has quit [Ping timeout: 256 seconds]
redj has quit [Ping timeout: 256 seconds]
<gonz_> With LLDB I'm not even getting locals
xackus_ has joined #zig
alexnask has quit [Quit: Leaving]
<gonz_> Either the LLDB vscode debug adapters are all broken or LLDB is actually a step down from VSdbg or whatever the basic C++ debugging adapter is w/ VSCode
<gonz_> At least with that one I get breakpoint support (didn't with the LLDB adapter that worked) and locals + *some* IDs being available for watch
metabulation has joined #zig
moo has quit [Ping timeout: 256 seconds]
knebulae has joined #zig
lanodan has quit [Ping timeout: 252 seconds]
slurpie has joined #zig
decentpenguin has joined #zig
decentpenguin has quit [Ping timeout: 256 seconds]
decentpenguin has joined #zig
basedtho has joined #zig
metaleap has quit [Quit: Leaving]
marmotini_ has joined #zig
frmdstryr has joined #zig
<gonz_> I'm either hitting a very, very rare case of stuff working fairly well or the basic VS/WinDBG/ debugging is improved and giving an uncharacteristically correct view of symbols.
marmotini_ has quit [Ping timeout: 260 seconds]
layneson has joined #zig
benjif has joined #zig
cole-h has joined #zig
decentpenguin has quit [Quit: decentpenguin]
decentpenguin has joined #zig
<frmdstryr> const ISR = extern fn () void;
<frmdstryr> ./startup.zig:775:13: error: invalid token: 'extern'
<frmdstryr> ?? what changed
<ikskuh> callconv(.C)
<ikskuh> const ISR = fn() callconv(.C) void;
<frmdstryr> Ah, thanks!
<frmdstryr> Is there something similar for async fn?
<plumm> i think theres a callconv for async?
<ikskuh> callconv(.Async)
dermetfan has quit [Ping timeout: 265 seconds]
waleee-cl has joined #zig
<frmdstryr> Has `const something = if (xxx) a else b; ` also changed?
<frmdstryr> Gone for like a few weeks and everything is broken haha
<plumm> That should still work
metaleap has joined #zig
metaleap has quit [Remote host closed the connection]
metaleap has joined #zig
Akuli has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Read error: Connection reset by peer]
dnmllr has joined #zig
Xavi92 has joined #zig
pystub has joined #zig
redj_ is now known as redj
frett27_ has joined #zig
lanodan has joined #zig
frett27 has quit [Ping timeout: 264 seconds]
<andrewrk> ikskuh, pretty straightforward: check out https://github.com/ziglang/zig/issues/5260 specifically the second bullet point
<plumm> andrewrk would it make sense to have a source format check just as a nice-to-have but also real time test of zig fmt?
<andrewrk> are you thinking of the --check flag?
<plumm> I dont have a zig installed to check but if that exists yes
<plumm> In CI
<ikskuh> andrewrk: ah so kinda super-dynamic linking :)
<ikskuh> one problem is that funtions will always return into the old code :D
<andrewrk> ikskuh, that's a feature! each function call will get the new function, but any ongoing control flow finishes in the old function
<ikskuh> hmm
<ikskuh> well, it's a first step for sure ☺
<ikskuh> have you ever used VisualStudio+C#+Edit&Continue?
<shakesoda> i can see that causing explosions but it sounds good
<ikskuh> if weg get this powerful at zig language level
<ikskuh> it would be absolutely awesome
<shakesoda> hot swapping is always a bit prone to that
metaleap has quit [Remote host closed the connection]
metaleap has joined #zig
<andrewrk> ikskuh, yep my first programming language supported that. VB6
<andrewrk> in some ways I have never gotten back to the productivity that I experienced with the VB6 IDE and debugger
<ikskuh> hehe, would be a glorious goal
layneson has quit [Quit: WeeChat 2.8]
<pmwhite> Does zig create debug symbols with the default build.zig?
FireFox317 has joined #zig
<FireFox317> andrewrk, will you be streaming tonight? :D
<andrewrk> maybe! I want to get to a certain checkpoint in the code. right now I'm doing a lot of chin scratching and thinking and staring at struct layouts
<andrewrk> pmwhite, yes
<pmwhite> I thought so. I was having trouble using the linux perf tool because some things seem to be broken. It's another problem with my system though.
<oats> andrewrk: ooh, what are you working on?
<andrewrk> self-hosted (non-llvm) backend
<oats> Sweet, already!
<oats> Will that make it harder to target/support as many architectures as are right now?
<Xavi92> That's an interesting question
<andrewrk> no it makes it much easier
<andrewrk> we don't lose any backends since llvm/clang/lld remain an optional dependency
<Xavi92> andrewrk: and what would the self-hosted compiler generate for other targets? LLVM IR?
<FireFox317> code :D
<FireFox317> i mean instructions for a cpu
decentpenguin has quit [Quit: decentpenguin]
<Xavi92> FireFox317: now I'm confused. Wouldn't the backends provided by llvm?
<Xavi92> be provided*
<FireFox317> Xavi92, the self-hosted compiler that andrewrk is writing also includes his own codegeneration
<FireFox317> in that sense it would be much easier to add a target to zig, since you would have to add the target to the zig code instead of the big and bulky llvm codebase
<Xavi92> So that, even if easier due to the size of the zig code base, backends would still need to be written from scratch, right?
<FireFox317> yes i think that is correct. Not 100% sure tho
<andrewrk> the neat thing we can do in zig is make the architecture a comptime parameter in those functions, so there would be no compilation speed penalty for switching on the arch :D
<Xavi92> andrewrk: looks handy, but... really? Magic constants on zig? :P
<andrewrk> where's the magic? that's the machine code for `ret` in x86
<Xavi92> I'd rather use e.g.: `const ret = 0xcc` than a constant with a comment on its side, but that's personal taste for sure
<fengb> It’s already in the genRet block
<Xavi92> Don't take it too seriously, that is a very simple example after all
<ikskuh> nah, it's a perfect example where it doesn't make sense to include a constant
<ikskuh> why should you return a constant? it clutters namespace and will make reading code harder than with a simple comment like in the code above
<ikskuh> it is used only there, nothing else in the code relies in that value
<fengb> Also x86 really doesn’t map to constants well. There’s lots of names that correspond to multiple instruction codes
<Xavi92> Didn't say I would place the constant on the global namespace. If anything, I'd rather place it inside the `.i386, .x86_64` block
<Xavi92> ikskuh: that's also your personal opinion
<ikskuh> yeah
<ikskuh> but:
<ikskuh> what is better:
<Xavi92> `const int3 = 0xcc; try self.code.append(0xcc);`
<ikskuh> const X86_RET_OPCODE = 0xC3;
<ikskuh> try self.code.append(X86_RET_OPCODE);
<Xavi92> Sorry, `const int3 = 0xcc; try self.code.append(INT3);`
<ikskuh> or try self.code.append(0xC3); // x86 ret
<ikskuh> one clutters namespace
<Xavi92> Don't mind about my stupid typing mistakes
<ikskuh> one does not
<ikskuh> both have exactly the same transportation of semantics
<Xavi92> ikskuh: one does rely on a comment, and I don't usually trust comments
<ikskuh> it's an invariant anyways
<ikskuh> it will never change
<Xavi92> Don't feel like bike-shedding, honestly. It's just personal taste
<Xavi92> What's important here is the fact porting zig to other targets looks straightforward
<Xavi92> And that's a good thing!
<ikskuh> andrewrk: looks like the current design will only support register machines?
dermetfan has joined #zig
<andrewrk> ikskuh, after I get a bit further on this I would love to have a discussion with you about weird architectures and see if you can break the design :)
_Vi has quit [Ping timeout: 244 seconds]
<oats> does llvm do much optimization in the IR -> machine code process?
<oats> if so, will zig lose the benefit of those optimizations?
<tdeo> llvm isn't going away
<tdeo> i believe
<oats> gotcha
<andrewrk> oats, yes llvm will always be better at zig for runtime optimizations
<andrewrk> but we can get 80% of the way there with 20% of the effort
<oats> I like the sound of that
<oats> is that just a result of llvm's size and complexity?
<andrewrk> yes and money
<Xavi92> Is LLVM causing much hassle to you contributors?
<fengb> At bare minimum, we can have much improved compile speed
<andrewrk> Xavi92, look at the 2 pinned issues on github...
<oats> yikes, that's not great
<Xavi92> Oh, I see :/
<ikskuh> andrewrk, you're welcome. i'm asking because of .NET/JVM output
<ikskuh> which would be awesome
_Vi has joined #zig
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<fengb> And wasm? 🙃
<ikskuh> well, you know wasm *grin*
<ikskuh> but would be awesome to just target *any* platfrom
drvirgilio has quit [Ping timeout: 260 seconds]
<ikskuh> .NET? yeah sure... Java? Yep. ARM? Yep! Web? ack
<fengb> I think it'd make closer to wasm tbh. How would you sidestep the GC on .NET or JVM?
<fengb> I suppose you could make a custom mmap backed with bytes so maybe I'm talking out of my ass :P
<ikskuh> fengb: we don'T have to sidestep the allocator :D
<ikskuh> GC
<ikskuh> gc_allocator would be an alloc() { new arra[] }
<ikskuh> and free() { }
<ikskuh> fengb: note that msvc has a obscure mode for C++/CLI
<fengb> free() doesn't map to the GC though. Although I do remember emscripten working around the GC by having a fixed buffer for the "memory"
<ikskuh> fengb: if the code is done right, freeing in a GC allocator is a no-op
<ikskuh> as the GC will just be happy with that
drvirgilio has joined #zig
<fengb> Hmm
<ikskuh> i think it's wort a try
<ikskuh> oh, and daurnimator could built a lua bytecode backend *laughs*
ifreund has joined #zig
joey152 has joined #zig
<oats> zig JS target when
<oats> ikskuh: haha, love it
<oats> I would totally try to find a use for that
<ikskuh> coding lua with zig? :D
<oats> lua's fun
<oats> there's already a handful of neat little languages that transpile to it
<oats> moonscript, fennel, etc
st4ll1 has joined #zig
drvirgilio has quit [Ping timeout: 240 seconds]
Xavi92 has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
drvirgilio has joined #zig
pystub has quit [Ping timeout: 240 seconds]
Akuli has quit [Quit: Leaving]
metaleap has quit [Remote host closed the connection]
metaleap has joined #zig
joey152 has quit [Ping timeout: 260 seconds]
dermetfan has quit [Quit: WeeChat 2.8]
FireFox317 has quit [Read error: Connection reset by peer]
FireFox317 has joined #zig
joey152 has joined #zig
<cow-orker> andrewrk: in src-self-hosted/codegen.zig - if (amount <= std.math.maxInt(u8)) .... but 0xEB (short jmp) takes a i8 (-128..127)
<andrewrk> good catch
dnmllr has joined #zig
st4ll1 has quit [Ping timeout: 260 seconds]
metaleap has quit [Remote host closed the connection]
frett27 has joined #zig
frett27_ has quit [Ping timeout: 260 seconds]
<pmwhite> I just learned about the -ggdb option to gcc. I'm guessing there is no way to achieve the same effect with the zig compiler, but it would be nice right now.https://gcc.gnu.org/legacy-ml/gcc-help/2009-02/msg00130.html
slurpie has quit [Remote host closed the connection]
ifreund has quit [Ping timeout: 260 seconds]
slurpie has joined #zig
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
slurpie has quit [Ping timeout: 272 seconds]
FireFox317 has quit [Ping timeout: 256 seconds]
<daurnimator> ikskuh: better to target lua itself. the lua bytecode is implementation specific.
<ikskuh> ah
<fengb> Not a spec?