ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<Sahnvour>
making progress in adding stacktrace for COFF, now I'll need to find out how/where to find the addres->source file relations
Sahnvour has quit [Quit: Page closed]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
cenomla has quit [Quit: cenomla]
Ojoshuaolson1 has joined #zig
<Ojoshuaolson1>
Zig's undocumented build system has impressive goals. Is there a good persistent place to list notable existing ones for intelligent discussion? Besides the mentions in https://github.com/zig-lang/zig/issues/204#issuecomment-291786367, I'd add Qt's Qbs, the defunct Tup, and especially build2 (build2.org/faq.xhtml).
<Ojoshuaolson1>
That issue is closed, btw. Zig forum one day? :P
<GitHub124>
[zig] andrewrk closed pull request #860: doc: fix typo and tighten wording in error sections (master...patch-1) https://git.io/vx0IY
<andrewrk>
this is unfortunate because it depends on some DLLs that ship with MSVC. But maybe that's OK for debug mode. Or maybe we try to parse pdb files
<Sahnvour>
oh, I assumed the solution would have to be in pure Zig
<andrewrk>
that would be better. unfortunately microsoft decided to provide an API for debug info instead of documenting the format
<Sahnvour>
I think they open-source'd it not so long ago to help the llvm folks
<Sahnvour>
wait, I was thinking that Zig emitted the debug information directly in some COFF section, but it's using pdb files after all ?
<andrewrk>
correct
<andrewrk>
this is provided by LLVM and LLD
<Sahnvour>
ok
MajorLag2 has joined #zig
MajorLag has quit [Ping timeout: 276 seconds]
<andrewrk>
best possible scenario: we are able to understand debug info with no external dependencies on DLLs
<Sahnvour>
indeed
<Sahnvour>
if llvm has an implementation for reading/writing this format, would it be possible to make use of it, by embedding it inside the zig compiler as some kind of builtins ?
<andrewrk>
the problem with that is that userland programs written in zig need this code embedded in them to print their own stack traces
<andrewrk>
we don't want userland programs written in zig to depend on llvm
<Sahnvour>
maybe I'm missing something but I was thinking about building it right into the zig executable (on windows), statically linked and all (given that there effectively is such a library in llvm)
<andrewrk>
so let's say it's in the zig executable. and now we have a hello world zig program which calls @panic
<andrewrk>
we build hello world with zig, and then run it
<andrewrk>
and it should print a stack trace
<andrewrk>
zig.exe is independent from helloworld.exe
<Sahnvour>
oh, right
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
MajorLag has joined #zig
MajorLag2 has quit [Ping timeout: 276 seconds]
<Sahnvour>
I'm not sure it would be doable to use the DIA lib, as it relies on COM and proprietary extensions of msvc (`__uuidof`)
<Sahnvour>
also LLVM has some documentation on the pdb format https://llvm.org/docs/PDB/index.html , I'll have a look at it to see if it helps getting started
<halosghost>
andrewrk: I'm really interested in zig; everything you're aiming at (C without the warts, manual memory management, seamless C interop, great cross compilation story) is deeply exciting
<halosghost>
I'm also super excited that 0.2.0 cleaned up a lot of the syntactic noise by replacing sigils with clearer keywords
<halosghost>
I do have a question though: is there a specific motivation for the layouting of blocks (e.g., the for loop syntax being `for (collection) |member|` instead of being some variant of `for member in collection`)?
<andrewrk>
halosghost, only to be consistent with other syntax. switching on a union(enum) unwraps the payload: Foo => |payload| {}
<andrewrk>
unwrapping a nullable or error union: if (foo()) |value| {} else |err| {}
<andrewrk>
suspending a coroutine gives you the promise handle: suspend |p| { }
<halosghost>
cool, that's an awesome reason
<halosghost>
internal consistency is very much a soft spot of mine
* halosghost
is minorly tempted to flood the zig issue tracker with all the things I desire in a language
<halosghost>
I cannot describe how excited that makes me
<andrewrk>
feel free to open as many high quality and well articulated issues as you want. I recommend searching a bit first; many ideas have been proposed and some are still open, some are closed
<halosghost>
sure
<ltr_>
nice talk andrewrk
<andrewrk>
thanks ltr_
<andrewrk>
halosghost, what project are you considering working on in zig?
<halosghost>
there's not a specific project
<halosghost>
C is the language with which I am most familiar
<halosghost>
and most of my personal projects are written in C
<halosghost>
the possibility of moving to a safer language without all the baggage that a lot of the current options offer sounds really great
<andrewrk>
cool
<andrewrk>
zig is a bit young, but the more people trying to use it the faster it will mature
<halosghost>
yeah
<ltr_>
andrewrk: what are you using for autocomplete and aid while coding?
<andrewrk>
vim and grep
<andrewrk>
it's not ideal
steveno_ has quit [Quit: Leaving]
<andrewrk>
I'm trying to get the self hosted compiler off the ground so that I can implement all the fun features there instead of in c++: doc generation, language server, multithreaded compilation, caching build artifacts, watching file system for changes and auto-rebuilding
<andrewrk>
language server being the one that is relevant to autocomplete and coding aid
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<ltr_>
thats sounds right
hoppetosse has joined #zig
davr0s has joined #zig
faa5e has joined #zig
<faa5e>
Have you considered (for recursive functions) to have functions that use the heap instead of the stack?
<faa5e>
This means that some memory is allocated before the (recusive) function is called and the memory is released after the function returns.
<faa5e>
It does mean that a function call can result in an allocation error.
<andrewrk>
faa5e, yes - in fact this is how coroutines work
<andrewrk>
the current syntax for this is
<andrewrk>
async<allocator> function()
<andrewrk>
and it returns error!promise, that is, it can either return error.OutOfMemory or the coroutine handle
<andrewrk>
and then the caller must ensure that the handle is either canceled or awaited
<faa5e>
Hi Andrew, I was just watching your presentation and heard you answer the questions about recursive functions and running out of heap.
<faa5e>
I have worked on a recursive decent parser that sometimes ran out of heap and rewrote it to one using the heap with some C++ classes.
<andrewrk>
neat! I'm working on the same thing with the self-hosted parser
<andrewrk>
the c++ parser is recursive descent but the self hosted one is a state machine
<faa5e>
(It also used goto statements for continueing after returning from a call.)
<itsMontoya>
Hey question, is there a way to handle errors without try?
<andrewrk>
hi itsMontoya
<andrewrk>
there is also `catch`
<andrewrk>
catch |err| expression
<andrewrk>
where expression can return a type that is the same as the type of the LHS of the catch ("default") or a `noreturn` type (such as calling @panic)
<andrewrk>
sorry let me give a better syntax example: foo() catch |e| expression
<andrewrk>
and then the most powerful one is `if`
<andrewrk>
if (foo()) |value| then_expression else |err| else_expression
<hoppetosse>
andrewrk: I hadn't seen the latest youtube video
<hoppetosse>
awesome!
<halosghost>
andrewrk: and blocks are expressions?
<andrewrk>
correct
<halosghost>
cool
<andrewrk>
in order to return an expression from a block you must label the block and then use `break :label value`
<Sahnvour>
I like how zig allows idioms (or plans to) that we struggle to emulate in C++ even with modern standards :)
<andrewrk>
Sahnvour, which one are you referring to?
<Sahnvour>
wrt the issue 629, this is something we're doing with "immediately invoked lambda expressions" for example
<Sahnvour>
which is already wuite convenient but do not feel like a native feature of the language
Ichorio has quit [Ping timeout: 240 seconds]
<halosghost>
andrewrk: fernuff
<andrewrk>
ah yes
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<isd>
Is there any documentation re: what syntax zig accepts for inline assembly? I'm trying to reproduce stuff I've gotten working in both C and Rust and struggling to satisfy the compiler
<andrewrk>
isd, ah I'm sorry this is a poorly documented, error prone situation right now. The best we have are examples.
<hoppetosse>
"We will have a zigfmt. It will have no configuration options"
<hoppetosse>
=)
Sahnvour has quit [Ping timeout: 260 seconds]
<isd>
Thought: I think it might make for mor readable code if @IntType took a custom enum (Signed or Unsigned) instead of a bool as it's first argument.
Sahnvour has joined #zig
<itsMontoya>
I'm getting -- Could NOT find LLVM (missing: LLVM_INCLUDE_DIRS)
<itsMontoya>
I git pulled
<itsMontoya>
and was trying to build the updated repo