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/
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
fengb has joined #zig
<fengb> tgschultz: error: invalid token: 'var' pub fn init(ptr: ?var) Self {
<fengb> Without the nullability — "error: parameter of type '(null)' requires comptime"
<tgschultz> fengb: that's an invalid way to express that. just take `ptr: var`, then in the body check if `@typeOf(ptr) == @typeOf(null)`
<fengb> Yeah it's not letting me
<tgschultz> huh
<tgschultz> hmmm...
<scientes> "(null)" is a glibc thing....
<scientes> so you are already invoking UB in C
<fengb> ".iface = comptime Allocator.Iface.init(null),"
<fengb> Adding comptime worked
<scientes> yeah but if you ever see "(null)" the C is incorrect
<scientes> as that is technically UB
<scientes> that glibc is glossing over
<tgschultz> scientes there's no C here
<scientes> oh ok, does zig format do the same thing?
<tgschultz> fengb: that's unintuitive, I think we should do it the other way and update the error message.
<fengb> Sure
<scientes> <scientes> yeah but if you ever see "(null)" the C is incorrect
<scientes> <scientes> as that is technically UB
<scientes> <scientes> that glibc is glossing overrint.cpp uses "(null)"
<scientes> ahh sorry, i see that ir_print.cpp uses "(null)"
<daurnimator> fengb: heh. I ran into a similar thing myself last night. I wanted: [*]var
<daurnimator> and another time I wanted *align(4096) var
<daurnimator> all failed :(
<daurnimator> Really I think we just need to replace 'var' with the proposal in #1669
<fengb> Jimmi's proposal is great; basically what I wanted in Erlang / Elixir
<scientes> yeah that makes sense
<scientes> I've done that just in the function before
<scientes> if (@typeInfo(var)) et cetera
mrkishi has quit [Ping timeout: 252 seconds]
<scientes> something like that...
<fengb> Also... want to avoid angle brackets >_>
<scientes> <_< >->
<scientes> <_>
<scientes> ^_^
avoidr has quit [Quit: leaving]
mrkishi has joined #zig
<fengb> Do as I say, not as I do
<tgschultz> now that the plan is to have async not take an allocator, my guess is that angle brackets will stay out of the language. #1669 would probably be `var(func)`if implemented.
<scientes> <<><>>>><><<<<<>>>
<mrkishi> tgschultz: unrelated but #1669 is something I've been reading on-- has it been considered giving var a way to introduce names?
<mrkishi> eg. `a: var A` to get a type A introduced instead of having to `@typeOf(a)`, possibly extended so that constraints can introduce even further names?
<daurnimator> mrkishi: hrm. my first thought is that it seems like a bad idea. my 2nd thought is that a complex constraint might be doing an expensive calculatation that you want to save. my 3rd thought is that the proposal in #1669 requires that the constraint be comptime, so it's probably already cached.
<mrkishi> it's not so much related to caching but to ergonomics, really. say defining a simple map over a generic list: if I'm not missing anything (high possibility), right now, you need to either be explicit like `fn map(comptime A: type, comptime B: type, allocator: *Allocator, f: fn (a: A) B, input: List(A)) !List(B)` or do imperative comptime type checking
<mrkishi> with #1669 you could probably create constraints to input and helper functions to extract their types so you can construct the proper return type
<daurnimator> mrkishi: I don't see any problems with being explicit like that
<mrkishi> there's no problem per se, but consider something like `fn map(allocator: *Allocator, f: fn (a: var A) var B, input: List(A)) !List(B)`
<mrkishi> imo that's more ergonomic while not hiding things as per zen of zig
<daurnimator> my first question there is: what is 'A'?
<daurnimator> A and B seem to be conjured from nowhere
<mrkishi> a new name introduced by `var`, basically `@typeOf(a)`
<mrkishi> yeah, it'd be a new concept and perhaps the syntax should be different
<mrkishi> but allowing `var` to be an explicit inference keyword doesn't seem completely wacky
<mrkishi> (where `var` doesn't need to be named `var` and the syntax doesn't need to be like that as well either)
<mrkishi> explicit inference like `fn f(a: infer T, b: T)`. I saw there was talk of something similar on #470 and it was disregarded, but perhaps the `var` keyword could be augmented instead
<mrkishi> back to #1699, consider the example `pub fn dot(a: var<isVector>, b: @typeOf(a)) @typeOf(a)`, the return there should actually be the type of the vector's scalar instead, so you need both `isVector` and `getVectorScalarType`
* scientes does not want to see <>
<mrkishi> could we instead allow var's constraint functions to return types as well, and var itself assign names to these?
<scientes> why not just use @typeInfo() on it?
<fengb> mrkishi: So basically like generic aliases like in Typescript? function <T, F extends (T) => T>foo(a: F, b: F): T
<daurnimator> fengb: argh, that looks like line noise :P
<mrkishi> yeah, `@typeInfo()` is what we'd need to use to extract the scalar type, so for a constraint X we'd need to provide multiple functions: one for testing for the constraint and others for extracting associated types from it
<mrkishi> that's what already proposed, right?
<fengb> I think we can emulate it with comptime references: `pub fn dot(comptime V: isVector, b: V) V`
<scientes> ^
<scientes> thats exactly what I'm saying
<mrkishi> not sure I follow
<fengb> "comptime V" defines the type that you can use in subsequent arguments
<scientes> something about <> scares me
<mrkishi> right, but then we're back pre #1699 and providing each type separately
<mrkishi> `pub fn dot(comptime V: isVector, comptime S: scalar, a: V, b: V) S`
<fengb> I kinda think that's more readable, even if it may be longer to type
<mrkishi> or, rather, `pub fn dot(comptime V: isVector, a: V, b: V) getScalar(V)` using typeinfo
<scientes> ^yep
<scientes> I still haven't figure out a good syntax for branching on vectors
<scientes> for any comparison you have ALL, SOME, or NONE
<daurnimator> scientes: you need more than that
<daurnimator> scientes: you don't want "SOME", you want "elements 1,4,5"
<scientes> I don't see any more being useful
<daurnimator> scientes: i.e. you want a bitarray returned.
<scientes> daurnimator, that is done with permute
<scientes> and you already have a bitarray
<daurnimator> which IMO makes sense to provide with a builtin
<scientes> if only talking about branching
<scientes> you can of course fiddle with the data beforehand
<scientes> this is based on my experience with how ppc works
marijnfs has joined #zig
marijnfs__ has quit [Ping timeout: 272 seconds]
<mrkishi> can zig types themselves have comptime fields somehow?
<mrkishi> something like associated types
<mrkishi> oh wait I see they can, sorry for noise
fengb has quit [Ping timeout: 256 seconds]
<emekankurumeh[m]> mumbles about pattern matching
_whitelogger has joined #zig
_whitelogger has joined #zig
<daurnimator> emekankurumeh[m]: I really want to see a PEG written in zig
<daurnimator> I was going to have an attempt at it; but allocator and uring are keeping me busy
<emekankurumeh[m]> i mean pattern matching in zig, like in rust
<emekankurumeh[m]> that was one of the things I really like d about rust
mrkishi has quit [Ping timeout: 252 seconds]
lygaret has joined #zig
very-mediocre has joined #zig
hio has quit [Quit: Connection closed for inactivity]
_whitelogger has joined #zig
<daurnimator> Anyone in here a rusted-on windows developer?
<daurnimator> Would be a great project to wrap some of the lower level NT apis; particularly the socket ones.
lqd has quit [*.net *.split]
Summertime has quit [*.net *.split]
shodan45 has quit [*.net *.split]
donpdonp has quit [*.net *.split]
noonien has quit [*.net *.split]
daurnimator[m] has quit [*.net *.split]
jzelinskie has quit [*.net *.split]
bgiannan has quit [*.net *.split]
hoppetosse has quit [*.net *.split]
daurnimator has quit [*.net *.split]
daurnimator has joined #zig
noonien has joined #zig
daurnimator[m] has joined #zig
jzelinskie has joined #zig
bgiannan has joined #zig
hoppetosse has joined #zig
lqd has joined #zig
donpdonp has joined #zig
shodan45 has joined #zig
Summertime has joined #zig
<very-mediocre> daurnimator: afaik windows sockets are like 90% similar to BSD sockets
<very-mediocre> sadly I'm swamped with work so can't contribute :{
<daurnimator> very-mediocre: might have lost your messages over the netsplit
<daurnimator> very-mediocre: windows sockets are implemeted in "AFD", if you want good performance or normal event semantics, you need to bind them directly instead of using winsock
very-mediocre has quit [Ping timeout: 256 seconds]
very-mediocre has joined #zig
<very-mediocre> got disconnected, looked into AFD meanwhile
<daurnimator> very-mediocre: it's quite interesting when you get deep into it :)
<very-mediocre> was looking for this post I read a year ago or so: https://news.ycombinator.com/item?id=11866562
<very-mediocre> because i knew iocp was also a thing
<very-mediocre> indeed it's very interesting
<daurnimator> very-mediocre: nearly all socket operations are an NT ioctl call with underdocumented parameters :)
<daurnimator> very-mediocre: midipix is probably one of the easiest to navigate codebases to get the details out of. e.g. for their implementation of send(), see https://git.midipix.org/ntapi/tree/src/socket/ntapi_sc_send.c?id=44175629431076ef6b37e3d6dce037983b6ddd72#n77
<very-mediocre> that's great
<very-mediocre> C can easily be unreadable
very-mediocre has quit [Remote host closed the connection]
very-mediocre has joined #zig
<daurnimator> very-mediocre: so IMO, someone needs to wire up all those low level AFD APIs in zig
<very-mediocre> can't find much about skipping user mode winsock entirely and doing it all that low level
<very-mediocre> other than midipix are you aware of projects doing this?
<daurnimator> very-mediocre: most projects only do it for the performance sensitive bits
<daurnimator> libuv is one example of that
<daurnimator> it's not disimilar to libc on linux vs raw syscalls: most people use libc, but sometimes you use the raw syscalls.
<very-mediocre> right, gotcha
<very-mediocre> tbh it seems pretty crazy on windows
<very-mediocre> everything is debated.
<very-mediocre> I'm googling around to get a better idea and I'm running into super long deliberations about how to implement things
<daurnimator> very-mediocre: we don't need to make those decisions yet (though I have ideas/plans)
<daurnimator> very-mediocre: to start with, what we'll need is the raw ioctl wrappers
<daurnimator> decisions about when to use winsock vs raw ioctls vs wrapping all up in an event framework can happen later. and likely we'll want to give users the option (same as we let people choose if they want to link against libc or not today on linux)
<very-mediocre> i'm sure you can tell i'm out of my element here, hence the not-so-riveting conversation :)
<very-mediocre> i understand everything but I have no business evaluating any decisions about this
<daurnimator> very-mediocre: an interesting starting project might be: try and send a UDP "hello" message using the raw ioctl API in pure zig.
<daurnimator> very-mediocre: will require wrapping the 'create socket' operation; and the 'send udp packet' operation
<very-mediocre> if this is a blocker for the HTTP client issue then winsock seems like a natural starting point
<daurnimator> very-mediocre: no its not at all
<daurnimator> very-mediocre: just a general 'useful to have' thing to for our zig toolbox
<very-mediocre> i see
very-mediocre has quit [Remote host closed the connection]
very-mediocre has joined #zig
very-mediocre has quit [Remote host closed the connection]
heitzmann has joined #zig
very-mediocre has joined #zig
heitzmann has quit [Quit: WeeChat 2.4]
heitzmann has joined #zig
very-mediocre has quit [Remote host closed the connection]
avoidr has joined #zig
mouldysammich has joined #zig
very-mediocre has joined #zig
marijnfs has quit [Quit: WeeChat 2.4]
hio has joined #zig
very-mediocre has quit [Remote host closed the connection]
mouldysammich is now known as sammich
marijnfs has joined #zig
jzelinskie has quit [Ping timeout: 252 seconds]
jzelinskie has joined #zig
shodan45 has quit [Remote host closed the connection]
bgiannan has quit [Ping timeout: 252 seconds]
bgiannan has joined #zig
lqd has quit [Ping timeout: 248 seconds]
lqd has joined #zig
rain1 has joined #zig
rain2 has quit [Ping timeout: 252 seconds]
noonien has quit [Ping timeout: 252 seconds]
noonien has joined #zig
halosghost has joined #zig
<scientes> how do i build zig without libuserland.a?
lygaret has joined #zig
<scientes> oh i guess i have zig0 which is fine
<emekankurumeh[m]> why would you want to do that?
<scientes> porting to a new architecture
<scientes> but i don't WANT to build compiler-rt....
<emekankurumeh[m]> <scientes "but i don't WANT to build compil"> i pretty sure that libuserland.a is different from compiler-rt
<scientes> yes it is
<scientes> but once you avoid libuserland.a you run into zig always wanting to compile compiler-rt
<scientes> even if just using build-obj
<emekankurumeh[m]> i thought it was just the parts of the zig compiler written in zig
<emekankurumeh[m]> like zen, fmt, and translate-c
<scientes> compiler-rt is a llvm library, ported to zig
<emekankurumeh[m]> libuserland not compiler-rt
<scientes> yes i know
<emekankurumeh[m]> have you tried building .a files?
<emekankurumeh[m]> accord to this issue zig doesn't bundle compiler-rt with static libs: https://github.com/ziglang/zig/issues/2551
jfo has joined #zig
<jfo> hi all, does anyone know what the `@` means in the path being passed to import here? https://github.com/jfo/zig/blob/efa39c5343e13a13e65210f55da5df23ee3feb3e/std/special/build_runner.zig#L1
<emekankurumeh[m]> it's probably just a regular package that points to the build file in a project
<emekankurumeh[m]> the `@` is so it doesn't conflict with any other package just like with `@root` in bootstrap.zig
<scientes> emekankurumeh[m], @root is special
<scientes> but @"" allows using reserved words and characters
<scientes> and calling arbitrary symbols
jfo has quit [Ping timeout: 245 seconds]
<emekankurumeh[m]> @root is just a package that refers to to the root file, any other name could have been chosen. the `@` could have been chosen for a special reason but as far as I can tell any other symbols could have been used just as easily.
<scientes> emekankurumeh[m], yeah but it is special coded in the compiler
<scientes> so it isn't really an example of a lanuage feature yet
<mikdusan1> ie: "@root" == where `pub fn main()` is decl'd; "@build" == where `pub fn build()` is decl'd
<scientes> I hate fighting with the assembly syntax
<scientes> there isn't even a clear conversion from llvm-ir, which i can get out of clang
<halosghost> isn't there an llvm tool to take ir and convert to asm?
<scientes> i'm talking about inline zig asm
<halosghost> ahh
<scientes> llvm-ir also has a asm command
<scientes> but its not clear how to convert the opposite way
<scientes> and I can never get the syntax just right
<halosghost> sure
crimson_penguin has quit [Ping timeout: 264 seconds]
crimson_penguin has joined #zig
avoidr has quit [Quit: leaving]
<donpdonp> struct Thing { pub fn init() Thing { return Thing {}; } }; using the common pattern of Thing.init(), whats the lifetime of Thing{} ? I thought the lifetime would be the duration of the enclosing funciton which would make the return Thing{} invalid almost immediately?
Akuli has joined #zig
<mikdusan1> donpdonp: `return Thing{}` makes a copy. but with guaranteed copy-elision it ends up targeting call site storage directly.
<donpdonp> mikdusan1: interesting, thx. i need to look up copy-elision
Ichorio has joined #zig
joaoh82 has joined #zig
joaoh82 has quit [Remote host closed the connection]
wootehfoot has joined #zig
<emekankurumeh[m]> i kinda wish try took a block, similar to languages like java
<mikdusan1> +builtin.Os.iPadOS
mrkishi has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
wootehfoot has joined #zig
DesDeux has joined #zig
avoidr has joined #zig
Akuli has quit [Quit: Leaving]
<DesDeux> Hello, have a really noobish question: how to install libc on windows so zig can find it?
<scientes> I got hello world working on ppc64el!
gamester has joined #zig
<gamester> DesDeux: have you tried passing "--library c", or exe.linkSystemLibrary("c") if you're using build.zig?
<DesDeux> <gamester> Yes and got "Unable to determine libc include path: file not found
<DesDeux> . Unable to link against libc: Unable to find libc installation: file not found"
<gamester> donpdonp: 'return Thing{}' makes a copy, for when that's bad people use create/destroy instead of init/deinit where create returns a pointer. copy elision isn't here yet
<gamester> DesDeux: hmm, I'm not sure then. Hopefully someone else can help
Ichorio_ has joined #zig
Summertime2 has joined #zig
Ichorio has quit [*.net *.split]
Summertime has quit [*.net *.split]
donpdonp has quit [*.net *.split]
Sahnvour has joined #zig
DesDeux has quit [Quit: Leaving]
<emekankurumeh[m]> DesDeux do you have mingw-w64 or visual studio installed?
gamester has left #zig ["Leaving"]
wilsonk has quit [Ping timeout: 272 seconds]
wilsonk has joined #zig
telemach has quit [Remote host closed the connection]
Sahnvour_ has joined #zig
<scientes> what was that hack to doing alloca(), I need to advance the stack pointer x bytes
<scientes> cause powerpc64el process startup not only doesn't follow its own spec, but its kinda fed up
Sahnvour has quit [Ping timeout: 248 seconds]
marijnfs_ has joined #zig
Ichorio_ has quit [Ping timeout: 252 seconds]
Sahnvour_ has quit [Quit: Leaving]
halosghost has quit [Quit: WeeChat 2.4]
mrkishi has quit [Ping timeout: 258 seconds]
avoidr has quit [Quit: leaving]
wootehfoot has quit [Read error: Connection reset by peer]
mrkishi has joined #zig
lygaret has quit [Quit: Leaving.]
<marijnfs_> has someone already played with zeromq with zig? seems the serialisation of zig is a nice match with that
z80lives has joined #zig
z80lives has left #zig ["ERC (IRC client for Emacs 26.1)"]
marijnfs_ has quit [Quit: WeeChat 2.4]
lunamn has quit [Ping timeout: 244 seconds]
lunamn has joined #zig