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/
kllr_sbstn has joined #zig
kllr_sbstn has quit [Ping timeout: 240 seconds]
kllr_sbstn has joined #zig
kllr_sbstn has quit [Ping timeout: 250 seconds]
kllr_sbstn has joined #zig
<andrewrk> thanks to LemonBoy we're actually pretty close to tier 1 support for 32-bit windows
kllr_sbstn has quit [Ping timeout: 240 seconds]
<marler8997_> if the path in --pkg-begin name path doesn't exist, should zig fail?
return0e has joined #zig
return0e has quit [Ping timeout: 276 seconds]
n_1-c_k has quit [Read error: Connection reset by peer]
n_1-c_k has joined #zig
kllr_sbstn has joined #zig
kllr_sbstn has quit [Client Quit]
waleee-cl has quit [Quit: Connection closed for inactivity]
<andrewrk> marler8997_, I think that zig should not try to open a file until it is needed
chemist69 has quit [Ping timeout: 276 seconds]
chemist69 has joined #zig
return0e has joined #zig
return0e has quit [Ping timeout: 265 seconds]
tdeo has joined #zig
uranther has joined #zig
<marler8997_> ok fair enough
<marler8997_> watching the update vid...looking at the docs I though you had added var as a return type :)
mahmudov has quit [Remote host closed the connection]
ltriant has quit [Quit: leaving]
return0e has joined #zig
Ekho- has joined #zig
jmiven_ has joined #zig
return0e has quit [Ping timeout: 268 seconds]
Ekho has quit [Remote host closed the connection]
jmiven has quit [Ping timeout: 245 seconds]
kurufu has quit [Ping timeout: 245 seconds]
bgiannan has quit [Ping timeout: 245 seconds]
bgiannan has joined #zig
kenaryn has joined #zig
<kenaryn> Hello, please what is the difference(s) between a public function and an extern function? I know other files have both access to it but I do not know the discrepancy there certainly is.
n_1-c_k has quit [Read error: Connection reset by peer]
n_1-c_k has joined #zig
<kenaryn> Formulated in another way, the extern function is used as an API, but why the public one can not?
LargeEpsilon has joined #zig
SimonNa has quit [Remote host closed the connection]
<daurnimator> kenaryn: 'extern' means follows the C ABI.
<daurnimator> huh. looks like we don't have a section in the manual about functions
<daurnimator> i.e. what `export` keyword vs `extern` keyword mean
<daurnimator> oh we do... but only as a block of code. https://ziglang.org/documentation/master/#Functions
<daurnimator> `extern fn internalName() void {}` => this usage of extern doesn't seem to match up with the definition of "The extern specifier is used to declare a function that will be resolved at link time, when linking statically, or at runtime, when linking dynamically."
<daurnimator> most of the other usages of `extern` are just for a function prototype; whereas the above example has an (empty) body
pushqrdx has joined #zig
<bgiannan> How can i print a string coming from a c api?
<bgiannan> i did that but it's unsafe: `sdl.SDL_GetError()[0..100]`
<daurnimator> bgiannan: first turn it into a slice (mem.len)
<bgiannan> ah thx
pushqrdx1 has joined #zig
pushqrdx1 has quit [Client Quit]
<daurnimator> we should really have a function in the std lib that takes a c string pointer and returns a slice...
pushqrdx1 has joined #zig
pushqrdx1 has quit [Client Quit]
pushqrdx has quit [Remote host closed the connection]
<daurnimator> ah. mem.toSlice
pushqrdx has joined #zig
<daurnimator> bgiannan: mem.toSliceConst(u8, sdl.SDL_GetError())
<bgiannan> perfect
pushqrdx has quit [Client Quit]
pushqrdx has joined #zig
<pushqrdx> never in my life have used irc before, used it for zig (albiet still new to it)
<pushqrdx> why irc as main thing though not discord 🤔
<bgiannan> there's a zig discord
<pushqrdx> ain't official though
<pushqrdx> nothing against irc, just wondering
<bgiannan> i don't know what the reasons are but i'm glad it's like this
return0e has joined #zig
<kenaryn> Thank you again daurnimator.
LargeEpsilon_ has joined #zig
LargeEpsilon has quit [Ping timeout: 246 seconds]
<mq32> hey
<mq32> pushqrdx, i'm really happy that zig uses an IRC channel instead of any other option as i can chat even with mobile interner :)
<mq32> *internet
n_1-c_k has quit [Ping timeout: 246 seconds]
n_1-c_k has joined #zig
dom96 has quit [Ping timeout: 245 seconds]
mgxm has quit [Read error: Connection reset by peer]
mgxm has joined #zig
dom96 has joined #zig
pushqrdx has quit [Quit: The Lounge - https://thelounge.chat]
gustav_o has joined #zig
<euantor> IRC is open and free, Discord is a closed walled garden
LargeEpsilon_ has quit [Ping timeout: 252 seconds]
LargeEpsilon_ has joined #zig
<tgschultz> ^
samtebbs has joined #zig
<presiden> ^
gustav_o has quit [Remote host closed the connection]
gustav_o has joined #zig
<Snektron> irc is like the c abi of chat programs
<gustav_o> I must say, I really enjoy writing code in zig!
<gustav_o> being able to test functions right next to the implementation is so nice as well
<mq32> gustav_o, i second that! :)
<gustav_o> how would I compare if two slices refer to the same memory? do I manually check .ptr and .len or is there a helper function in mem?
<mq32> huh. i think you have to compare the ptr
<mq32> but why do you want to do that?
<gustav_o> for a test, I want to make sure that my function returns newly allocated memory instead of the input slice
<daurnimator> gustav_o: you want to check if two slices overlap?
<gustav_o> if they are the same, or rather if they are different, I ended up with expect(slice.ptr != copy.ptr) and expect(slice.len == copy.len)
<gustav_o> so there is probably not a function for that
<daurnimator> gustav_o: I'm sure sure if it works... but can you write: `slice != copy`?
<gustav_o> nope
<daurnimator> what error is it?
<gustav_o> error: operator not allowed for type '[]const u8' testing.expect(str.slice != copy);
<gustav_o> how would I normally output a newly allocated object using a parameter to a function? Double-pointer as in C?
<samtebbs> gustav_o: Allocators return a slice so perhaps a pointer to a slice
kenaryn has quit [Quit: WeeChat 2.3]
redj has quit [Read error: Connection reset by peer]
samtebbs has quit [Ping timeout: 252 seconds]
n_1-c_k has quit [Read error: Connection reset by peer]
n_1-c_k has joined #zig
<tgschultz> gustav_o, I'm not sure I'm understanding your question. You want to return a newly allocated object, but instead of returning a pointer you want to take a parameter that tells the function where to store the pointer?
<gustav_o> Yes, I need to return the newly allocated object but the return value is used for a different thing (chaining of multiple function calls)
<tgschultz> then yes, you have the right idea.
redj has joined #zig
<gustav_o> ok, thanks
<tgschultz> though someday there may be something like multiple returns using an ad-hoc struct return type and anonymous struct literals: https://github.com/ziglang/zig/issues/685
<gustav_o> Cool
<gustav_o> This is what I managed to achieve now, I really like it: https://pastebin.com/zYKafRCr
<gustav_o> capture() (for the lack of a better word) moves the parser cursor forward and returns true if the constructed parser succeeds. Note that it only allocates memory if the parse succeeds
<tgschultz> multiple returns doesn't seem like it would be useful for your case anyway.
<gustav_o> Maybe if the returned struct could contain generic data?
<tgschultz> You can do: `pub fn(arg: Whatever) struct{data: @typeOf(arg)}{...}`, but you can't do `pub fn(arg: Whatever) struct{data: var}{...}`.
<gustav_o> ah ok. what about `pub fn (comptime T: Type) struct { data: T, ... } { ... }`?
<gustav_o> but then the next chained function would need to be able to handle generic structs somehow..
<tgschultz> Yeah, that works too.
<tgschultz> you can do `pub fn (input: var, comptime T: Type) struct { data: T, ... } { ... }`
<tgschultz> assuming that 'input' is the previous link's resulting struct.
<gustav_o> what is `var` in this case?
redj has quit [Read error: Connection reset by peer]
<mq32> gustav_o: "var" is "just anything", so you can pass anything as that parameter and inspect it with @TypeOf and similar functions
<gustav_o> ah cool
<gustav_o> mesh.* = ObjMesh{ .name = name.get(allocator) catch |err| return .Failure, };
<gustav_o> Will that line return before setting the pointer?
<gustav_o> (realized that |err| could be removed)
<gustav_o> really cool to be able to work this quickly.. add new function, write some tests, once tests pass -> use function and continue
<gustav_o> can I create anonymous functions yet in zig?
<gustav_o> i.e. in a function call
<mq32> gustav_o, yeah, but it's a bit clobbery:
<mq32> const Helper = struct { fn myFun() void { … } }; var fnptr = Helper.myFun;
<gustav_o> ah okay
<tgschultz> yeah, you have to wrap it in a struct today, but function definitions as expressions was accepted, so that shouldn't be necessary in the future: https://github.com/ziglang/zig/issues/1717
<tgschultz> You can shorten that example too: `const fnptr = struct { fn myFuin(){...} }.myFun;`
<gustav_o> functions as expressions is great
<tgschultz> I use this pattern frequently for what I call "comptime closures". http://zig.tgschultz.com/interpolation.zig is a good example
<tgschultz> I agree. I'm a fan of that change.
<gustav_o> tgschultz so that is similar to List(T) ?
<gustav_o> *ArrayList(T)
mps has left #zig [#zig]
<tgschultz> kinda? it creates a set of interpolation functions, in the specified float precision.
marmotini_ has joined #zig
<tgschultz> as well as the set of functions for creating your own derivative interpolation s
<tgschultz> It was part of a larger tween-based animation library that I haven't worked on in a while
<gustav_o> pretty cool
<gustav_o> what did you use it for? :)
<gustav_o> In other news, my .obj file loader is progressing now that I worked out my issues. Thanks for the help!
doesntgolf has joined #zig
samtebbs has joined #zig
<samtebbs> Did the documentation generation flag come with a corresponding function for a build.zig file?
dimenus has joined #zig
<samtebbs> andrewrk: Thanks. Would a setGenerateDocs() function which sets a generate_docs field in LibExeObjStep suffice?
<dimenus> scientes: are you still working on the simd pr? or do you mind if i take a crack at some of those commits
<scientes> I am still working at it, but what are you talking about?
<scientes> or do you mean adding more commits?
<dimenus> not adding more, just splitting it up to make it more easily mergable?
<scientes> no, that isn't a problem, they depend on each other
<scientes> its handing on me fixing some bugs
<dimenus> ok
<scientes> i have motivation, because it is lots of work to keep it rebased
<gustav_o> Is there a way to import a zig file from a folder that is outside of the current path? ie. `const Vec3 = @import("../math/vec.zig").Vec3;`
<samtebbs> gustav_o: That will work as long as ".." isn't outside of where you're running the command
<gustav_o> Ahhh
<gustav_o> So I need to have a file that imports all tests from subfolders and references them in order to run tests that depend on `Vec3`?
<gustav_o> *in this file
<gustav_o> `zig test src\content\obj_parser.zig` doesn't work
LargeEpsilon_ has quit [Ping timeout: 264 seconds]
<samtebbs> gustav_o: What happens when you try to run that test command above?
<gustav_o> samtebbs: error: import of file outside package path: '../math/vec.zig'
<mikdusan> try `--main-pkg-path dir` where dir is a parent dir to all the sources
<gustav_o> I resorted to a comptime block importing all files with tests at the root path and then running `zig test main.zig` instead
<gustav_o> ok I'll try
<gustav_o> yep that worked as well!
redj has joined #zig
<samtebbs> gustav_o: Nice :)
* daurnimator is currently sitting with bgiannan. say Hi everybody :)
<samtebbs> Hi bgiannan and daurnimator :)
<samtebbs> o/
<daurnimator> "heh" > bgiannan
<gustav_o> hi!
<gustav_o> hm, I seem to be able to access `ArrayList.items` even though it's not pub?
<gustav_o> hm, I seem to be able to access `ArrayList.items` even though it's not pub?
<gustav_o> wops
jmiven_ is now known as jmiven
waleee-cl has joined #zig
<tgschultz> gustav_o there is no pub/private on struct fields
<tgschultz> it's syntactically valid to say `struct{ pub x: i32, }`, it just doesn't mean anything
Akuli has joined #zig
samtebbs has quit [Quit: Lost terminal]
<gustav_o> aha..
<tgschultz> I think it is still an open question whether or not private struct fields are a good idea.
<gustav_o> yea I just assumed it was possible but now that I think about it, it's not clear what's best
<mq32> tgschultz, i think its good how zig does it at the moment
<mq32> module-private/public structs
<mq32> this may hide some implementation details from the public API and removes the privat field from the API
wilsonk has quit [Ping timeout: 240 seconds]
doublex has quit [Ping timeout: 240 seconds]
wilsonk has joined #zig
Ichorio has joined #zig
wilsonk has quit [Read error: Connection reset by peer]
gustav_o has quit [Remote host closed the connection]
wilsonk has joined #zig
LargeEpsilon_ has joined #zig
<donpdonp> i worked on the beginings of a language parser for my zig app. used ragel to compile ragel-lang to .c, then zig took care of everything else. great C interop is so nice.
porky11 has joined #zig
scientes has quit [Quit: ZNC 1.7.4+deb7 - https://znc.in]
doublex has joined #zig
lunamn_ has joined #zig
lunamn has quit [Ping timeout: 240 seconds]
husho has joined #zig
<husho> is it possible to open and read files during comptime?
<mq32> husho, kinda. look at @embedFile()
<husho> yeah, but what if I want to call system calls
LargeEpsilon_ has quit [Ping timeout: 246 seconds]
Foxfir3 has joined #zig
<Foxfir3> arm7 support? will I run into any issues? rpi4
<Foxfir3> and hello :)
FireFox317 has joined #zig
<FireFox317> Hey Foxfir3, I'm FireFox317 :)
<nrdmn> is there an easy way to clone a struct with one attribute changed?
<FireFox317> Yes we support arm7, see the support table: https://ziglang.org/#Support-Table
<THFKA4> there are issues, i ran into https://github.com/ziglang/zig/issues/3412 last week
<THFKA4> here's the main arm7 support bug https://github.com/ziglang/zig/issues/3174
<THFKA4> although i think RPi 4 is aarch64..
mahmudov has joined #zig
<Foxfir3> ls
<Foxfir3> FireFox317: we sure know how to come up with nicks :D
porky11 has quit [Ping timeout: 245 seconds]
<FireFox317> andrewrk: How would I use -dump-analysis to implement some basic IDE support for Zig? I mean if I just have a simple hello_world.zig program without any tests in it, `zig test -fdump-analaysis` won't return anything
<Foxfir3> THFKA4: thank for the links. I just received the Pi4. for a school project. writing a tut, and wanted to include som new lanuguages. Zig seems to be worth mentioning.
<tgschultz> nrdmn: no, not really.
<Foxfir3> THFKA4: that the weird thing about Pi3/4. seems like the hardware is 64bit. Need to dig a bit deeper though.
<Foxfir3> FireFox317: Will give It a go then :) impressive how far Zig seems to have come in such a short time. Thats a good sign.
<FireFox317> Foxfir3, are you gonna run linux on them, or just freestanding?
<Foxfir3> FireFox317: well.. wasted a week on Raspian *sigh*, then switched to Arch. Have'nt decided on embedding yet, but seems logical to get a Pi0 for that part. Will demononstrate some Elixir and some simple Arm assemply, but want to include some exmaples from the new kids on the block. Spend some time on Julia (slooowest JIT in the world), V is a joke. Pony did'nt compile. Dart is missing part of the compiler.
<Foxfir3> Crystal has to be crosscompiled. oh God! so.. Rust and Zig seems to make It into my list.
<Foxfir3> FireFox317: did anyone map the pins yet?
<FireFox317> Don't think so, but I know there is one project that has some really cool stuff running bare metal on a raspberry pi. https://github.com/markfirmware/zig-bare-metal-raspberry-pi
porky11 has joined #zig
<fengb> Is Raspian poor? I haven't tinkered with my Pi much
<FireFox317> But if you just want to turn on some gpio's or something, it should be possible to cross compile for arm32/64 linux and do some mmap magic to turn on some gpio's
<Foxfir3> FireFox317: nice. found his asm bits. thanks for the link.
<Foxfir3> fengb: my honest opinion. Raspian is a hack. but from a business perspective, Its a nice one. For a Linux user, not so nice.
wootehfoot has joined #zig
<fengb> Is arch pretty stable?
marijnfs has joined #zig
porky11 has quit [Ping timeout: 245 seconds]
n_1-c_k has left #zig ["WeeChat 2.6"]
<Foxfir3> fengb: It is. but if you run / and home on SSD, updates can get a bit scary. my experience so far is that the answer is ot simple. Arch Arm is mature now (and very friendly community), while Raspian is more shake'n bake, and will bite you down the road.
<Foxfir3> FireFox317: im guessing the best examply would be to compile on the Pi, and demonstrate the use of addresses. I should do that with C, but It seems pointless to repeat what thounsands have already demonstrated.
<fengb> Hrm I might try it out then
<Foxfir3> thanks for the warm welcome guys :)
<FireFox317> Foxfir3: Be aware that Zig is not stable yet :) You might come across some bugs, but most stuff "just works"
Akuli has quit [Quit: Leaving]
LargeEpsilon_ has joined #zig
doublex has quit [Ping timeout: 250 seconds]
FireFox317 has quit [Ping timeout: 268 seconds]
doublex has joined #zig
dimenus has quit [Ping timeout: 250 seconds]
clktmr has joined #zig
LargeEpsilon_ has quit [Remote host closed the connection]
marmotini_ has quit [Quit: Leaving]
scientes has joined #zig
<andrewrk> FireFox317, this is where multibuilds (#3028) comes in. You would take advantage of this tool I'm writing to merge dumps
<andrewrk> start with one generated for std with all the tests enabled. then you can produce dumps of your in-progress hello world app and merge them with the std lib one
<andrewrk> if something is referenced from nowhere across all sets of all builds, that should probably be an unused thing error, although the compiler isn't able to catch this
<andrewrk> it's a bit of overhead for such a simple use case - but the point is that it's a solution robust enough to handle conditional compilation. nothing else that I'm aware of can handle this case
_whitelogger has joined #zig
husho has quit [Remote host closed the connection]
<Foxfir3> andrewrk: would that be during runtime or compiletime?
<andrewrk> Foxfir3, this would be a third party community project
<Foxfir3> andrewrk: okay. 'the compiler isn't able to catch this
<Foxfir3> so that has to be a manual check? the 'dumping', is that 'hot loading'?
<andrewrk> Foxfir3, this is part of a discussion of a brand new feature which is enabling std lib documentation
<andrewrk> the feature is that the stage1 c++ compiler can be passed -fdump-analysis to write a json file with results of semantic analysis
<andrewrk> further, -femit-docs will use this to generate html/js documentation
<Foxfir3> andrewrk: sort of like SassDocs. Thats really neat.
<Foxfir3> by 'semantic', you mean what?
<Foxfir3> the end result will be semantic. okay.
<andrewrk> "semantic analysis" is the part where a compiler figures out the types and other things and possibly emits compile errors
<THFKA4> the logical conclusion of this is compiler-as-a-server, right?
<THFKA4> where an IDE can use an API to get analysis on the fly instead of rerunning the full compilation
<THFKA4> as a service*
<Foxfir3> andrewrk: that is a nice project
<andrewrk> THFKA4, yes
<andrewrk> that's the plan for self-hosted
<THFKA4> sweet
<andrewrk> but I compromised and spent a week on making stage1 dump semantic analysis, because everybody wants std lib docs
clktmr has quit [Quit: Lost terminal]
<scientes> what about offset-slices, so that memory compaction is possible?
<scientes> it seems some data structures would like that
<scientes> hmm, it would be much more complicated
<scientes> so you would basically have to have heap pools, and then have your data structure linked to that heap pool and manage compaction itsself
wootehfoot has quit [Read error: Connection reset by peer]
<Snektron> Suppose one wants to write some Zig Vulkan bindings (to utilize features such as default struct values and enum literals), what would be the best way to translate enum values starting with a digit?
<Snektron> for example, there is VkImageType which has constant VK_IMAGE_TYPE_3D
<Snektron> (i think writing .discrete_gpu is nicer than VK_PHYSICAL_DEBICE_TYPE_DISCRETE_GPU)
<mq32> Snektron, +1 for .discrete_gpu
<mq32> i'm working on a thin opengl abstraction layer and i'm using tagged enums for this
<mq32> enum(GLenum) { texture2D = GL_TEXTURE_2D, … }
<Snektron> Other projects either keep the full enum constants and type names everywhere, though in my opinion its kind of weird to write vk.VkThing and i find code nicer when theres less screaming snake case values
<Snektron> or they rewrite it to some identifier such that theres no digit at the start, eg 3d, e3D or image_3d
waleee-cl has quit [Quit: Connection closed for inactivity]
<Snektron> mq32: ah, so you just include the name of the enum type in the constant?
<mq32> nah, it's just that the TextureTarget is "texture2D"
<mq32> i don't like to abbreviate it further because it looses semantics
<Snektron> i suppose i should just pick one of the renaming ones, its always problems like these i tend to get stuck on
<mq32> hey, naming IS important :)
<Snektron> its true
<mq32> i'm struggling that "type" is a global identifier in zig i can't use for anything
<Snektron> the rust guys solved that by naming everything "ty"
<mq32> one solution would be to put "type" into builtin package: "builtin.Type"
<Snektron> const Type = type;
<mq32> other way round :D
<mq32> const type = @import("builtin").Type;
<Snektron> oh wow, i didn't expect that to work
<mq32> it doesn't work yet, but that would be my proposal
<mq32> it's also good that "use" is beeing removed as a keyword in 0.6
<Snektron> no i mean const Type = type;
<mq32> ah
<mq32> why not? :D
<mq32> "type" is just a type like any other
<Snektron> idk really, it seems logical