ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
hopppetosse has quit [Ping timeout: 264 seconds]
Ichorio has quit [Quit: Leaving]
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 265 seconds]
acha has joined #zig
<acha> andrewrk: I just had a quick thought, instead of errdefer have you considered something like
<acha> defer when PatternMatch { }
<acha> it seems like less is baked into the language that way.
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 265 seconds]
<andrewrk> would you like to make a proposal on github?
<acha> andrewrk: not in the best position to champion the idea tbh, just thought i would offer it up for your consideration in case you like it.
<acha> I haven't really used zig at all other than reading the docs for example.
<acha> Not really sure it is a good idea, just something that crossed my mind while reading the docs.
<andrewrk> acha, what would be an example PatternMatch?
<acha> Hmm, well I was also thinking about this idea for the myrddin programming language. over there things that fail are either `Ok result, or `Err . So in myrddin it would be defer when `Err _ { }
<acha> but zig is a bit different.
<acha> I dunno if you can match on an error or nullable for example.
<andrewrk> if (expression) |value_if_ok| expression else |err_code| expression
<acha> right, ah i can see why error defers are different, they must always be the outer scope right?
<andrewrk> they can be in any scope. the errdefer expression is activated if control flow leaves the scope by returning an error from the function
<andrewrk> so, an errdefer inside a scope that has no `return` or `try` expression is dead code
<acha> got it.
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 252 seconds]
cenomla has joined #zig
<andrewrk> gonna merge error sets in a few minutes
acha has quit [Quit: Page closed]
<GitHub178> [zig] andrewrk opened pull request #759: Error Sets (master...error-sets) https://git.io/vAkMi
cenomla has quit [Quit: cenomla]
<GitHub100> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAkSf
<GitHub100> zig/master 5911962 Andrew Kelley: Merge pull request #759 from zig-lang/error-sets...
<GitHub63> [zig] andrewrk closed pull request #759: Error Sets (master...error-sets) https://git.io/vAkMi
<GitHub60> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAk9U
<GitHub60> zig/master 2c697e5 Andrew Kelley: appveyor: don't try to build for mingw...
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 276 seconds]
Hejsil has joined #zig
<Hejsil> Uuuuh error sets. Time for another syntax refactor!
<Hejsil> andrewrk, so this is the intended way of getting a functions error set? @typeOf(foo).ReturnType.ErrorSet
dd3 has joined #zig
dd3 has quit [Ping timeout: 276 seconds]
dd3 has joined #zig
dd3 has quit [Ping timeout: 256 seconds]
jfo has joined #zig
jfo has quit [Client Quit]
cratuki has joined #zig
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 255 seconds]
hoppetosse has joined #zig
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 276 seconds]
hopppetosse has joined #zig
hopppetosse has quit [Remote host closed the connection]
hopppetosse has joined #zig
hoppetosse has quit [Ping timeout: 240 seconds]
hopppetosse has quit [Ping timeout: 260 seconds]
zesterer has joined #zig
<zesterer> What's the status of the ambiguous return problem so far?
zesterer has quit [Remote host closed the connection]
zesterer has joined #zig
<zesterer> I've been thinking, and the simplest, most elegant fit for this problem I can see is to add an equals before the function body like: "fn foo(b: Bar) void = {}"
<zesterer> Really, if a Zig-ish syntax is wanted, it should be: "cont foo: fn (b: Bar) void = {}"
zesterer has quit [Remote host closed the connection]
zesterer has joined #zig
zesterer has quit [Client Quit]
zesterer has joined #zig
hasen_judy has joined #zig
zesterer_ has joined #zig
zesterer has quit [Ping timeout: 248 seconds]
zesterer_ is now known as zesterer
zesterer has quit [Client Quit]
zesterer has joined #zig
hasen_judy has quit [Remote host closed the connection]
hasen_judy has joined #zig
zesterer has quit [Remote host closed the connection]
hasen_judy has quit [Remote host closed the connection]
zesterer_ has joined #zig
<MajorLag_> Isn't the ambiguous return syntax only a problem if you remove the return specification requirement?
<MajorLag_> I see. Hadn't really considered that since empty struct literal as a return type never occurred to me, and I know basically nothing about the new error sets stuff
<zesterer_> MajorLag_: AFAIK, it's still a problem since it may affect more than just error sets
<MajorLag_> I can see that, with the example case being returning A{} as an empty struct literal, I just think that's so edge case that (A{}) is perfectly acceptable.
<MajorLag_> Error sets are less edge case I imagine
<MajorLag_> "cont foo: fn (b: Bar) void = {}" looks right to me.
<Hejsil> Does that mean that any block can implicitly cast to a function?
<Hejsil> Can I do { ... }()?
<Hejsil> Aka, call a block
<Hejsil> Or maybe (fn (b: bar) void)({ ... })()
<SimonNa> calling function literal immediately, it's handy in D occasionally: immutable x = { ...some code... return y; }();
<Hejsil> Well, we have blk: { break :blk 4; }, so that is not needed in Zig
<SimonNa> hmm
<MajorLag_> It would be nice to unify the syntax though.
<SimonNa> I agree with the judgement that const ... = { ... } suggests that such blocks are flexible literals
Hejsil has quit [Quit: Page closed]
<zesterer_> Is making them flexible literals a problem? It would be nice to throw around code block as if they're closures, but it does somewhat undermine Zig's focus on simplicity
zesterer_ has quit [Quit: zesterer_]
Jezza has joined #zig
<MajorLag_> Something like this? https://pastebin.com/08288KTw
<MajorLag_> If tuples also happen, you could allocate a tuple of whatever you wanted to capture and pass that as the capture.
sdf82882 has joined #zig
hasen_judy has joined #zig
<sdf82882> Hi! I need a programming language I can easily call from C++ code (which is not C or C++, which I don't like very much). Would I be able to use zig for this? Just asking before starting learning the whole language
<GitHub154> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAI6O
<GitHub154> zig/master 3919afc Andrew Kelley: fix crash with error peer type resolution...
hasen_judy has quit [Ping timeout: 252 seconds]
<andrewrk> sdf82882, yes, it's a perfect fit, see for example http://tiehuis.github.io/iterative-replacement-of-c-with-zig
<andrewrk> sdf82882, the only reason you might not do it is that zig is still at an early beta version and not stable yet
<sdf82882> I don't really care about that, it's a personal project, and it's going to be small enough at first that rewriting it in another language if I encounter any stopper wouldn't be the end of the world, andrewrk, thanks
<andrewrk> sdf82882, sounds fun, let me know if you run into any issues and I'll try to sort them out quickly for you
<sdf82882> The first thing we will change is replacing the Makefile with zigs own custom build system. The build system of zig is written in zig itself, which reduces the requirement of knowing the oft-arcane Makefile idiosyncrasies.
<sdf82882> This might be a problem, since the makefile I have is autogenerated by a tool of the framework I'm using, and it's complex enough that I wouldn't want to (or know how to) translate it by hand
<andrewrk> that's optional, of course
<andrewrk> you can also call zig from a makefile
<sdf82882> Oh, I see the verbose output and it seems what it's doing is pretty straightforward, cool
<sdf82882> yeah, looks exactly what I need, thanks
Hejsil has joined #zig
return0e has joined #zig
return0e_ has quit [Read error: No route to host]
arBmind has joined #zig
<sdf82882> andrewrk, is the full documentation the place to learn the language right now? I was looking at some examples, like https://github.com/zig-lang/zig/blob/master/example/guess_number/main.zig, but I can't ctrl+f anything about the "try" syntax in the documentation
<sdf82882> any "gentler" introduction?
<Hejsil> There currently is a difference in how errors are handled between 0.1.1 and master. Documentation for master has information on try http://ziglang.org/documentation/master/
<Hejsil> guess game is using the master syntax
<MajorLag_> try is in the Error section.
<sdf82882> Thanks, Hejsil, I was looking at the 0.1.1
<andrewrk> hi Hejsil
<Hejsil> Yo
<andrewrk> sdf82882, we're pretty close to 0.2.0 release - I recommend a master build and docs at this point
<sdf82882> andrewrk, that's what I'm studying from right now, so that's good
<Hejsil> andrewrk, Did @memberIndexByTag or @memberTag make it in with error sets? https://github.com/zig-lang/zig/issues/632#issuecomment-350305401
<andrewrk> Hejsil, ah, no, let's open separate issues for those
<andrewrk> Hejsil, I'm not sure how @memberTag would work actually. I think you just can do usize(error_value) for that
<andrewrk> oh, @memberTag would take a field index and return the error value
<andrewrk> anyway, yeah, let's get those reflection features going if you need them, feel free to open issues
hoppetosse has joined #zig
sdf82882 has quit [Quit: Page closed]
Jezza has quit [Ping timeout: 260 seconds]
<GitHub119> [zig] andrewrk pushed 2 new commits to master: https://git.io/vAINi
<GitHub119> zig/master e7bf8f3 Andrew Kelley: fix compiler crash switching on global error with no else
<GitHub119> zig/master 1fb308c Andrew Kelley: self hosted compiler: move tokenization and parsing to std lib
<Hejsil> How would this @field actually work?
<Hejsil> I would assume it can only get the value of constant members in struct/unions, and error set/enum tags
dd3 has joined #zig
hoppetosse has quit [Ping timeout: 256 seconds]
hoppetosse has joined #zig
dd3 has quit [Ping timeout: 256 seconds]
Jezza has joined #zig
hoppetosse has quit [Ping timeout: 256 seconds]
<andrewrk> Hejsil, it's the same as `a.b` except `b` is a comptime string
<andrewrk> so it's pretty powerful
<Hejsil> Aaah, ok. Was just mislead by the T parameter
<andrewrk> ah, yeah, poor name choice
<MajorLag_> That'll be a huge improvement on string matching against @memberName
<andrewrk> should save you a few @setEvalBranchQuota branches :)
skyfex has joined #zig
<skyfex> andrewrk: I was wondering, is there a timeline to have the self hosting compiler replace the C++ version? do you expect to stop development of the C++ version at some point?
<andrewrk> skyfex, it will always be in the source tree and be part of the build process
<andrewrk> but I do plan for some features to only be available in the self hosted compiler
<andrewrk> as for timeline... the road is open. full speed ahead
<andrewrk> the milestone is 0.2.0 which means that it's prioritized over everything in 0.3.0 and beyond
cratuki has left #zig [#zig]
hoppetosse has joined #zig
davr0s has joined #zig
Hejsil has quit [Read error: Connection reset by peer]
hoppetosse has quit [Ping timeout: 265 seconds]
<GitHub76> [zig] bnoordhuis opened pull request #768: document when to use error!type in function decl (master...func-decl-error) https://git.io/vALWd
hoppetosse has joined #zig
hoppetosse has quit [Ping timeout: 268 seconds]
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 276 seconds]
Jezza has quit [Ping timeout: 240 seconds]
<GitHub7> [zig] andrewrk pushed 1 new commit to master: https://git.io/vALBf
<GitHub7> zig/master a2bd9f8 Andrew Kelley: std lib: modify allocator idiom...
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]