ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
hasen_judy has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hoppetosse has quit [Ping timeout: 255 seconds]
cenomla has joined #zig
davr0s has joined #zig
<GitHub179> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAYHe
<GitHub179> zig/master dfbb825 Andrew Kelley: fix self hosted tokenizer handling of EOF
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
Hejsil has joined #zig
Tobba has quit [Ping timeout: 256 seconds]
Hejsil has quit [Client Quit]
arBmind has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
cenomla has quit [Quit: cenomla]
arBmind has quit [Quit: Leaving.]
<vegard> -- Could NOT find CLANG (missing: CLANG_LIBRARIES CLANG_INCLUDE_DIRS)
<vegard> oops. I get that ^ when I run the cmake command from the readme
<vegard> I have installed clang and libclang-dev
lqd has quit []
lqd has joined #zig
<vegard> alright, looks like I needed llvm-5.0 and clang-5.0 on ubuntu
<vegard> /home/vegard/git/zig/deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp: In function ‘llvm::Error lld::mach_o::{anonymous}::processSection(lld::DefinedAtom::ContentType, const lld::mach_o::normalized::Section&, bool, const lld::mach_o::normalized::NormalizedFile&, lld::mach_o::MachOFile&, bool, bool)’:
<vegard> /home/vegard/git/zig/deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:487:21: error: ‘size’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
<vegard> offset += size;
monteslu has quit []
monteslu has joined #zig
hoppetosse has joined #zig
<vegard> there's a few more, gonna pass -Wno-error=maybe-uninitialized in CXXFLAGS for now
<vegard> and -Wno-error=strict-aliasing ...
<vegard> it works.
Hejsil has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<vegard> andrewrk: echo -n '||=' > test.zig && ./zig build-obj test.zig
Hejsil has quit [Ping timeout: 260 seconds]
Hejsil has joined #zig
Hejsil has quit [Quit: Page closed]
arBmind has joined #zig
t4nkf33der has quit []
t4nkf33der has joined #zig
hoppetosse has quit [Ping timeout: 240 seconds]
hoppetosse has joined #zig
<andrewrk> vegard, what version of what compiler gives those errors?
cgag has quit []
cgag has joined #zig
<vegard> zig latest git master, my g++ is g++ (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904
<andrewrk> good to know. I've been testing with g++ 6.4.0
<andrewrk> the self hosted zig compiler handles '||=' just fine :)
<GitHub61> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAO7u
<GitHub61> zig/master 2dcff95 Andrew Kelley: self hosted: add tokenizer test fix eof handling
<andrewrk> does it fix it if you replace create with the `new` operator?
<vegard> yes.
<andrewrk> this is problematic, because we don't want exceptions, and new can throw std::bad_alloc
hasen_judy has quit [Remote host closed the connection]
hasen_judy has joined #zig
Hejsil has joined #zig
hasen_judy has quit [Ping timeout: 252 seconds]
<andrewrk> ah, we can use new(std::nothrow)
Thalheim has quit [Quit: leaving]
<GitHub71> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAObr
<GitHub71> zig/master 02f70cd Andrew Kelley: zig_llvm.cpp uses new(std::nothrow)...
<andrewrk> vegard, fixed ^
<vegard> cool, good job :-)
<vegard> the ||= is supposed to be fixed too?
<andrewrk> make install && bin/zig build --build-file ../build.zig --prefix $(pwd)/stage2 install && stage2/bin/zig fmt test.zig
<andrewrk> test.zig:1:1: error: expected variable declaration or function, found Pipe
<vegard> I still get segfault with this after pulling: make zig && echo -n '||=' > test.zig && ./zig build-obj test.zig
<GitHub165> zig/master c721354 Andrew Kelley: correct doc comment in self hosted parser
<GitHub165> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAOpS
<MajorLag_> So about that deref operator. `$` isn't unprecedented and is apparently not a big deal to type on international keyboards. It is however ugly.
<andrewrk> $ is less of a deal than ^ ?
<MajorLag_> apparently quite a bit, yes
<andrewrk> good to know
<andrewrk> just throwing out one other option here.
<MajorLag_> yeah, I'm not wild about `$`, just thought I'd mention it
<andrewrk> 1. change all @ to $. 2. use @ for address-of. 3. use '&' for pointer-to-a-single-thing
<andrewrk> (keep * deref)
<andrewrk> if you think about the * thing, the item inside [] indicates how many bytes long the block is
<andrewrk> originally I meant [*] as "could be anything! you don't know how many"
<MajorLag_> That could work. Though $typeOf is going to feel like a variable to people used to shell languages. # isn't available for that is it?
<andrewrk> but if * is the poniter-to-single-thing, then [*] kinda means "the length of the block is a pointer"
<andrewrk> # could be available too
<andrewrk> #import #typeOf #"identifier"
<andrewrk> traditionally # means you're giving some info to the compiler too, so that's not bad
<MajorLag_> unfortunately `?` already has a meaning in Zig. [?]
<andrewrk> yeah that's what I thought of first
<Hejsil> [_] maybe then?
<andrewrk> for pointer to anything?
<andrewrk> oops I mean for pointer to block of unknown size?
<Hejsil> Yes
<MajorLag_> _ could be an identifier... well, except you're considering making _ mean "ignore me"
<Hejsil> _ is not an identifier as far as I know
<Hejsil> _ = 5 is valid, even if _ is not declared
<Hejsil> So I would assume it's a special thing
<MajorLag_> actually it already does mean that doesn't it? _= sdl.SDL_UpdateTexture(...
<andrewrk> yeah it's special
<MajorLag_> hmm... [_] would sorta mean "ignore the length" then I guess.
<andrewrk> I think [*] is fine for pointer to block of any length
<MajorLag_> well certainly I prefer it, but we are spitballing
<andrewrk> it's basically * from C except 2 extra characters to punish you for not using a better type
<MajorLag_> I'm curious how translate-c will handle this. Just assume all pointers are [*]null ?
<andrewrk> not the null part
<andrewrk> it's the worst possible thing, [*] for everything
<andrewrk> and we won't even support field access of a [*]Struct, you'll have to cast it to & (or whatever the single pointer type is)
<andrewrk> well it's not bad: foo[0].field
<andrewrk> not cast, but access an index.
<andrewrk> oh, it's ?[*] too
<MajorLag_> yeah that makes sense.
<andrewrk> (??foo)[0].field
<andrewrk> there *is* an annotation you can put on pointers in .h files that marks pointers as non null, and translate-c respects it
<andrewrk> but it's uncommon
<MajorLag_> these sorts of measures make sense when interacting with C in my opinon.
<andrewrk> agreed
<andrewrk> it would be nice if there was some way we could know that, e.g. printf wants a [*]null though
<MajorLag_> Zig already has the most painless interaction with C I've seen outside of C.
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 255 seconds]
sient has joined #zig
<vegard> andrewrk: echo -ne '@"\' > unreachable.zig && ./zig build-obj unreachable.zig
<andrewrk> vegard, the c++ compiler only has to be able to build the self hosted compiler
Ichorio has joined #zig
<andrewrk> vegard, make install && bin/zig build --build-file ../build.zig --prefix $(pwd)/stage2 install && stage2/bin/zig fmt unreachable.zig
<andrewrk> unreachable.zig:1:1: error: expected variable declaration or function, found Invalid
<vegard> oh, okay.
<andrewrk> it still can be fixed, just low on my priority list :)
<andrewrk> MajorLag_, things like the argument to libc `puts` should be `[*]null const u8` instead of `?[*] const u8` is one reason that we have @import("std").c
<andrewrk> I think it would make sense to just put all the libc prototypes in there, to get the better APIs
<andrewrk> plus, we're going to need that anyway for zig's libc implementation
<andrewrk> once we have our own libc we're going to rock the cross compilation world
<MajorLag_> I don't do a lot of cross compilation, so I guess I don't follow?
davr0s has joined #zig
hoppetosse has quit [Ping timeout: 256 seconds]
<andrewrk> say you're making a game, and you want it to work on linux and windows
<andrewrk> and it depends on zlib and libpng
<andrewrk> once we have our own libc, you'll be able to actually build zlib and libpng, with zig, for both targets, no matter which target you're developing on
<andrewrk> `zig build` in your game's repo will be able to do everything
<andrewrk> zig libraries will be able to depend on c libraries, without a dependency on a system C compiler
<andrewrk> the less things you require people to manually install, the more useful zig libraries can be
<MajorLag_> So the Zig libc implementation would literally replace libc. So would libpng/zlib object files be lniked against Zig-libc and my code, or would libpng/zlib get built using translate-c and the Zig-libc?
<andrewrk> if you opted into this, libpng/zlib would be linked against zig-libc, and your code linked against zig-libc as well
<andrewrk> but then implementations would ultimately be the same, e.g. if you used the libc allocator, or if you used the zig default general purpose allocator, it would be the same thing
<MajorLag_> But I still would have no requirement for a C environment, which is wicked cool.
<andrewrk> yeah that's the idea
<andrewrk> the implementation would be mostly a port of musl
<andrewrk> which is what we've already done for e.g. std.math
<andrewrk> and musl is gaining popularity recently with docker and alpine linux
<andrewrk> so we'd actually have pretty decent compatibility with popular libraries
<andrewrk> and then port wine for the windows parts of libc
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
clownpriest has joined #zig
andrewrk has quit [Quit: ZNC - http://znc.in]
Ichorio has quit [Quit: Leaving]
dd3 has joined #zig
dd3 has quit [Ping timeout: 256 seconds]
arBmind has quit [Quit: Leaving.]
vegard has quit [Quit: Lost terminal]
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 252 seconds]
andrewrk has joined #zig
<Hejsil> andrewrk, found a fun bug :)
<Hejsil> Have opened an issue
hoppetosse has joined #zig
cenomla has joined #zig
hasen_judy has joined #zig
redj has joined #zig
hasen_judy has quit [Ping timeout: 255 seconds]
<andrewrk> Hejsil, goodness
<andrewrk> thanks
<Hejsil> Hit that on a refactor of some code. Good thing it wasn't to hard to find, as I was aware I needed to change the function signatures
<andrewrk> yeah I'm really sorry that is quite a nasty bug
tridactyla has quit [Remote host closed the connection]
<MajorLag_> Oh neat, you can use comptime type creation to instead create a namespace. For example, to only write a bunch of math functions once and create f32 and f64 versions.
hopppetosse has joined #zig
<andrewrk> yep. you can also accept f32 or f64 as a comptime parameter
<andrewrk> I guess you already knew that and prefer the namespace way of organizing. that's neat, I hadn't thought of that
tridactyla has joined #zig
hoppetosse has quit [Ping timeout: 256 seconds]
Hejsil has quit [Read error: Connection reset by peer]
dd3 has joined #zig
clownpriest has quit [Ping timeout: 256 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hopppetosse has quit [Ping timeout: 240 seconds]
hopppetosse has joined #zig
<MajorLag_> yeah, but if I wrote it like: lerp(comptime T: type, s: T, e: T, x: T) T then I would always have to pass the type in when calling it.
<MajorLag_> this way I can just import it: const interpolate = @import("interpolate.zig").Create(f32);
<andrewrk> yeah that's pretty nifty
<MajorLag_> then I can call any interpolation in the library with the specified type.
<MajorLag_> I don't know if you caught Jon's library stream, but he was talking about a similar concept for Jai. Zig already has it, it turns out.
<andrewrk> I didn't catch it
<andrewrk> any other interesting nuggets?
aiwakura has quit [Ping timeout: 260 seconds]
<MajorLag_> It was a while ago. Um... He talked about different ways they might do things like add a type to "Print", you know, register handlers for things at comptime. I'm sure I'm forgetting a lot.
hasen_judy has joined #zig
dd3 has quit [Ping timeout: 240 seconds]
<andrewrk> ah I've thought about that
<MajorLag_> I can think of a way to accomplish it in Zig today, I think.
<MajorLag_> Taking fmt as an example, you'd have it first see if the type was a struct and contained a function with the right signature (or name), then call that with the flags between "{}"
<MajorLag_> If it didn't, fallback to normal behavior
<andrewrk> that's a nice idea
<andrewrk> one crazy thing I just thought of, format could take a namespace (@import) as a special arg, e.g. "{@}" and that arg isn't printed, instead it's expected to have a comptime function that can override printing for different types
<andrewrk> and then in that format, after that arg, it checks that comptime function first to see if it has an override
<andrewrk> so you could even kinda change the default printing for ints and non-structs using this strategy
<MajorLag_> Yeah, that seems totally doable.
<andrewrk> a comptime string arg such as the format arg is really a Domain Specific Language
<andrewrk> you can pretty much do anything as long as it doesn't call external functions or os api
<MajorLag_> Behind the scenes, is there any difference between a struct and a namespace? Are structs a superset of namespace?
<andrewrk> they're implemented differently, but in practice an empty struct is the same thing as a namespace
<MajorLag_> the Create() I mentioned above is implemented as returning an "empty" struct full of function pointers. I use them pretty interchangeably.
<MajorLag_> er, not pointers
<MajorLag_> specifically not pointers
<MajorLag_> I could even extend it to do some basic reflection on struct types and make educated guesses as to what the importer wanted. Like, it's a struct full of f32 members, or an array of such, so it is probably a vector. That's overengineering though.
<MajorLag_> Or I could get really crazy: const interpolate = @import("interpolate.zig").Create(ComplexStruct, "memberName", "member2Name", "member3Name"); specifying which members to perform interpolation on for that type.
<andrewrk> MajorLag_, this is why I think we don't need macros
<MajorLag_> I would have to agree. There's very little I think I couldn't do with comptime. There are probably a lot of language features that could be implemented in "std" if one were inclined.
<MajorLag_> Did you add the ability to call nakedcc if they're (void)void? if so I might take another crack at computed jumps.
<MajorLag_> it occurs I could have also used inline maybe.
<andrewrk> I don't remember. I'll have to get back to you on that, I'm about to be busy for the evening