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
<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>
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.
<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
<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