<kandinski>
I'm exploring Zig with a view to implement a toy scheme in it, and I'm sure this is not a bug but a misunderstanding of mine: https://termbin.com/iuxb
<fengb>
Tuples only coerce to arrays, not slices
<fengb>
My array is defined as a slice
<kandinski>
[_]FooType would be an array?
<kandinski>
where the _ means "compiler, please fill in the length"?
<fengb>
Yes but you’d need to define a size for a type
<fengb>
The inferred syntax only works for building an array, not defining variables
<kandinski>
error: inferred array size invalid here
<kandinski>
hmm right
<kandinski>
yup, test passing, thanks
<fengb>
np
<fengb>
There’s a proposal to allow &.{foo} to coerce into a slice. It has some design flaws
<leeward>
`.{foo][0..]`?
<kandinski>
this is because the compiler is reading the tuple literal as a struct and then coercing it, correct?
<fengb>
Right
<kandinski>
this worked: var my_array = [_]ErrorUnionOptionalStringType{ mystring, mystring, mystring };
<kandinski>
(hope it's ok to paste single lines)
<kandinski>
but now of course my_array is of type [3]..., I just didn't have to count them by hand
<leeward>
Yep, that should do it.
<kandinski>
much appreciated, folks
tines9 has quit [Ping timeout: 256 seconds]
ncon has quit [Ping timeout: 260 seconds]
nephele has quit [Ping timeout: 244 seconds]
nephele_ has joined #zig
nephele_ is now known as nephele
tines9 has joined #zig
ncon has joined #zig
earnestly has quit [Ping timeout: 258 seconds]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
a_chou has quit [Ping timeout: 256 seconds]
a_chou has joined #zig
a_chou has quit [Remote host closed the connection]
waleee-cl has quit [Quit: Connection closed for inactivity]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
swills has quit [Ping timeout: 260 seconds]
marnix has quit [Ping timeout: 272 seconds]
marnix has joined #zig
swills has joined #zig
rlr has quit [Quit: WeeChat 2.9]
swills has quit [Ping timeout: 264 seconds]
swills has joined #zig
ur5us_ has quit [Ping timeout: 260 seconds]
mattnite has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
mattnite has quit [Quit: Ping timeout (120 seconds)]
cole-h has joined #zig
earnestly has joined #zig
nvmd has quit [Ping timeout: 272 seconds]
_Vi has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
<justin_smith>
I also copied the original code into the repo, and linked to the original examples
<justin_smith>
also, if someone wants to dig even further, the commit history is the refactor that the blog post will walk through (and if that should be fixed I'll rebase so that "history" is a good one for the blog to follow)
marnix has joined #zig
<jorangreef>
Thanks andrewrk, I want to hack your tcp chat server at https://gist.github.com/andrewrk/34c21bdc1600b0884a3ab9fa9aa485b8 just to echo back what it reads, for a single connection only, without the hash map overhead, but am running into "evented writes to the same fd is not thread-safe". Could you "pro-tweak" it for me? I have everything else, an
<jorangreef>
io_uring-based client and another C contender also using io_uring to compare with. Sorry for those 100 mails ikskuh had a fun weekend.
<justin_smith>
it starts with something very close to a decomposed "translate-c" output (where nested conversions on one line are broken into explicit steps per line)
<ikskuh>
jorangreef: no worries, i love seeing progress, even if i ignored the thread from the start
* ikskuh
aint a major user of async apis :D
<jorangreef>
I figured most people would have unwatched around the 30th push D:
<andrewrk>
jorangreef, let me see what I can do. It might require a std lib patch hack, but I'm guessing that will be fine for your purposes?
<andrewrk>
there's a larger reworking which needs to be done here to avoid trying to put the same fd into epoll multiple times
<ikskuh>
jorangreef: i watch the whole repo :D
<jorangreef>
andrewrk sure, that would be awesome.
<ikskuh>
andrewrk: how's 6250 going? there were some exciting commits in there!
<andrewrk>
ikskuh, it's good, you can see progress like this: `git fetch && git log -p origin/stage2-zig-cc -- BRANCH_TODO`
<ikskuh>
ah
<andrewrk>
above the line break is merge blockers, below is issues I need to file after merging
<andrewrk>
so... 33 more commits, then merge, then file 29 github issues :D
<ikskuh>
hm. i don't get any output for this :D
<ikskuh>
but i've just checked out the right branch :)
waleee-cl has quit [Quit: Connection closed for inactivity]
<andrewrk>
this branch changes the CLI btw to remove --c-source; instead it pays attention to file extensions
<andrewrk>
zig build-exe foo.zig bar.c
<fengb>
So I can't name my zig sources .c? D:
<leeward>
Foiled again!
<andrewrk>
jorangreef, I wish self-hosted was done so I could be doing event loop stuff with you more right now
<andrewrk>
I just feel like this is too much of a bottleneck for me to not focus on it until completion
<ikskuh>
andrewrk: the current changes allow for planned simultaneous compilation, right?
<jorangreef>
andrewrk, that's the right thing to focus on, will be awesome when self-hosted is done, it's a force multiplier
<andrewrk>
ikskuh, yeah you can see it's centered around a job system
<justin_smith>
as we discussed previously, data structures are kind of strewn about lib/zig/std, I notice lib/zig/std/atomic/ has atomic concurrent data structures, so if I want to do lock free maybe std/lib/lockfree ? I'm thinking the basics, lock free stack, lock free queue, then a ringbuffer apropriate for usage as a high throughput channel
<andrewrk>
I decided not to do evented I/O for now, because that will simplify bootstrapping the compiler
<ikskuh>
yeah, true
<ikskuh>
neat!
<ikskuh>
this is gonna be great!
<ikskuh>
finally no long wait times for compiling bearssl anymore :D
<ikskuh>
* audit the CLI options for stage2
<ikskuh>
also a very good point :)
<andrewrk>
ikskuh, I think it is reasonable that we could get parallel builds of c objects by 0.7.0
<ikskuh>
nice
<ikskuh>
on the change above: how do i pass comiler flags per C file?
<andrewrk>
* add CLI support for a way to pass extra flags to c source files
<andrewrk>
;)
<ikskuh>
ah :D
<andrewrk>
justin_smith, I had originally intended for std.atomic to be lock free data structures, but after weeks working on a lock free queue I failed and gave up and now std.atomic should be renamed to std.threadsafe
<justin_smith>
andrewrk: AHA - I'll include that in my work then - better to have std.threadsafe.lockfree or std.lockfree for the non-locking variants?
<andrewrk>
I think std lib path names can be decided later
<justin_smith>
I know it's tempting to make this an auto-upgrade kind of thing, but certain lockfree algorithms (which are worth using) need slightly different usage apis
<andrewrk>
my recommendation would be to work on these lock free data structures externally and treat upstreaming them as a separate project
<justin_smith>
cool
<andrewrk>
I came to the conclusion that lock free data structures would not actually improve the event loop perf
<andrewrk>
but that's just me, maybe you end up finding something different :)
<justin_smith>
my hunch was that last one (ringbuffer) would make the real difference
<justin_smith>
if your consumers keep up it's a very fast paradigm
<justin_smith>
my thought was to have a "channel" abstraction built on ringbuffer + some simplifying assumptions
<companion_cube>
if the event loop is plugguable, maybe the standard one can be relatively simple?
<justin_smith>
but it's experimental, I'll make some tests and we'll see if I come up with anything
<andrewrk>
sounds good
<andrewrk>
oh they finally fixed all the regressions I reported in llvm 11rc2. time to run the test suite again
<mattnite>
wew!
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
mmohammadi98122 has joined #zig
mmohammadi98122 has quit [Client Quit]
mmohammadi9812 has quit [Ping timeout: 240 seconds]
<andrewrk>
jorangreef, I might have taken on more than I can chew today, you might be better finding another way to do your benchmark than waiting for me
<jorangreef>
andrewrk, no worries! ...thanks for Zig... incredible work! If anyone else can help, all we need is a simple zig tcp server that accepts a single connection, reads a 1K buffer and immediately writes back.
<ikskuh>
multiple clients or single client?
<jorangreef>
single client
<ikskuh>
let me hack something together quickly
<ikskuh>
i need to do a bugfix on zig-network anyways
<companion_cube>
fgenesis: is it correct to say that virtual memory makes the "hierarchical table layout" for you?
v_m_v has joined #zig
<fgenesis>
companion_cube: huh?
<fgenesis>
what are you referring to?
<companion_cube>
in the ringbuffer article
<companion_cube>
"[…] we could use virtual memory instead, and avoid the complexity of a hierarchical table layout."
<companion_cube>
basically that's what virtual memory is, right?
<fgenesis>
...yeah? except that it's the cpu doing it in hardware pretty much
<companion_cube>
yeah sure
<companion_cube>
basically writing an allocator, there
<fgenesis>
but all of this talk about virtual memory becomes a bit nasty when you're on HW without it. stupid 8-bit microcontrollers :D
<fgenesis>
so i dunno if anything requiring VM is even suitable for the standard lib
<fgenesis>
or even if you're on a 32bit platform and virtual memory is rather scarce by today's standards
<companion_cube>
maybe there should be layers of stdlib :)
<companion_cube>
small and big
<fgenesis>
rust does this since a while iirc
<fgenesis>
a core lib that depends on nothing, an os lib that has all the OS things, some more, and finally the stdlib tying them together
<fgenesis>
but i am not knowledgeable in rust so please ask someone competent :D
zippoh has joined #zig
<fgenesis>
anything is better than in C. syscalls to into the standard lib because uuhhhh, but floating point stuff is totally exotic enough to warrant a libm (at least on *nix)
<fgenesis>
like having a libsyscall wasn't a good idea
<ikskuh>
fgenesis: nice thing in zig:
<ikskuh>
when you don't use it, it's not compiled
<ikskuh>
so you can provide such a smart/efficient ringbuffer on OSes with support for it
<ikskuh>
and fall back to a less efficient one on other platforms
<fgenesis>
yeah, but think about the API
<earnestly>
Like io_uring
<ikskuh>
it shouldn't differ between both APIs
<fgenesis>
as long as that doesn't matter for whether VM is used internally or not, it's good
<ikskuh>
*implementations
<fgenesis>
yeah i mean that, it totally definitely should not :D
<ikskuh>
except that initializing the ringbuffer may fail
mattnite has quit [Remote host closed the connection]
<fgenesis>
win10 apparently has an API that doesn't fail, and via NT api directly one can also do this
<fgenesis>
and that only works with a pointer spanning twin pages to two separate calls
<fgenesis>
so the two steps would be a valid fallback if the more efficient thing isn't available
<fgenesis>
because cmon, read() does a memcpy which could be avoided
<ikskuh>
:D
<ikskuh>
you mean: just do "getReadSlice()" and let the syscall write directly to the buffer? :D
<companion_cube>
pretty cool post fgenesis, anyway
<companion_cube>
thanks for sharing
<fgenesis>
i still want to code an lz secompressor that does this, deliver pointers directly into the decomp window
<fgenesis>
*decompressor
<fgenesis>
i do consider the buffer-centric-io post a milestone because ti solves all of the problems with 'fread() reported eof but i forgot to check it'-style code
<fgenesis>
and fits well into the zig mentality so.. why not
aldessa has joined #zig
<andrewrk>
welcome alexnask[m] to the core zig team!
<ikskuh>
we also have traits/interfaces as a library :D
<ikskuh>
usp of zig: "we don't need that language feature, we have a library for that"
<alexnask[m]>
Its more of a proof of concept, its based on capturing a comptime var and forcing comptime functions to be called with anonymous structs
<alexnask[m]>
(to get around the caching)
<andrewrk>
oh it's not the conservative stack based thing? interesting
<ikskuh>
andrewrk: how strong are you opposed to allow .decls in @Type(.Struct)?
<ikskuh>
*strongly
<andrewrk>
it's still open for consideration
<ikskuh>
oh, nice
<ikskuh>
because alexnask[m] and i found a nice argument for it:
<ikskuh>
not requiring "*vtable Struct"
<andrewrk>
would be open to have a serious discussion about it after I get 6250 off my mind, maybe we can come to a conclusion (accepted or closed) before 0.7.0
<ikskuh>
okay, sure :)
<ikskuh>
spoiler: interface.zig could be improved further to allow this:
* fgenesis
misread read 6502 first and is now sad
<ikskuh>
hrhr
<ikskuh>
const ptr = IType.init(foobar);
<ikskuh>
ptr.method(some);
<ikskuh>
instead of
<ikskuh>
ptr.call("method", .{some});
<ikskuh>
fgenesis: *psst*, i'm waiting for the issue counter to bump up to 6501… :D
<fgenesis>
hrhr
<ikskuh>
this is gonna be fun
wootehfoot has quit [Read error: Connection reset by peer]
<aldessa>
I'm reading the documentation and think some of it is a bit strange?
<aldessa>
a lot of it is just code, for example rather than writing 2^29, it says 1 << 29 and some sections are just programs with comments
<ikskuh>
aldessa: documentation is very WIP
v_m_v has quit [Remote host closed the connection]
<aldessa>
i might make a pull request for the multidimensional arrays, it uses a square matrix so you can't tell the order of the dimensions
zippoh has quit [Remote host closed the connection]
<aldessa>
it makes sense to be [m][n] rows x columns like maths but i had to compile to figure out since in maths you write R^m x n instead of m x n R
zippoh has joined #zig
zippoh has quit [Remote host closed the connection]
<aldessa>
anyhow good night
<aldessa>
cool project
aldessa has quit [Quit: Leaving]
zippoh has joined #zig
xackus_ has quit [Ping timeout: 272 seconds]
zippoh has quit [Remote host closed the connection]
zippoh has joined #zig
eagle2com has joined #zig
marnix has quit [Ping timeout: 264 seconds]
xackus_ has joined #zig
ur5us_ has joined #zig
mmohammadi9812 has quit [Quit: I quit (╯°□°)╯︵ ┻━┻]
zippoh has quit [Remote host closed the connection]
zippoh has joined #zig
zippoh has quit [Remote host closed the connection]
zippoh has joined #zig
marnix has joined #zig
xackus_ has quit [Ping timeout: 260 seconds]
<justin_smith>
fgenesis: that usage of a ring buffer (using it for arbitrary sized chunks of data that might wrap around the end) is a special use case I'm not relying on for my channel impl, that's a very clever solution though
<fgenesis>
23:05 < aldessa> it makes sense to be [m][n] rows x columns like maths
<fgenesis>
for the record, math notation is wrong! :D
<fgenesis>
nobody in their right mind would address something as (y, x)
marnix has quit [Ping timeout: 272 seconds]
Akuli has quit [Quit: Leaving]
lqd has quit [Read error: Connection reset by peer]
procnto has quit [Read error: Connection reset by peer]
jzelinskie has quit [Ping timeout: 272 seconds]
dputtick has quit [Write error: Connection reset by peer]