ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
noonien has quit [Quit: Connection closed for inactivity]
isd has joined #zig
<MajorLag> andrewrk, with just a small modification to std.format, this is possible: https://paste.ubuntu.com/p/CWQzSs8V7Y/
<MajorLag> It could be improved if I could pass v.format, so then a type could have multiple formaters, and b) could be named whatever the programmer wants. However, the compiler wants the variable to be comptime if I try that.
isd has quit [Ping timeout: 264 seconds]
isd has joined #zig
<andrewrk> MajorLag, I like this idea of std.fmt.format looking for a special function name and calling it if it exists to provide a custom formatter
<andrewrk> is that what the "catching" of a compile error would be for? checking if a method exists?
<MajorLag> pretty much yeah. Then you wouldn't need to tell fmt that it should call it, it could just do it. I'm not sure if that's better though.
<andrewrk> I'll extend the reflection support enough to make this work
<andrewrk> without the catching a compile error thing
<MajorLag> By adding a way to introspect namespaces/empty structs? That'd be slick.
<andrewrk> yes
<Tobba> MajorLag: I mean, that's the whole fun part of having proper meta-typing
<Tobba> andrewrk: (unrelated) out of curiosity, do you have any plans wrt quasi-quotation in zig?
<andrewrk> what's that? messing with the AST?
<Tobba> being able to "quote" expressions/statements or raw lists of tokens; such that you can read them at compile time
<andrewrk> and then eval them right?
<Tobba> that, or with a plain token list, you could conceivably parse them to implement something like the struct keyword as a comptime function
<andrewrk> I'd have to see a really convincing use case for that. It's one of those things where it can be easily abused and make a codebase difficult to read
<Tobba> (afaik "quasi-quotation" usually refers to the simple token list variant, but I'm halfway sure it can refer to either)
<Tobba> oh that's very true
<Tobba> there's at least a neat aspect of being able to manipulate both expressions and token lists at compile time; that you could conceivably expose the whole parser as a plain comptime function
<Tobba> but that's not exactly a practical use case
<andrewrk> the tokenizer and parser is already exposed in the standard library; one could call it at compile time
<Tobba> oo, neat (is there a list of everything included in the standard lib somewhere?)
<MajorLag> Source for the standard lib is the only thing I know of.
<andrewrk> that's right. generated documentation is pending more progress on the self hosted compiler
<Tobba> figured
<Tobba> DSLs aren't always bad for readability though, if used responsibly
return0e has quit [Ping timeout: 276 seconds]
<Tobba> I'm curious if there's a nice inbetween somewhere
return0e has joined #zig
<Tobba> i.e for dealing with shader uniforms with OpenGL or setting up networking tables for a game
<Tobba> also, quasi-quotation of token lists gets a whole lot less messy if you match up brackets during lexing and have the tokens behave as a tree (I might've mentioned this before); doesn't really affect the readability concern though
<Tobba> in theory that makes it a lot easier to generate good errors when hitting mismatched brackets too
isd has quit [Quit: Leaving.]
<hobomatic> So what are the semantics of the 'var' type? from what I have been able to intuit, its like an expression that is spliced in at compile time
<andrewrk> hobomatic, there is no var type - that's a syntactic construct that is only valid as a parameter placeholder or a return type placeholder, to make the function infer the type
<andrewrk> maybe "auto" is a better word
<hobomatic> ah, ok
<MajorLag> or "any"
<hobomatic> another naive question, what is the purpose of std.empty_import?
<andrewrk> hobomatic, it's used by std/c/index.zig
<hobomatic> ah OK makes sense.
accidental has joined #zig
sand-witch has quit [Remote host closed the connection]
sand-witch has joined #zig
sand-witch has quit [Remote host closed the connection]
sand-witch has joined #zig
accidental has quit [Quit: Leaving.]
sand-witch has quit [Remote host closed the connection]
sand-witch has joined #zig
_whitelogger has joined #zig
cenomla has quit [Quit: cenomla]
sand-witch has left #zig ["Leaving"]
Ichorio has joined #zig
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
ullabj0rn has joined #zig
ullabj0rn has quit [Client Quit]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
sand-witch has joined #zig
<sand-witch> andrewrk: Hey, since you created libsoundio.. I've been trying out LabSound (3d audio, forked from chrome/webkit web audio API). I fiddled with its cmake to get it compiling on Linux, only now I'm getting errors from RtAudio via stdio.
<sand-witch> Is this what you were referring to when you listed "Errors are communicated via return codes, not logging to stdio." as one of libsoundio's features?
<sand-witch> Or was it yet another library that you were referring to?
Sahnvour has joined #zig
Sahnvour has quit [Client Quit]
sand-witch has quit [Remote host closed the connection]
sand-witch has joined #zig
gazatu has joined #zig
<gazatu> yo
<gazatu> i just wanted to ask if there is a workaround for following error: "LLVM ERROR: cannot move instruction since its users are not dominated by CoroBegin"
<gazatu> i also get this kind of error: "Call parameter type does not match function signature! %Allocator* %1 %StackTrace* %8 = call fastcc i8* @__zig_coro_alloc_helper(void ({ i16, %"[]u8" }*, %StackTrace*, %Allocator*, i64, i29)* %7, %Allocator* %1, %Allocator* %1, i16* %2, i64 120), !dbg !2403 LLVM ERROR: Broken function found, compilation aborted! LLVM ERROR: IO failure on output stream: invalid argument"
s455wang has joined #zig
Sahnvour has joined #zig
gazatu has quit [Quit: Page closed]
mattw has joined #zig
davr0s has joined #zig
davr0s has quit [Ping timeout: 240 seconds]
Sahnvour has quit [Quit: Page closed]
mattw has quit [Ping timeout: 260 seconds]
cenomla has joined #zig
mattw has joined #zig
mattw has quit [Ping timeout: 260 seconds]
<andrewrk> sand-witch, yes. alsa-lib is also guilty
<andrewrk> gazatu, I'm working on that right now
<andrewrk> I believe that is https://github.com/zig-lang/zig/issues/821
cenomla has quit [Quit: cenomla]
yoyoyo has joined #zig
yoyoyo has quit [Client Quit]
cenomla has joined #zig
<hobomatic> there is no multiline comment syntax, right?
<hobomatic> also, i notice that the parser/lexer doesn't like tabs as whitespace
<andrewrk> hobomatic, correct
<andrewrk> zig has line-independent tokenization
<andrewrk> hard tabs as whitespace: https://github.com/zig-lang/zig/issues/544
davr0s has joined #zig
<hobomatic> I see, yeah i can definitely understand wanting to keeping complexity out of the tokenizer and letting/requiring editors to do editor things.
<andrewrk> I might relax the tab restriction once we have zig fmt (it would allow tabs but change them into spaces)
<MajorLag> andrewrk, is there a way to import a file from a folder in a package that isn't the index? Specifically, I need a syscall that isn't in os.linux, and the number is defined in linux.arch, which isn't pub (why not?). As far as I can tell, I can't even switch on builtin.arch and import myself because there's no way to get at the arch.zig files without either copying them locally or specifying the full path.
<andrewrk> MajorLag, this is the same question as "can I access non-public stuff even though it's supposed to be private?" - which is to say - it's often the case that the API designer failed to make enough things public
<andrewrk> can I just fix the API for you? :)
<MajorLag> yeah, I mean, I guess that's the real problem here.
<MajorLag> I sometimes rathole on workarounds.
<andrewrk> I think std.os.linux should have the syscall1, syscall2, etc functions exposed. would that solve the problem?
<andrewrk> and the syscall numbers
<MajorLag> doesn't look like there's anything in <arch>.zig that shouldn't be exposed.
<MajorLag> so just making linux.arch pub would be great
<andrewrk> on it
<andrewrk> I'm starting to think that maybe the default should be public, and you have to use a keyword to make things private
<MajorLag> I do find myself writing "pub" automatically a lot.
<andrewrk> running tests and then pushing
<andrewrk> feel free to make a PR adding some syscalls to the std lib btw
<MajorLag> I'll probably do that for any I run into. And associated constants.
<andrewrk> musl libc source code is really useful for this
<MajorLag> I'll check that out. I've actually been looking at a combination of Go's syscall package and whatever google turns up which is unfortunately often mixed in with glibc as though the syscall interface isn't independent.
<andrewrk> I think you'll be pleasantly surpised with musl how clean and simple it is
<andrewrk> tests passed
<MajorLag> I remember a similar issue with fuse. Lots of documentation on using the fus library, pretty much none on fuse itself.
<GitHub197> [zig] andrewrk pushed 1 new commit to master: https://git.io/vxRTQ
<GitHub197> zig/master 2cff319 Andrew Kelley: std.os.linux exposes syscall functions and syscall numbers
<MajorLag> thanks.
cenomla has quit [Quit: cenomla]
accidental has joined #zig
accidental has left #zig [#zig]
isd has joined #zig
arBmind has joined #zig
_whitelogger has joined #zig
Ichorio has quit [Ping timeout: 264 seconds]
<sand-witch> I agree with public by default
<andrewrk> that's kinda why I've been dragging my feet on enforcing "pub" for fields
Sahnvour has joined #zig
so has joined #zig
<sand-witch> One thing I don't find very intuitive is the import/namespace system. I don't think it's positive that people shave off the root part of the namespace and leave the less significant child namespace, or even rename them to their liking during import. I am pretty fond of the c++ system where by default you use whatever namespacing the library author designed, and they tend to be very flat. But that's really all I've known for a
<sand-witch> long time now, so I might be wrong.
<sand-witch> Maybe C++ doesn't require as many namespaces due to function overloading, but then on the other hand you have C which has no namespaces so I don't know.
<andrewrk> sand-witch, one if the big reasons for status quo is that you know where every identifier comes from
<andrewrk> often in c or c++ you have trouble figuring out where something is defined
isd has quit [Ping timeout: 276 seconds]
<sand-witch> yes that's true. And looking at the zig std library right now I see that the functions are named differently to take advantage of this system. So they are shorter like mem.eql, mem.set, etc
<GitHub150> [zig] andrewrk pushed 3 new commits to master: https://git.io/vxRsH
<GitHub150> zig/master 897e783 Andrew Kelley: add promise->T syntax parsing...
<GitHub150> zig/master 18af2f9 Andrew Kelley: fix async fns with inferred error sets...
<GitHub150> zig/master b1c07c0 Andrew Kelley: move error ret tracing codegen to zig ir...
<sand-witch> some* :) (where it makes sense)
isd has joined #zig
<andrewrk> sand-witch, if you feel strongly about the importing system, the best thing you can do is create a proposal as a github issue, and suggest an alternative to status quo that is well-reasoned and convincing, with code examples
<andrewrk> that said I'm always open to feedback even if you don't have an alternative suggestion
<andrewrk> another thing to consider is that zig does not allow identifier shadowing at all. so ability to rename things when importing is important
<Sahnvour> hi, I discovered Zig a few days ago and since I don't have specific project ideas to play with it, was wondering if there are accessible tasks to learn and contribute to it
<andrewrk> hi Sahnvour
<andrewrk> there is a "help wanted" label on github which may be interesting to you
<andrewrk> perhaps also the "userland" label
<andrewrk> one example would be a deflate / inflate implementation in the standard library
<Sahnvour> thanks, I'll have a look
<Sahnvour> btw, my main machine is on windows, do you think https://github.com/zig-lang/zig/issues/721 is going to be fixed any time soon ?
<andrewrk> I'm not working on it at the moment. That actually might be a nice issue for you to work on if you're intested in contributing
<Sahnvour> I feel like it would be useful, but have no idea how these things work under the hood at the moment so I may not be anywhere near efficient