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/
klltkr has quit [Remote host closed the connection]
<tgschultz> daurnimator: I'm not even being specific to languages. For instance, I think package managers as they exist in all the unixes cause way way more trouble than they have ever solved.
<AlexMax> Hrm, just found out about the \n on windows thing.
<marler8997_> Have you tried nix?
<AlexMax> I'm a fan of being opinionated in terms of source formatting, but enforcing a non-native newline style on windows kind of rubs me the wrong way.
<AlexMax> Not a big deal to set my editor to something else, but I just hope I don't run into problems elsewhere.
<marler8997_> also no tabs
<AlexMax> Yeah I saw that too, no complaints about that.
<AlexMax> \r\n vs \n doesn't strike me as some sort of formatting holy war topic, more platform convenience. A text file on windows uses \r\n, and \n is supported on a case-by-case basis. I haven't had to think about line-endings in a very long time, because git seems to do the right thing automatically - storing internally as \n, checking out in the working copy as \r\n. Now I have to think about it.
<AlexMax> It's not a gigantic deal, and there have already probably been countless conversations on the topic, and I'm sure there is justification and concensus was probably reached long ago. Just saying it's odd.
<tgschultz> AlexMax: zig fmt is meant to deal with that on your behalf. And yeah, it's been discussed entirely too much for something so insignificant.
<AlexMax> Oh, zig fmt will fix that? Gotcha. I'm using VSCode and at least the plugin I'm using it didn't run on save for me.
<AlexMax> I think I toyed around with it in vim too, where it did run zig fmt automatically, but for some reason indentation always shifted left 4 spaces on a newline.
st4ll1 has quit [Ping timeout: 258 seconds]
<AlexMax> hrm, zig fmt isn't fixing this for me
<AlexMax> > .\build.zig:1:28: error: Expected test, comptime, var decl, or container field, found Invalid
st4ll1 has joined #zig
<tgschultz> I'm afraid I can't help, I just tell Notepad++ to use LF only, and only zig fmt when I make PRs.
<squeek502> zig fmt correcting line endings is planned, not implemented
<AlexMax> Oh there's nothing to help. Changing this in my editor is trivial.
<tgschultz> ah, well that would do it. it seems a simple enough thing to do, just eat all CRs
<AlexMax> i was just under the impression that zig fmt already fixed that problem, because of what you said
<tgschultz> I honestly thought it was implemented
<AlexMax> No worries.
<AlexMax> I understand how one could be mistaken.
<cyanmide> Has there been any progress on a language server for zig?
<AlexMax> My old C project had some crazy cmake stuff set up where it automatically downloaded, built, and made accessible to my main program some dependencies without actually vendoring the source to my repository. It was a bear to set up, but when I finally got it working it was really quite nice. What would be the recommended alternative to this in Zig?
marijnfs_ has joined #zig
<AlexMax> ExternalProject I think it was called
marijnfs has quit [Ping timeout: 245 seconds]
<AlexMax> zig build --verbose doesn't seem to actually print anything
<AlexMax> Should it?
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
curtisf has joined #zig
<mikdusan> only a few things like install artifacts (zig build install) respond to --verbose. maybe try `--verbose-link` but be aware zig-cache is smart enough to avoid relinking when source, compiler or options are the same
<AlexMax> I was careless and was missing a few things for a working build script, so zig build literally did nothing
<AlexMax> so that would explain why --verbose didn't work - it did, there was just nothing to show :P
letoram has joined #zig
<andrewrk> cyanmide, no progress to report, check back in a release cycle or two
_whitelogger has joined #zig
<curtisf> What's the cleanest way to loop over a list-like data structure in zig? I see issue for loop over index range was closed :(
<andrewrk> curtisf, std.ArrayList? for (array_list.toSlice()) |item| {}
<curtisf> It's my own data structure, and converting it to a slice would require allocation because the elements aren't contiguous
<andrewrk> linked list: while (maybe_node) |node| : (maybe_node = node.next) {}
<emekankurumeh[m]> or implement your own custom iterator for it
<curtisf> an iterator like the linked list seems like it would work
<andrewrk> yeah optionals & while go well together
<andrewrk> you can also implement an iterator struct with a "next" method, and then it looks like: while (it.next()) |item| {}
<curtisf> hmmm I think I've broken the compiler. I'm getting no output from `zig build-exe` but it's not returning successfully
<emekankurumeh[m]> did you compile it in debug mode?
<emekankurumeh[m]> the compiler
<curtisf> I don't remember... is there a way to tell from the binary?
<curtisf> ah, no I followed the wiki instructions which are Release
<andrewrk> on windows I was unable to figure out how to get zig in debug mode with llvm in release mode
<andrewrk> and llvm is practically unusable in debug mode
<curtisf> ah, that's unfortunate
<curtisf> I can try to make a minimal failure tomorrow
<scientes> andrewrk, maybe you at least build a release tablegen LLVM_OPTIMIZED_TABLEGEN=true
<andrewrk> scientes, what is that and why is it not on by default?
<scientes> its for when the rest is debug
<andrewrk> nice work on fmuladd btw
<scientes> and the LLVM defaults are horrible, such as doing parallel linking by default
<scientes> tablegen is how llvm generates code, its documented here http://llvm.org/docs/CMake.html
<scientes> *generates assembly
<andrewrk> unrelated: I tried building zig with emscripten for webassembly so that there could be a client-side zig sandbox in the browser. I got 7% through compiling LLVM: https://github.com/emscripten-core/emscripten/issues/6015#issuecomment-503404904
<scientes> well, tablegen is so important it has its own page http://llvm.org/docs/TableGen/
<scientes> I didn't think emscripten support 64-bit ints
<scientes> which is part of c99 compat
<andrewrk> in a turing complete language you can do anything
<scientes> well......
<andrewrk> emscripten cannot self-host yet: https://github.com/emscripten-core/emscripten/issues/6432
<scientes> if its compiling to wasm then it should support 64-bit ints
<scientes> i guess emscripten isn't the same thing i knew when asm.js was around
<curtisf> ooo, it turns out it was caused by me using `var` as a return type
<andrewrk> curtisf, ah, yes, sorry that is potentially planned but not currently implemented, and in some situations crashes rather than printing a helpful message
<andrewrk> return type inference proposal: https://github.com/ziglang/zig/issues/447
<curtisf> Yea, as I started removing things I got that error message
<curtisf> Would it be useful to share the program that causes the crash without the message? It's rather small
<andrewrk> it might be, but I can't promise anything
<curtisf> well, here it is: https://hastebin.com/vodawegado.zig I'll remember not to accidentally type `var` as return types
<curtisf> I'm about a week behind master so I guess it's also possible it's been fixed
benaiah has quit [Remote host closed the connection]
curtisf has quit [Ping timeout: 256 seconds]
benaiah has joined #zig
<andrewrk> unlikely on this one
lunamn has quit [Quit: Lost terminal]
<marler8997_> Is there a way to know which commit the packages were generated from on the download page?
<marler8997_> oh you know what, I'm an idiot....the sha is right there in the filename
<marler8997_> der
daex has quit [Ping timeout: 248 seconds]
<gonz_> What's the magic invocation to get the Visual Studio debugger to correctly watch variables and list locals for a zig executable? The PDB and everything is all there.
Ichorio has joined #zig
<ki9a> gonz_: you open the .exe as a project in vc++ and it doesn't show locals?
<gonz_> no
ltriant has quit [Ping timeout: 248 seconds]
Ichorio has quit [Ping timeout: 252 seconds]
tdl7rt has joined #zig
avoidr has joined #zig
<gonz_> Nevermind… I was just testing with a too minimal example…
mattisme has joined #zig
SamTebbs33 has joined #zig
tdl7rt has quit [Quit: Page closed]
SamTebbs33 is now known as samtebbs
samtebbs has quit [Quit: leaving]
SamTebbs33 has joined #zig
SamTebbs33 is now known as samtebbs
samtebbs has quit [Client Quit]
samtebbs has joined #zig
avoidr has quit [Quit: leaving]
hio has joined #zig
daex has joined #zig
<BitPuffin> so var as the type in function parameters results in comptime ducktyping or something?
<BitPuffin> was trying to read some std lib code
st4ll1 has quit [Ping timeout: 246 seconds]
Aransentin has joined #zig
<marijnfs_> BitPuffin: it's more like templating, the function get's explicitly compiled with the type you provide
<BitPuffin> hmm well they seem to go hand in hand in zig
Akuli has joined #zig
halosghost has joined #zig
Aransentin has quit []
lunamn has joined #zig
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
porky11 has joined #zig
<daurnimator> BitPuffin: yeah pretty much compile time ducktyping
<AlexMax> Hrm, curious. addIncludeDir() seems to use -isystem instead of -I.
<AlexMax> I'm not sure it can build one of my C project's without modification, as I (perhaps foolishly) used -Ifoo/#include "bar.h" instead of #include "foo/bar.h"
marijnfs has joined #zig
wootehfoot has joined #zig
FireFox317 has joined #zig
<FireFox317> AlexMax: did you know you can use @cInclude and @cImport inside zig code to include c code?
avoidr has joined #zig
<tralamazza> FireFox317: the PROVIDE was really the magic, thanks again
<tralamazza> unfortunately the @export with .Weak did not work
porky11 has quit [Ping timeout: 252 seconds]
<FireFox317> tralamazza: Nice! Good to hear. What microcontroller are you programming? I'm trying to program a stm32 cortex m4, but if I set the correct size for the RAM I get a hardfault and if I set the size a bit smaller it works. However, debugging is kinda hard since I can't single step on the actual hardware
<tralamazza> I have a bluepill laying around, gonna use that for now
<tralamazza> but eventually port to nrf52
<tralamazza> which stm32 exactly?
<tralamazza> f4?
redj has quit [Read error: Connection reset by peer]
marler8997 has joined #zig
<FireFox317> tralamazza: Jup: stm32f446re
redj has joined #zig
<marler8997> I've just finished a tool that will download the latest zig compiler on windows: https://github.com/marler8997/zigbuild
<marler8997> python3 downloadlatest
<marler8997> currently requires curl, but planning on adding support for more http download clients
<marler8997> after running this tool, you should be able to execute the latest zig compiler, you don't even need to update your PATH
<tralamazza> oh there is a zig in chocolatey
<marler8997> does it let you download the latest zig compiler?
<Sahnvour> it's also in scoop I think
<marler8997> you can download the latest zig compiler with these? from master?
<marler8997> I downloaded chocoloatey but not able to figure out how to download the latest compiler from master
<Sahnvour> on scoop it's 0.4.0 it seems
<marler8997> it probably doesn't make since to push every build of zig to a package manager's metadata
<Sahnvour> yep
<Sahnvour> I'm not sure they want that
<Sahnvour> and someone has to do it
<marler8997> yeah, sounds like chocelatey and scoop are a different use case than what my script does, which is just to download the latest bleeding edge compiler from ziglang.org/download
<tralamazza> choco seems 0.4 also
<marler8997> maybe there's a way to ask choco/scoop to install the latest master, but haven't seen a way
<daurnimator> marler8997: something I've suggested for windows in particular is a fully-self-contained zig binary
<daurnimator> ==> just download zig.exe and e.g. the std library and all the libcs are bundled in there
FireFox317 has quit [Quit: Page closed]
Akuli has quit [Quit: Leaving]
daex has quit [Ping timeout: 246 seconds]
marijnfs has quit [Quit: WeeChat 2.4]
Ichorio has joined #zig
marijnfs has joined #zig
moo has joined #zig
wootehfoot has quit [Ping timeout: 268 seconds]
<Tetralux> daurnimator: I like to be able to open the source code of std, so I wouldn't want that to be the only choice. Seems okay as an option though. I'm curious if there's a specific reason why you want that.
<daurnimator> Tetralux: distributing software to windows... standalone .exes are *so* much easier for most people
<daurnimator> whether its because they copy/paste around the .exe and expect it to work. or they don't have permissions to install anything. or that for some reason people just swap out dlls and expect software to keep working
marijnfs has quit [Quit: WeeChat 2.4]
<Tetralux> I figured it might be something like that. Was just curious if it was a different reason :p
<Tetralux> Only reason I like having it not like that is because I can fiddle with code in the std library if I want/need to, and then revert it later.
<Tetralux> Mainly for debugging or narrowing down problems.
<Tetralux> Stuff like that.
moo has quit [Quit: Leaving]
<Tetralux> But yeah. Could be cool though. "One file. One programming language." xD
wootehfoot has joined #zig
<Sahnvour> daurnimator: you should be hyped by V then /s
<mikdusan> oh you had to go there :)
<daurnimator> Tetralux: it would be just one installation option.
<daurnimator> and 'installation' here is generous :P
<Tetralux> Yeah
<Tetralux> I gotcha.
<Tetralux> I like the idea.
<Tetralux> :)
<emekankurumeh[m]> perhaps zig will have its own std bundled in the executable and you can use --override-std-dirbti override that with a text version
<marler8997> having the zig compiler binary and standard library as separate files doesn't really bother me, but maybe it would make distribution easier for others
halosghost has quit [Quit: WeeChat 2.5]
wootehfoot has quit [Read error: Connection reset by peer]
marijnfs has joined #zig
kristoff_it has joined #zig
<marijnfs> i wish zig didn't have semicolons
<AlexMax> FireFox317: I know you're not here anymore, but I was trying to do the "zig as build system" thing first, and for whatever reason, cc was ignoring my headers when passed as -isystem but when passed as -I (by using --verbose on the build step and modifying the command line by hand)
<AlexMax> things worked just fine
<AlexMax> I know it's probably some misunderstanding of how clang handles headers, but it just seems odd to default to -isystem and give no -I option.
<AlexMax> through the use of addIncludeDir()
<marijnfs> to use the serializer, do you need to calculate the memory first?
ltriant has joined #zig
ltriant_ has joined #zig
<tgschultz> daurnimator: what's the advantage of a single exe over the current status quo of a zipped folder?
<daurnimator> tgschultz: less effort for a user; less things that can go wrong
<tgschultz> ...than unzipping a folder and putting it anywhere you want?
<daurnimator> yep.... so many people have weird workflows
<daurnimator> many projects have standalone .exe downloads for windows
<tgschultz> I'm aware of many portable (as zig is) applications, but few that are single exe unless they are simple, like putty. Considering the downside of not having immediate access to the std lib code, not to mention that it would probably have to self-extract to a temp dir anyway... it just seems like needless complication for an edge case that probably has better options.
<AlexMax> So it appears that -isystem only adds header directories for #include <foo.h> style includes, while -I adds it at the very least for #include "foo.h", possibly also #include <foo.h> as well
<marler8997> Yeah I'm pretty sure -I allows both types of includes
<marijnfs> how do i serialize to a variable buffer
<marijnfs> I'm confused by the stream system
ltriant_ has left #zig [#zig]
<daurnimator> andrewrk: good work :) almost there!
<AlexMax> Okay here is the full `zig cc` command that doesn't work
<AlexMax> I get the exact same error if I change zig cc to `clang-8` my local copy of clang
<AlexMax> (the error being some missing declarations that should actually exist)
<AlexMax> If I go in and change -isystem /home/alexmax/workspace/portmino/src to -I /home/alexmax/workspace/portmino/src, the declarations are found.
<AlexMax> .....oh no
<AlexMax> .......oh no no no no no
<AlexMax> the missing symbols are in a header called.....error.h
avoidr has quit [Quit: leaving]
<AlexMax> There's already a header called error.h
<AlexMax> Therefore, whatever system header that is loaded earlier in the zig cc line gets loaded first.
<andrewrk> result location branch: 599 out of 616 behavioral tests passing
<scientes> sweet
<andrewrk> marler8997, are you aware of the json version of the download page?
<andrewrk> I think I forgot to put a link to it anywhere
Ichorio has quit [Ping timeout: 252 seconds]
kristoff_it has quit [Remote host closed the connection]
<marijnfs> thats still copy ellision?
<AlexMax> man, i feel like a dummy
<AlexMax> still, defaulting to -isystem seems kind of like an odd choice, so I opened an issue for it
curtisf has joined #zig
curtisf has quit [Ping timeout: 256 seconds]
<andrewrk> marijnfs, yes it's https://github.com/ziglang/zig/pull/2602