<g-w1>
is * a person on irc? I dont see them in the people on it?
<waleee-cl>
sounds like something with your irc-client
* ifreund
indeed i am
<ifreund>
g-w1: * is /me
ur5us has joined #zig
skuzzymiglet has joined #zig
<dominikh>
hey. I have this weird problem where the following trivial program hangs indefinitely instead of exiting: https://play.golang.org/p/jvGMvrobK1F – is this expected or a known issue? for a non-trivial program, it executes fine (including async/await), then hangs when it should exit. I couldn't find a fitting issue on github
<waleee-cl>
dominikh: is NetworkSubsystemFailed an error you have added?
<daurnimator>
ifreund: I see I'm still winning the code golf ;)
<waleee-cl>
bah. Why didn't grep find it in lib/std/os.zig
<dominikh>
waleee-cl: the entirety of my code is this: https://play.golang.org/p/0p8ExGdjKMm – and all I'm doing is trying to build it with zig built from master
<pixelherodev>
daurnimator: you compressed the full string to 414?
<pixelherodev>
Or you mean that's your winning size?
<pixelherodev>
I think I might be able to get a working one under 400 without compression
<daurnimator>
pixelherodev: that's the winning size; and I think I compressed pretty well
<pixelherodev>
daurnimator, ifreund: dumb question, what'd you use to write to stdout? I was thinking of using write directly
<daurnimator>
dunno how much I should give away from my solution
<pixelherodev>
True :P
<pixelherodev>
If only there was a std.debug.warn equivalent for stdout :(
<pixelherodev>
s/warn/print/
<fengb>
Add it in a PR :P
<pixelherodev>
lol
<andrewrk>
what you actually want is @import("std").fizzbuzz(); so I do not recognize this as a use case for std.debug.warn equivalent for stdout :)
<pixelherodev>
lol
<pixelherodev>
My "write to stdout" is nearly 100 chars right now *winces*
<pixelherodev>
More than 100, actually. Ouch.
<pixelherodev>
Maybe I should drop fmt.format usage...
<daurnimator>
okay I'll tell you that my winning entry contains: `pub fn main()!void{const p=@import("std").io.getStdOut().writer().print;`
<pixelherodev>
... I totes forgot that exists :P
<pixelherodev>
Thanks :P
<pixelherodev>
I've used that in freestanding, how did I forget it exists??
<daurnimator>
if anyone can make that shorter I'd be interested.....
<daurnimator>
e.g. `io.File{.handle=1}.writer()` is a few characters longer
<waleee-cl>
that was surpsingly J-ish (the simultaneous assignment & usage)
earnestly has quit [Ping timeout: 260 seconds]
<pixelherodev>
oof
<daurnimator>
waleee-cl: what was/is?
<waleee-cl>
your stdout-main
<daurnimator>
waleee-cl: huh?
<daurnimator>
there is no usage there?
<waleee-cl>
right. General look & feel similar to J then
<daurnimator>
I don't see why it's similar to J....
<daurnimator>
it's in most languages e.g. in javascript you could write `function main(){const p = require("something").foo().bar();`
kristoff_it2 has quit [Ping timeout: 256 seconds]
<pixelherodev>
I can't compress the full text below ~800 bytes :(
<pixelherodev>
That would've been a fun strategy
<g-w1>
would var p be better, less text
<daurnimator>
g-w1: `error: variable of type '(bound fn(std.io.writer.Writer(std.fs.file.File,std.os.WriteError,std.fs.file.File.write),[]const u8,anytype) anytype)' must be const or comptime`
<waleee-cl>
(re J, the J scores on code.golf is disappointedly long it sems)
<g-w1>
oh, that makes sense, cool. you just ruined my master plan :)
<waleee-cl>
s/long/high/
<pixelherodev>
With bzip, I can get it down to ~575 bytes, but that's still not adequate
<pixelherodev>
Impressive (given input is >10KiB), but not good enough
<pixelherodev>
(and bzip isn't supported by stdlib so it's more a thought experiment than anything else :P)
CmdrCrisp has quit [Ping timeout: 260 seconds]
ask6155 has joined #zig
<pixelherodev>
Ugh, at 500 currently...
<pixelherodev>
This does prove that manual compression into a Turing-complete language can exceed even the best "normal" compressors
<pixelherodev>
New compressor idea: zz. A Zig-based compressor that compresses arbitrary text input into the shortest possible Zig program possible :P
<justin_smith>
pixelherodev: this exists in the world of DSP, it's called generative compression https://arxiv.org/abs/1703.01467
ask6155 has left #zig [#zig]
<justin_smith>
simplest possible version: turn a sine wave, unit amplitude, at 440 hz lasting 3 years, into a tuple {sin, 1, 440, 94608000}
<justin_smith>
of course real usage won't use such a dumb special case generator
ask6155 has joined #zig
klltkr has quit [Ping timeout: 265 seconds]
<pixelherodev>
Hmm. hmmmmm.
ask6155 has left #zig [#zig]
<justin_smith>
pixelherodev: classic example might be a fractal generator, which could be said to contain ~infinite detail in a single formula (or even pi if you iterate down all the digits...)
xackus_ has joined #zig
xackus has quit [Ping timeout: 240 seconds]
<pixelherodev>
ifreund: sorry! :)
<pixelherodev>
Oh... oops.
<pixelherodev>
I just spent at least an hour on it...
* pixelherodev
facepalms
<pixelherodev>
and daurnimator is still ahead of me by a bit! :P
lucid_0x80 has joined #zig
lucid_0x80 has quit [Ping timeout: 240 seconds]
ask6155 has joined #zig
<pixelherodev>
daurnimator: I think I'm going to give up and let you keep first.
<pixelherodev>
*eighteen freaking bytes* ugh
<pixelherodev>
Ooh, I think I have it
ur5us has quit [Ping timeout: 260 seconds]
<daurnimator>
pixelherodev: I'm curious to see your solution
<pixelherodev>
daurnimator: same :)
<pixelherodev>
Trade?
<daurnimator>
as the winner I'm not sure if I should ;)
mmohammadi9812 has quit [Ping timeout: 258 seconds]
mmohammadi9812 has joined #zig
ur5us has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 265 seconds]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
ask6155 has left #zig [#zig]
Kingsquee has quit []
earnestly has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
cole-h has quit [Ping timeout: 260 seconds]
ur5us has quit [Ping timeout: 260 seconds]
rzezeski has quit [Quit: Connection closed for inactivity]
frett27 has joined #zig
FireFox317 has joined #zig
ask6155 has joined #zig
<ifreund>
Ugh, I am also 1 byte off on quine
<daurnimator>
quine cheat: the file name is code.zig
<ask6155>
how do I use the -L flag? I have a folder with .h files and a folder with .so(s). In zig I get the error that it can't find `#include <x/x.h>` and I have put them in a seperate folder(for reasons). So how do I make zig find them?
<daurnimator>
ask6155: -I
<ifreund>
oh, I was using @src().file :D
<ifreund>
there's the byte
<ask6155>
daurnimator, ah that was it
FireFox317 has quit [Quit: Leaving]
<ask6155>
I think this is unrelated but I'm getting an unrecognised glibc version error.
<ask6155>
`unrecognised C ABI`
<ifreund>
ask6155: are you using zig 0.6.0?
<ask6155>
yes
<ask6155>
latest release
<ifreund>
your system glibc version is probably too new, this is an issue that has been fixed in master and won't be a problem with 0.7.0
<ask6155>
it's in staging and hasn't gotten into extra (yet)
<ask6155>
oof
<frett27>
andrew is in personal troubles now, i think the 0.7 can wait a bit, as there are all elements on github / master
ask6155 has left #zig [#zig]
xackus_ has joined #zig
ask6155 has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
ask6155 has left #zig [#zig]
kristoff_it1 has joined #zig
kristoff_it2 has quit [Ping timeout: 260 seconds]
bgiannan has quit [Read error: Connection reset by peer]
WilhelmVonWeiner has quit [Ping timeout: 258 seconds]
nvmd has quit [Quit: Later nerds.]
<geert_>
exit
<geert_>
quit
<geert_>
geert_ has quit [Quit: Lost terminal]
xackus_ has quit [Ping timeout: 256 seconds]
data-man has joined #zig
frmdstryr has joined #zig
donniewest has joined #zig
<data-man>
ask6155: I use clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz in Arch, installed to /opt/llvm
<data-man>
And cmake -DCMAKE_PREFIX_PATH=/opt/llvm -DZIG_PREFER_CLANG_CPP_DYLIB=OFF for building
data-man has quit [Quit: Konversation terminated!]
Kena has joined #zig
<ifreund>
you can also just grab the arch package from staging
<Kena>
Hello binary and digital people. Is the continue expression in a while loop evaluated after the expression in the loop? or it is before?
<earnestly>
continue would necessarily have to be evaluated after the current loop iteration and before the next
<Kena>
Thank you buddy.
moinstar has joined #zig
<Kena>
I have a interrogation for a long time and still do not understand, what is the interest (or the use case) for compiling from source instead of using some pre-compiled binaries?
<pixelherodev>
In what context?
<g-w1>
maybe you don't trust the binary, or there is not a binary released for your platform, or you want cpu-specific optimisations
<pixelherodev>
Or you want to disable specific features
<earnestly>
A main reason is for different architectures and combinations of features which would require an exponential number of pre-compiled binaries. Another important reason is knowing if the binary you receive is actually the binary that would be produced from the source (reproducibility)
<Kena>
I'm unable to answer that, I'm just trying to figure out why anyone would want to compile zig from source instead of merely downloading the pre-compiled binaries and use it as it is.
<pixelherodev>
Ah, for Zig in particular
<earnestly>
Someone has to also pre-compile binaries
<pixelherodev>
Maybe you suspect a trusting trust attack :P
<Kena>
lol
<earnestly>
At least the problem has been countered
<Kena>
Allright, thefore it is for security policy reasons.
<earnestly>
Although not in zigs case because there's only one implementation
<pixelherodev>
Kena: that's *one* reason
<pixelherodev>
It depends on who's doing it
<pixelherodev>
earnestly: I meant in the C++ compiler ;)
<earnestly>
pixelherodev: Hm?
<pixelherodev>
I'd say "a very smart trusting trust attack" but frankly it'd still be less complex than the compiler itself.
<earnestly>
pixelherodev: Defeating the Trusting Trust problem requires multiple implementations
<Kena>
Ah yes, missed the other replies, thanks guys :)
<earnestly>
See Wheeler's thesis on Diverse Double Compiling
<pixelherodev>
"Defeating" trusting trust requires going all the way back to the assembler.
<earnestly>
No, see reference
<pixelherodev>
I have.
<pixelherodev>
But at a certain point you can start asking, "hey, if the *compiler* could be suspicious... what about the text editor? or assembler? or hex dumper?"
<pixelherodev>
What if `sha256` is compromised and is lying when it says that the produced compilers match?
<pixelherodev>
or `ls -l` was compromised to give the wrong length when a compiler was detected?
<earnestly>
It's further a problem when you know proof doesn't compose
<earnestly>
So you have to audit the entire system as a whole
<pixelherodev>
The obvious answer is to use a system simple enough that you can inspect it with a logic probe ;)
<pixelherodev>
e.g. a z80-based system. You can literally see what it's reading from memory - *if you can trust the logic probe* ;P
<earnestly>
Or Wirth's Oberon heh
<pixelherodev>
At a certain point, it's more an exercise in paranoia than a legitimate concern
<g-w1>
is z80 used anymore? is it a mainframe os?
<pixelherodev>
I use the z80 personally, and I'm working on designing a physical computer using one
<g-w1>
you use it as a day to day os?
<pixelherodev>
I was initially doing that as a hobby project for a game system, but now I genuinely want to use such a system for typical tasks (word processing, for instance)
<pixelherodev>
g-w1: not *yet*, but hopefully within the next two years
xackus_ has joined #zig
<g-w1>
nice
<earnestly>
pixelherodev: Are you using zig with it currently?
<pixelherodev>
Hahahahahaha, with a *z80*?
<earnestly>
For it
<earnestly>
(Does llvm even support it...)
<pixelherodev>
I want to add a z80 backend to stage2 eventually, but I'm focusing on CBE for the 0.8 release
<pixelherodev>
There was a revived patchset for LLVM-z80 support a few weeks back I think
<pixelherodev>
There's a couple attempts going on, and at least a dozen abandoned ones ranging back over the past fifteen years.
<earnestly>
Why you might want to build things yourself
skuzzymiglet has quit [Ping timeout: 240 seconds]
<Kena>
Decidedly, you made my day, I will vote for you as the new chairman for noobies corporation.
<Kena>
But maybe the guy's account suffered from social ingeneering to provide the community with false information, so logic probe fails here :D
<Kena>
Or maybe the owner's account is legitimate but he secretly suffers from schizophrenia and even Ocaml or Coq can't beat it with their formal proof-driven theory.
Sergeeeek[m] has joined #zig
moinstar has quit [Quit: Leaving.]
frmdstryr has quit [Ping timeout: 260 seconds]
<Kena>
It is desirable for a software to be written in order to compute the more possible informations at compilation time or is insane at a certain point?
<earnestly>
The earlier you can find errors the better
<dutchie>
also, normally you compile once and run often, so if you can compute things in the compile step you end up saving time overall
<earnestly>
Stepanov often jokes about how programmers tend to compute the same thing repeatidly in their software
<earnestly>
Even if it's trivial things like n / 1024 / 1024, which could be n / 1024 * 1024, which is then just n / 1048576. One less division. Or in other cases where a function computes some aspect of its input and then throws it away. E.g. printf usefully returns the number of bytes it wrote instead of discarding it
<pixelherodev>
earnestly: except that those are optimized *anyways&
<pixelherodev>
*
<pixelherodev>
Not the printf example, that's definitely true
<pixelherodev>
But anything involving basic arithmetic is downright trivial to optimize
<pixelherodev>
I'd disagree with the idea that "as much as possible should be put in to compile time"
<pixelherodev>
Some things are more expensive to compute at compile time than at run time by such a large margin that the time "saved" at runtime is so miniscule you'd have to run the program for millenia to make up for the cost incurred by a single compilation
<pixelherodev>
I'd say that for *release* builds, as much as possible should be done at compile time, generally, since those are meant to be run for orders of magnitude more than they're compiled
<pixelherodev>
But, since programmers spend most time (hopefully) in debug mode, that rule absolutely doesn't hold true - and the complexity needed to selectively build pieces at compile time is nowhere near worth the little bit it would gain
<pixelherodev>
What's the old line, "programmer time is expensive, hardware is cheap?" Faster compilations = less programmer time = money saved. You're welcome ;)
<Kena>
Thanks for the explanations, I always asked myself if the industry, even the embedded devices or internet of things, would benefit from software mostly computed at compile time.
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 272 seconds]
Akuli has joined #zig
<earnestly>
pixelherodev: His perspective is not about making assumptions of the compiler, obviously in that sort of context it doesn't make sense
<earnestly>
pixelherodev: This is an example of the kind of thing he starts out with: https://0x0.st/ikWp.bin (c++ file)
<Kena>
So time is more important than space I can conclude.
<earnestly>
It depends
<pixelherodev>
Depends on who you ask, what project you're working on, your priorities, etc
hnOsmium0001 has joined #zig
<g-w1>
this code doesn't work. it says that it found a [13]Card instead of [52]Card. what am I doing wrong const deck_arr: [52]Card = [52]Card{ .two, .three, .four, .five, .six, .seven, .eight, .nine, .ten, .jack, .queen, .king, .ace, } ** 4;
<dutchie>
the right hand side has 13 members
<g-w1>
ah. i had to do this: const deck_arr: [52]Card = [13]Card{ .two, .three, .four, .five, .six, .seven, .eight, .nine, .ten, .jack, .queen, .king, .ace, } ** 4;
<g-w1>
im pretty sure that is true. in std.zig:94 you will find the thing that does all the magic.
osa1 has quit [Remote host closed the connection]
frmdstryr has joined #zig
geert_ has joined #zig
<pixelherodev>
Or at least *most* of the magic :)
<g-w1>
where is the rest of the magic?
<geert_>
Following the Zig language for awhile and made some important tools with it. The question is how could I contribute with coding and docs? Just ask on an issue on Github or is their a better way?
jicksaw has quit [Quit: ZNC is kill]
<g-w1>
I got started by looking at some of the issues on github with the contibutor friendly tag and then trying to solve them. I found the ones relatting to main.zig to be the easiest, probably because it has bugs because it is pretty new. this one looks fairly easy if you are farmilar with tokenizers: https://github.com/ziglang/zig/issues/6823.
<geert_>
thanks
<g-w1>
I have only made 2 prs and working on 3rd so I am not expert by any means
<geert_>
Just fix them and not ask to fix them in the comments?
<g-w1>
yeah!
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<johnLate>
Is there any difference between "!void" and "anyerror!void"?
xackus_ has joined #zig
FireFox317 has quit [Quit: Leaving]
<andrewrk>
the former error set is inferred; the latter is the global error set
CmdrCrisp has joined #zig
<Kena>
the inferred one does NOT benefit from additionaly optimizations right?
<andrewrk>
in theory it's possible, in practice not likely. the main purpose of inferred error sets is to help you, the programmer, cover all the edge cases
<companion_cube>
imho, type inference should *never* change the underlying behavior
jicksaw has joined #zig
<companion_cube>
(i.e. a fully annotated program is the same as the program with some types inferred)
<Kena>
That reminds me, one principle of Python or D (don't recall): explicit is better than implicit.
<companion_cube>
always thought it was rich that python had that in its zen
<Kena>
Please does the `|_|`represent a anonymous payload?
<companion_cube>
_ just means to ignore a value
tane has joined #zig
<andrewrk>
companion_cube, type inference could potentially provide more information to the optimizer, is all
<Kena>
It's just a captured value (or payload) without an name, is that right?
<companion_cube>
andrewrk: ah, if the type inferred is smaller than anyerror? yeah
<companion_cube>
but then it should still be the same as writing the exact error set
<travv0>
is the logic behind not having compiler warnings that something is either fine to do or it's forbidden? i remember seeing andrewrk say in an issue that no warnings is deliberate and was wondering if there was more info somewhere on the decision
<companion_cube>
(the LSP should be able to suggest the exact error set, ideally)
<justin_smith>
Kena: in other languages _ is a valid identifier, and by convention it's used for values you need to exist but don't actually touch
<travv0>
cause i've been bitten by stuff like forgetting to use an argument or something in a function before and wished there was a warning about it
<companion_cube>
afaik in all languages that have destructuring/pattern matching, _ is the wildcard
<justin_smith>
companion_cube: but it's used when you aren't interested in binding the value in that position, right?
<companion_cube>
yes
<companion_cube>
matches anything, discards the value
<Kena>
But it is interesting for the compiler? I mean does `|_|` allow to allocate a smaller memory space for the payload than it would do with `|value|` syntax? In a for or while loop context I mean.
<justin_smith>
Kena: the compiler shouldn't warn / error if you rebind _
<Kena>
Allright, thank you.
<justin_smith>
usually shadowing does error
<justin_smith>
Kena: I guess hypothetically you could save stack space if you know you aren't using a block local?
CmdrCrisp has quit [Ping timeout: 260 seconds]
<Kena>
Yes, I beginning to grasp some wisdom shards along the way. I hope there will be more memory management-related informations in the docs during the upcoming release.
<Kena>
It's cleary the kind of mechanics that it seduces me and push me into the low-level language segment.
<justin_smith>
I would if that would be saving the space of a full copy of the object, or just a pointer?
<Kena>
a pointer! :D
frett27_ has joined #zig
<companion_cube>
I imagine it's just like ignoring the result of some expression
<companion_cube>
the compiler is free to not store it
frett27 has quit [Ping timeout: 240 seconds]
xackus_ has quit [Ping timeout: 260 seconds]
skuzzymiglet has quit [Ping timeout: 264 seconds]
skuzzymiglet has joined #zig
Patrice_ has joined #zig
geert_ has quit [Ping timeout: 256 seconds]
frett27_ has quit [Ping timeout: 265 seconds]
Kingsquee has joined #zig
cole-h has joined #zig
xackus_ has joined #zig
riba has joined #zig
<Kena>
Please do you know about an article that explain how does a compiler work? like the lexical analysis, the parsing, the analysis semantic, code generation and linking. It could help a noob like me to better understand how zig deals about memory.
<earnestly>
Kena: Look up the Dragon Book
<g-w1>
Kena: honestly, the self hosted compiler is a very good example for the frontend of the compiler. Right now I am writing a compiler to learn, and I kinda just winged it for the semantic anlysis and codegen. the llvm tuturial is also pretty good. here are some resources I found useful when writing my compiler https://github.com/g-w1/ezc#resources .I hope this helps you!
<Kena>
Thanks, do you think "Compilers: Principles, Techniques, and Tools" from Dragon book published in 2006 is nevertheless better than the most recent ones from other publishers?
<frmdstryr>
lld uses blx instruction, no object with architecture supporting feature detected
<frmdstryr>
Anyone have any info on what that means / how to fix it?
<frmdstryr>
It's an stm32l5 (cortex-m33)
<justin_smith>
I'm trying to use a slice with an API that takes a "user data" void pointer
<g-w1>
slice.ptr
<justin_smith>
I'm able to use @ptrCast to make a *c_void from the slice, but how do I get the slice back from the void?
<justin_smith>
I can only provide one arg, I'd like to pass the slice so that I know the count when I get it back
<justin_smith>
or do I need a sentinal null?
mmohammadi9812 has quit [Remote host closed the connection]
mmohammadi9812 has joined #zig
skuzzymiglet has quit [Remote host closed the connection]
<justin_smith>
g-w1: that gets the pointer, but loses the length info, what I really want is to round trip the slice itself
<g-w1>
does the length change after you pass it to the api
<justin_smith>
never
<justin_smith>
all it does to my void pointer is pass it back to my callback
<g-w1>
so why dont you just pass the pointer and keep the length with ptr.len
skuzzymiglet has joined #zig
<justin_smith>
g-w1: because my callback only gets the data from the API
skuzzymiglet has quit [Client Quit]
skuzzymiglet has joined #zig
<justin_smith>
g-w1: I can't "keep" anything, I register a handling function and a void pointer, that function is called later with that pointer as an arg
<g-w1>
ohh. If this were me I would make an array with [len, ...rest of elements] and then pass that.
<g-w1>
so you know the first element is the len
skuzzymiglet has quit [Client Quit]
<justin_smith>
g-w1: I was trying to use a slice for this, because I thought that was what a slice was
<g-w1>
ok
<justin_smith>
but I couldn't get the conversion from void back to slice, and maybe that's the wrong way to do this
skuzzymiglet has joined #zig
<tane>
justin_smith, take a pointer to slice, cast it to *c_void, then cast that back to pointer to slice
<g-w1>
there should be a way.
<justin_smith>
tane: OK, I thought I was doing that, clearly I'm doing something else stupid
<someguestguy>
you end up with undefined behavior if your input value isn't part of an non-exhaustive enum
<someguestguy>
I want to do a if-check to either print the tag name or not if the tag is present, but I can't really just return "no tag name" but I don't know how to use the builtins (typeof, typeinfo, etc) to check.
<someguestguy>
error messages aren't helping a lot on how to access the members (printing @typeInfo(@typeof()) confused me.
<someguestguy>
basically how do I get @tagName to not invoke undefined behavior, or fi
<someguestguy>
if-check*
<someguestguy>
for whether it's available then either call @tagName or not.
<someguestguy>
(nevermind, someone pointed me to the std.meta versions where it doesn't panic and instead returns an error)
someguestguy has quit [Remote host closed the connection]