<g-w1>
could someone tell me if this is an error in the zig compiler before i file a bug? the compiler should not allow else here since the error set is error {T} only https://paste.rs/fhu
hlolli has quit [Ping timeout: 272 seconds]
reductum has quit [Quit: WeeChat 2.9]
lunamn has quit [Ping timeout: 240 seconds]
linuxgemini has quit [Ping timeout: 240 seconds]
ave_ has quit [Ping timeout: 264 seconds]
<ifreund>
g-w1: seems like a stage1 bug to me
<g-w1>
ok. im trying to fix rn. good excuse to become farmillar with c++
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
<pixelherodev>
g-w1: there is no such excuse :P
<pixelherodev>
(no excuse for becoming familiar with C++ is good lol)
<g-w1>
lol
lunamn has joined #zig
linuxgemini has joined #zig
ave_ has joined #zig
<g-w1>
my patch found TONS of bugs like this in the self hosted compiler :|. itll be a long night fixing them. https://share.olind.xyz/f.php?h=3jByW7Ie&p=1 any suggestions for how to fix this without going over like 50 instances of this?
<pixelherodev>
g-w1: patch ZLS to support refactoring :P
<pixelherodev>
Or not ZLS
<pixelherodev>
Use the AST API
<g-w1>
or anyone wanna use their text editor/grep magic to grep the error message and delete the lines?
<pixelherodev>
Basically, write a `zig refactor` tool :P
<pixelherodev>
I can do that if you send the patch
<pixelherodev>
It's still manual, but pretty fast
<g-w1>
thanks
<g-w1>
ill push it to gh rn
<pixelherodev>
(I have shortcuts for "jump to error" and "delete the next few lines", so it's not terrible)
<g-w1>
well i mean the output from the `make` gives the lines in the error messages, so someone good with sed/unix stuff could do it automatically
<pixelherodev>
I could try that too
<pixelherodev>
I just don't trust it lol;
<pixelherodev>
Ah wait, actually, send the error log instead
<pixelherodev>
I'll do it that way
<pixelherodev>
Mostly because I can't build Zig compilers right now :(
<pixelherodev>
Not with stage1 support at least
<pixelherodev>
Pure stage2, I think I can still do
<pixelherodev>
But I don't have and won't ever have LLVM 11
<g-w1>
what os are you on?
<pixelherodev>
(because I decided I'd rather use static stage1 builds for now and just not deal with LLVM ever again)
<pixelherodev>
g-w1: Linux
<pixelherodev>
glibc-based, too, it's just a total pain
<pixelherodev>
I mean, my daily driver is 9front now
<pixelherodev>
But zig work I do over SSH to Linux
<pixelherodev>
At least until I add a plan9 backend :)
<pixelherodev>
Though that's not until stage2 because I frankly don't want stage1 on here lol
<pixelherodev>
Pipe the output of Zig to > grep "error: unreachable else prong" | sort | uniq
<pixelherodev>
~40 of them are on the same line in comptime code
<g-w1>
ah
<pixelherodev>
I can still write you that script if you want :P
<pixelherodev>
Or you can solve them manually
kristoff_it1 has joined #zig
<pixelherodev>
kristoff_it: heyo!
<g-w1>
ill just do manually
<g-w1>
thx for the help
<pixelherodev>
:)
<pixelherodev>
This is arguably a bug in stage1 as well
<pixelherodev>
It shouldn't report the same error 50 times just because it was called from 50 places
aerona has joined #zig
kristoff_it has quit [Ping timeout: 264 seconds]
kristoff_it1 has quit [Ping timeout: 256 seconds]
hnOsmium0001 has joined #zig
<yZ5vlALg86lP>
how does one write `zig test` test cases that need linking against external symbols?
<yZ5vlALg86lP>
is there some build.zig magic incantation i have to do?
<daurnimator>
you just link the whole test.
<daurnimator>
`zig test -lfoo`
<yZ5vlALg86lP>
thanks. that woorks!
earnestly has quit [Ping timeout: 256 seconds]
<viaken>
g-w1: std.fmt.allocPrint did what I needed, but thanks for the pointer. And with that, I finished my first non-hello world Zig program. :)
<g-w1>
nice!
factormystic has quit [Ping timeout: 256 seconds]
<andrewrk>
anyone know what to do when vscode says "Request textDocument/semanticTokens failed" "Message: NotImplemented" ?
<andrewrk>
is it because my vscode is too old? 1.45.0
factormystic has joined #zig
<pixelherodev>
"Open a terminal, and run `vim` - that should fix your editor :)" (I can make this joke because I don't use Vim anymore ;P)
<andrewrk>
from discord: yeah it's beacuse my vscode is too old
<pixelherodev>
Found the first situation in which I have found the behavior of `cat *.foo >file.foo` is actually desirable: `cat *.deck >all.deck` ignores the previous contents and regenerates it from all the other *.deck files :P
lltt has quit [Ping timeout: 246 seconds]
adamkowalski has quit [Remote host closed the connection]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<andrewrk>
marler8997__, thanks for helping me out on stream! btw what do you think about making this the default when the OS is linux and the target is non-native? there would be the component that changes what the linker does, and then there would be a comptime bool that start code would look at before calling main()
<marler8997__>
andrewrk, yes, in fact that's exactly what I say in my previous comment before the one I linked you
<marler8997__>
QUOTE: " think by default it would be reasonable to change the default behavior based on whether we are compiling for native or cross targets. Find the system's dynamic linker at "link time" if we compile natively, and find it at runtime if we are cross compiling."
<andrewrk>
brilliant! sorry for just now noticing all this
Bekwnn has joined #zig
<marler8997__>
no problem, what brought this up all the sudden?
<andrewrk>
I mentioned it on the Handmade Seattle podcast that aired this weekend, and I wanted to explain the idea to some of the other conference attendees during the afterparty
<marler8997__>
oh cool
<andrewrk>
it's funny because we *also* discussed a closed source model vs an open source model and I was arguing that zig community members provide so much value that to me closed-source would be crazy. and then here I tried to figure out this thing and you already had a PoC
<marler8997__>
lol...closed source model like jai? bleh
<marler8997__>
I mean, I guess I'm ok with closed source as long as it's not closed to me :) But I emailed them about contributing and they just said they weren't hiring...so boo for closed source
<Bekwnn>
Hi all, I've been trying to debug an error code 5 I've started hitting since updating to 0.7 and beyond. Haven't been able to find any good info on it. Is it the same as gcc's error code?
<Bekwnn>
occurs on build after the full build.zig has run
<andrewrk>
hi Bekwnn do you have any more output you can share?
<andrewrk>
zig doesn't have error code numbers, so that message is probably coming from your terminal or something else
<ikskuh>
do we have an issue that is about "using zig on file systems that don't support locking"?
<g-w1>
I am seeing in std/fs.zig at the bottom on test "", there is _ = makeDirAbsolute; what is the point of this. it is a function, so is it testing the function, or making sure it gets included in the docs?
<pixelherodev>
g-w1: ensuring testing, probably
<ikskuh>
g-w1, it ensures the function is *referenced* so it will be compiled
<g-w1>
what do you mean referenced, so that every function in the stdlib is compiled not lazily? in a lib aren't all public functions compiled.
<ifreund>
no, not all public functions are compiled
<ifreund>
only if the are called or exported
<ifreund>
or referenced as done here
<g-w1>
wow, interesting, so it is not idomatic to ship a binary of a zig library?
xackus_ has quit [Ping timeout: 256 seconds]
<ifreund>
there is no stable zig ABI and probably never will be. shared libraries use the C ABI, libraries with a zig api are only distributed as source
xackus has joined #zig
kristoff_it has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 246 seconds]
<scientes>
maintaining two API/ABIs is twice the work
<scientes>
look at how much a PITA C++ ABI is
<ask6155>
Since zig provides c compilation support and I can link to musl is it a good idea to statically most of if not every library?
kristoff_it has quit [Ping timeout: 265 seconds]
<ikskuh>
scientes: C++ abi is only pain because people allow c++ functions to be exported into compiled libraries
<ikskuh>
ask6155: you cannot create object files from zig packages (so idiomatic zig code)
<ikskuh>
but you can create any C library as a static lib with either musl or glibc support
<ask6155>
So should I?
<ikskuh>
that's a philosophy question :D
<ikskuh>
i usually link most C libraries as source
<ikskuh>
not as static lib
<scientes>
ikskuh, yeah, because it is two APIs---the ABI and the API (but there is no difference, as Alan Turing pointed out)
<ikskuh>
i can't follow
<scientes>
C++ has two interfaces
<scientes>
instead of just a source interface
<scientes>
that is what you said
<scientes>
<ikskuh> scientes: C++ abi is only pain because people allow c++ functions to be exported into compiled libraries
<scientes>
you are explaining dynamic linking
<ikskuh>
ah
<scientes>
and dynamic linking is an additional API
<scientes>
even for zig the C ABI is a bit of a pain
<scientes>
but not nearly as bad as others
<scientes>
and llvm doesn't make it easy either, as you basically have to just study what clang does
<scientes>
instead of llvm supporting the classifications that are part of arch'es ABI documents
sawzall has quit [Read error: Connection reset by peer]
kristoff_it has joined #zig
<ikskuh>
well
sawzall has joined #zig
<ikskuh>
C ABI is specified, so you can also just follow the specification ;)
<earnestly>
It is?
<earnestly>
Wait, do you have links to specifications for C's ABI?
<marler8997__>
I bought a book on modern C++ a few years ago because it was so different
waleee-cl has joined #zig
<pixelherodev>
"How to write modern C++: don't"
<marler8997__>
I'm on his first slide with code and feel like throwing my hands in the air
<companion_cube>
I mean, it's very powerful, but wow, the complexity has jumped again
hlolli has joined #zig
<pixelherodev>
companion_cube: that's exactly why I'm never going to touch it - or anything written in it
hlolli_ has quit [Ping timeout: 272 seconds]
<companion_cube>
yeah I agree
<companion_cube>
I'm still kind of shocked, is all
<Sahnvour>
just skimmed through it, a lot of C++ quirks are getting fixed over time and with c++20 especially, so the complexity of writing code is actually reduced imho
hlolli_ has joined #zig
<Sahnvour>
complexity of the language+stdlib standard is another story
hlolli has quit [Ping timeout: 260 seconds]
<companion_cube>
maybe, but like, 3 syntaxes for concepts?
<companion_cube>
one of which is `(concept auto x)` to pass an `x`?
<Sahnvour>
I take it anyday over std::enable_if :D
<companion_cube>
ah yeah he mentions that
<Sahnvour>
agreed that's typical c++ bullshit but oh well
<marler8997__>
what's wrong with enable_if?
<companion_cube>
I mean I think these are good changes, especially modules
<marler8997__>
(still watching vid so maybe I'm just no caught up)
<companion_cube>
but damn, it's such a pile of complexity
<Sahnvour>
it's kind of a hack to emulate concepts, it's hard to parse for humans, and it compiles awfully slow
<companion_cube>
isn't it what Zig will have though? :)
<companion_cube>
(lack of concepts)
<pixelherodev>
Sahnvour: reducing complexity of writing code is meaningless if the implementation of the compiler is, well, C++
jjido has joined #zig
<Sahnvour>
companion_cube: no accepted proposal yet, or is there a stance against it in fine?
<companion_cube>
I honestly have no idea
<companion_cube>
but I think it's to be like in D, with compile time asserts and ifs
<companion_cube>
(not sure if a syntax for comptime precondition exists amyway)
<companion_cube>
anyway*
<Sahnvour>
hmm, that's unfortunate
<Sahnvour>
pixelherodev: why ?
<pixelherodev>
Because it's a dependency
hlolli_ has quit [Ping timeout: 272 seconds]
<marler8997__>
there's a proposal that woudl allow us to implement concepts inside the function signature
<pixelherodev>
If I write the cleanest code ever, and I depend on, say, LLVM, my code still sucks
<marler8997__>
will find..
<pixelherodev>
because all of LLVM is for all intents and purposes part of my code
<pixelherodev>
The same goes for the compiler you're building with
<pixelherodev>
It's why I dislike GCC and Clang - they're both terrible
<companion_cube>
people writing C++ don't care about their compiler being complicated, for sure
<Sahnvour>
I don't see your point
<pixelherodev>
"Good code + Bad compiler -> bad"
<pixelherodev>
"Bad code + good compiler -> bad"
<pixelherodev>
"Good code + Good compiler -> good"
<pixelherodev>
marler8997__: I meant more "if (@hasField(@TypeOf(...), ... ))" at the top of the function
<marler8997__>
yeah that's what I wrote
<marler8997__>
isNumber could use @hasField
<pixelherodev>
You wrote that as the return type
<pixelherodev>
... ah wait
<marler8997__>
that wasn't really the point
<pixelherodev>
You left return type blank :P
<pixelherodev>
Threw me off, I thought that block *was* the return type lol
<marler8997__>
sure, return type wasn't relevant
<marler8997__>
pseudocode
<marler8997__>
ah ok
<pixelherodev>
It doesn't count as pseudocode if it's 99% identical to real code!
<pixelherodev>
That's just confusing code!
<marler8997__>
lol
<marler8997__>
it's "chat code"...somewhere in between real/pseudo code :)
ur5us_ has joined #zig
cren has joined #zig
hlolli has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<hlolli>
If I do `var bitReader = std.io.bitReader; \n var bit_stream = bitReader(.Little, stream.reader());` I get `error: calling a generic function requires compile-time known function value`, fair enough, but if I change to `const bitReader = std.io.bitReader;` I get `error: expected type '*std.io.bit_reader.BitReader .... found '*const std.io.bit_reader.BitReader` should I post a pastebin for better clarity, or can I bypass var/const checks?
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<g-w1>
where is bit_reader coming from? std.io directly exports BitReader and it is a function, not a constant std/io/bit_reader.zig:176 does this help?
<hlolli>
I tried calling BitReader directly, I think it makes sense here that there are parts of this that needs to be known at compiletime."const bit_stream = BitReader(.Little, @TypeOf(stream)).init(stream);" I guess I'm running trough the gotchas, the tests in the source files help a lot.
<hlolli>
ok so maybe I'm doing something very basic wrong. `const std = @import("std"); \n const BitReader = std.io.BitReader;` this can't work because BitReader is a fn
<hlolli>
?
<g-w1>
well you can assign a function to a constant. this is how you bring a function into a namespace
neceve has quit [Ping timeout: 264 seconds]
radgeRayden has quit [Remote host closed the connection]
<hlolli>
I need to site over this a bit :) I see myself often disagreeing with the definition of const or var, I'd see a var being variable memory location and const be a const memory location. But probably it's nuanced.
<g-w1>
eventually functions will be: `pub const main = fn() void {}`. iirc 0.8.0
<hlolli>
nice, looks readable to me.
tracernz has quit [Read error: Connection reset by peer]
<justin_smith>
hlolli: within eg. function scope, you can't even guarantee that a variable hits heap, it might only be stored in a register or the stack
tracernz has joined #zig
<hlolli>
justin_smith it's a small world! :D
<justin_smith>
hlolli: small indeed, I spent some time learning arm 64 bit assembly, then decided I needed more experience with low level but not machine level programming, which led here
<justin_smith>
hlolli: I translated some jack example code into zig for example
omglasers2 has joined #zig
gpanders has quit [Ping timeout: 272 seconds]
<hlolli>
very nice, what led me here is the fact that I've been using nix a lot, and I want to write code which I can compile on nix and have it run everywhere, especially with wasm. I may steal some of your jack code. You mean you just called the libjack api directly? (I guess a wrapper library is unneccecary when you can call c functions directly).
<justin_smith>
hlolli: right, most of the work was taking the output of "zig translate-c" with the sample jack app and turning it into idiomatic code
<hlolli>
Yes, and when I learned that graalvm can't compile to wasm but only consume it, I kind-a gave up on graalvm and decided to give zig a try, compared to vlang and rust, I felt what andrewrk was doing was the better approach.
<justin_smith>
I did it as sort of an exercise
<hlolli>
nice, I used jackjni heavily in clojure.
gpanders has joined #zig
<justin_smith>
nice, I'm still stuck in that old set of rules that says you don't allocate or risk running GC in DSP code, so I never bothered with that
<justin_smith>
but I guess machines are fast enough these days that it can work
<justin_smith>
machines / gcs
<hlolli>
yes, so far the Allocator module seem to make the GC mechanism clear, I never got heavily involved with GC, only when jna would gc my pointers and crash the jvm, in which case I'd need to make sure I'm holding the references. But I look forward learning about it.
<justin_smith>
hlolli: the usual concern is that gc and allocation both take unpredictable amount of time, which is bad for real time DSP
<hlolli>
true, maybe as you point out, just not performing any GC should be fine for any limited DSP mechanism. Csound doesn't GC at all, just frees memory heap if it's not used anymore.
<justin_smith>
right, and it doesn't allocate memory inside DSP code either
<justin_smith>
instrument allocation is a separate step
<justin_smith>
and it doesn't rely on malloc for this (which introduces unpredictable pause times)
<hlolli>
I guess it's fine if you're not allocating instument in realtime. Compile before starting there's to say?
<justin_smith>
hlolli: as I understand it csound uses a pool for instrument allocations, no syscall
cren has quit [Quit: cren]
<justin_smith>
other than the initial allocation of that pool before dsp starts
<hlolli>
I was touching the instrument allocation slightly recently, there are many different parts to it, some inefficiant as far as I could tell.
<hlolli>
ah ture, that's defenitely the case
<justin_smith>
hlolli: anyway, my original point was I didn't try this stuff in clojure because clojure without allocation / gc is impossible
nvmd has quit [Quit: Later nerds.]
<hlolli>
Yes, when I do live code with clojure, I always put the ksmps high and the quality is overall low. But if I were to do a recording I'd always record the events to a score and render it offline. But I guess you are approaching this with more low latency realtime audio.
<hlolli>
Also I'm performing music often in smoke filled nightclubs with Berlin style PA system which have been victims of noise concerts and beer spills. So yet another reason I don't worry about a glitch now and then :)
<fengb>
Any sufficiently complicated C++ program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of ~Common Lisp~ Haskell
<companion_cube>
hell yes :p
<marler8997__>
lol
<companion_cube>
well it could at least contain ML
<companion_cube>
ML is nice and simple
<fengb>
HTML is an implementation of ML right? 🙃
<companion_cube>
nah, different 'M' :p
<companion_cube>
clearly markup < meta
<novaskell>
C++2030 turns out to just be strict haskell with angle brackets
<companion_cube>
strict haskell is basically ML
<companion_cube>
but yeah, that's where they're going
<companion_cube>
(converging with rust, too)
<novaskell>
wonder when Idris becomes the goal
<companion_cube>
I mean, C++ will never be pure, it's going to be tough
<fengb>
I don’t think you can shoehorn in Idris. (Although I wouldn’t expect shoehorning in ML either...)
<novaskell>
ATS2 but that'd be pure pain
<companion_cube>
is shoehorning a specific thing here? :D
<companion_cube>
what a weird video…
<novaskell>
since that does deal with mutation through refinement and linear types... and it comes with templates which give even better errors