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/
omglasers2 has quit [Read error: Connection reset by peer]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
osa1 has quit [Ping timeout: 256 seconds]
msingle has quit [Ping timeout: 240 seconds]
radgeRayden has joined #zig
ur5us_ has joined #zig
osa1 has joined #zig
<andrewrk> g-w1, source from the fs
<pixelherodev> andrewrk: for bool in CBE - since bool doesn't exist pre-C99 - should we add an ifdef set to the header defining bool as unsigned char, false as zero, and true as one for C89 (and including stdbool on later revisions)?
<pixelherodev> Or just use integer values explicitly?
<ifreund> why are we supporting pre-C99 now? can't that wait?
<pixelherodev> ifreund: We're supporting C89 officially
<pixelherodev> With ifdef-based support for later revisions
<ifreund> just curious, are there many compilers that support C89 but not C99?
<pixelherodev> probably not
<ifreund> what's the logic behind targeting C89 then?
<pixelherodev> We use the lowest common denominator, while still taking advantage of later support when it is present
<pixelherodev> So yeah, that actually tells me exactly what to do :P
<pixelherodev> ifreund: e.g. we use _Noreturn on C11, or __attribute(noreturn) on GCC, but leave it as plain void for compilers which don't support those
<ifreund> that all makes sense to me
msingle has joined #zig
<ifreund> I'm just wondering if there's a compelling reason to support C89 other than "because we can"
<pixelherodev> Just because most compilers support C99 doesn't mean we should rely on it
<dominikh> any love for K&R C?
<pixelherodev> GCC/Clang both support C11, and people are probably going to argue we should use that as the base as a result
<pixelherodev> dominikh: nope :P
<pixelherodev> Only ISO C
<pixelherodev> ISO/ANSI, at any rate
<andrewrk> ifreund, pixelherodev: I see no reason to support anything besides C89 for the C backend
<andrewrk> the output is not supposed to be readable, it's supposed to be widely compatible
<andrewrk> for #6378 we'll have a branch where we hack up the C backend for the one time transformation to make the output readable, do it, then delete the branch and forget about it
<pixelherodev> Good news: got header tests working, so tetsuo's emit_h branch is just about ready for merge :)
<andrewrk> nice
<pixelherodev> whoa!
<pixelherodev> `and` for `&&` is part of C95??
<ifreund> supporting only C89 makes more sense to me than supporting all the more recent versions as well
<pixelherodev> ifreund: it's not really "supporting"
<g-w1> after the c self-hosted compiler, will you have to update the c every time you update the zig, or will the c-based compiler be just good enough to compile the the zig compiler?
<pixelherodev> e.g. unreachable is only present as a GNU extension - so when it's available, we use it, because it's a more faithful recreation
<ifreund> my point was more that focusing on a single target would probably make getting that target to feature completion faster, but I'm not the one doing the work so feel free to ignore me of course
<pixelherodev> g-w1: at that point, the language is intended to already be stable
<g-w1> ah
<pixelherodev> ifreund: there's no real effort involved lol
a92 has joined #zig
<pixelherodev> it's a tiny 5-line ifdef in a common header file
<ifreund> nice
<pixelherodev> As far as the CBE is concerned, e.g. zig_unreachable() is guaranteed to exist
<pixelherodev> It just happens to be a nop on many platforms
<ifreund> yeah I see what you mean now, that's quite a nice way of handling things
<andrewrk> pixelherodev, your proposal regarding stdbool.h and ifdefs sounds reasonable to me
squeek502 has quit [Remote host closed the connection]
<pixelherodev> Added a bit of type support to CBE too while I was it
<pixelherodev> s/it/at &
<g-w1> when the language is stable and it has a c based compiler, lets say the version upgrades to 2.0, then will the c based compiler be updated? if so, manually or automatically? or will it be so stable that the newer version is just more optimisations and stuff, but the semantics are the same?
<pixelherodev> g-w1: the idea is to never update the language like that after 1.0
<pixelherodev> First header test passing :)
<andrewrk> g-w1, manually
<g-w1> thx
earnestly has quit [Ping timeout: 256 seconds]
hlolli__ has quit [Ping timeout: 272 seconds]
msingle has quit [Ping timeout: 240 seconds]
<pixelherodev> Now to just add CBE Execution support via `argv[0] cc` :D
<pixelherodev> Then CBE test harness will be basically done
msingle has joined #zig
<g-w1> is there a way to do @fieldParentPtr in gdb, or the equavalent?
<pixelherodev> Uh, so I just updated zig master, and now every attempt to build gives "cacheunavailable" :(
<torque> it's possible that the cache is not available
AlbinoDrought has quit [Quit: quit]
<pixelherodev> lol
<pixelherodev> Wiped the cache, problem persists :(
<g-w1> did you wipe the global cache?
<pixelherodev> Nope
<pixelherodev> Good call, let's see if that helps
<pixelherodev> Seems to have helped, good catch!
<daurnimator> pixelherodev: I once suggested a `#include <zig/common.h>` that does all sorts of ifdefs
<pixelherodev> daurnimator: that's basically what we do...
<pixelherodev> daurnimator: we just inject it automatically into every file instead of requiring an include
a92 has quit [Quit: My presence will now cease]
msingle has quit [Ping timeout: 240 seconds]
<pixelherodev> andrewrk: to run zig cc, should I make main's buildOutputTpe public, use std.process.args (ugh) to find argv[0] and exec it, or something else entirely?
<pixelherodev> punt_to_clang, maybe?
<pixelherodev> ZigClang_main might be good...
msingle has joined #zig
<daurnimator> why isn't the zig compiler a library itself (like clang is)
<pixelherodev> Why should it be?
<andrewrk> it's structured that way - what changes would you expect to see from status quo?
<pixelherodev> ZigClang_main will act exactly like running clang with the given arguments, correct?
<daurnimator> andrewrk: actually it's better than I remember. couple of things: 1. execve is a spanner in the world. 2. entry points (at the moment `mainArgs`) or a C-abi friendly wrappers should be exported 3. don't rely on cwd anywhere: take the working dir as an argument
<andrewrk> pixelherodev, correct
<andrewrk> daurnimator, libraries should use Compilation as the library entry point, not main.zig
<andrewrk> so I think (2) is the only issue
<andrewrk> not sure what you mean by "spanner"
<pixelherodev> Ah, right! I can use Compilation to compile C?
<pixelherodev> Or is that for Zig only?
<andrewrk> yes
<andrewrk> it will rely on executing self_exe_path with `zig clang` args
<andrewrk> so the main problem you have to solve is making that work
<daurnimator> andrewrk: uh "spanner in the works"
<andrewrk> daurnimator, I'm still not following, can you elaborate on (1)?
<daurnimator> > To throw a spanner in the works is to, deliberately or otherwise, cause disruption; to interfere with the smooth running of something.
<andrewrk> oh, I see. in the u.s. we call that a monkey wrench
<andrewrk> pixelherodev, I had a plan for this, which is that for testing stage2 we would actually pass the zig_exe_path as self_exe_path
<daurnimator> andrewrk: there are a few places where main.zig calls `execve`: if someone was trying to use zig as a library in that manner, then they would be unhappy :)
<andrewrk> I'm not ready to make a stable C API for the compiler, but it is written cleanly, with Compilation being the entry point API and main.zig doing not much more than CLI parsing
<daurnimator> so if I wanted to e.g. `zig translate-c` as a library, how would I do it? https://github.com/ziglang/zig/blob/6d3c176c127b3475a2202b0edd4855374c7ead30/src/main.zig#L19 doesn't seem to be public
<andrewrk> pixelherodev, we have Builder.zig_exe when doing `./zig build test-stage2` so the only problem to solve is getting that path to be available when we invoke `zig test src/test.zig`
<andrewrk> maybe we can use addArg on the resulting LibExeObjStep for the test, and then get the arg from src/test.zig
<andrewrk> I think that would be a matter of putting `pub ` in front of `const translate_c = @import("translate_c.zig");`
<andrewrk> I'm not being sarcastic
kristoff_it has quit [Ping timeout: 256 seconds]
wilsonk__ has joined #zig
ur5us_ has quit [Ping timeout: 260 seconds]
wilsonk_ has quit [Ping timeout: 264 seconds]
osa1 has quit [Quit: osa1]
osa1 has joined #zig
wilsonk_ has joined #zig
wilsonk__ has quit [Ping timeout: 256 seconds]
msingle has quit [Ping timeout: 240 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
siraben has joined #zig
<siraben> Does Zig have a package system?
<siraben> s/system/manager
<pixelherodev> Not yet
AlbinoDrought has joined #zig
AlbinoDrought has quit [Changing host]
AlbinoDrought has joined #zig
CodeSpelunker has quit [Quit: CodeSpelunker]
waleee-cl has quit [Quit: Connection closed for inactivity]
<siraben> Any Nix users here with examples of how they build Zig projects?
<josias> siraben: There are a couple inofficial package managers. Including https://github.com/mattnite/zkg
<novaskell> I use guix (similar) and mostly sidestep the package system for now until it's more stable. Handling it properly in package scripts would be the same deal as Rust where you place everything into a reachable directory and then call `zig build` on it and copy the binary. Sadly lose the cache when you do so though
<siraben> Levy (Elara): Nix has a `buildRustPackage` function abstracts away those details https://nixos.org/manual/nixpkgs/stable/#compiling-rust-applications-with-cargo
<siraben> Potentially one could be made for Zig as well
<siraben> Building Zig itself seems to fail ATM, src/os.cpp:1105:9: error: use of undeclared identifier 'futimens'
<siraben> if (futimens(file, times) == -1) {
<siraben> ^
<siraben> (on macOS)
<daurnimator> andrewrk: that's a simple fix at least: adding `pub`... and creating a package :)
<novaskell> siraben: Guix has the same though it doesn't gain anything from guix and the sometimes "smarter than average" build.zig scripts make some of it non-trivial at the moment
<siraben> I see. Can you specify versions of packags and pin them?
<siraben> packages*
<novaskell> same as nix, you can pull packages from the future and the past and pinning is just creating a package/manifest referencing a specific commit/release
<siraben> Ah yeah I mean in the context of Zig's packages
<novaskell> inherit/derive a package (if it exists) then specify a fixed commit/release? Nix/Guix don't really care about what version something is as much as they care about where to get it and what the has of the content is
<siraben> As in, Rust has Cargo.lock, does Zig have some lockfile
<novaskell> ah, there's no package management at the moment in zig at present
<siraben> I see
<novaskell> so no lock file or concept of versions
decentpenguin has quit [Quit: ZNC crashed or something]
decentpenguin has joined #zig
<daurnimator> siraben: are you on old OSX? futimes was only added in 10.13 which is the frequent cause of that error message
<siraben> daurnimator: I'm on 10.15, but I'm using the Nix package manager which hasn't updated its libsystem from 10.12 to 10.13 yet, https://github.com/NixOS/nixpkgs/pull/101940
<daurnimator> siraben: they better hurry up and get to 10.16...
<daurnimator> uh, 10.14 sorry
<daurnimator> we're likely to drop support for 10.13 soon
<siraben> 10.13 is being EOL'd?
<daurnimator> I expect so; generally they EOL a month after the 3rd following release
<siraben> Where would I find Apple's LTS schedule?
<daurnimator> --> big sur (10.16) was released 7 days ago
<daurnimator> so 10.13 will fall out of support before the end of the year
<siraben> Why would Zig require such new dependencies?
<daurnimator> siraben: we only support what OS vendors support.
THFKA4 has quit [Ping timeout: 260 seconds]
THFKA4 has joined #zig
osa1 has quit [Quit: osa1]
osa1 has joined #zig
sord937 has joined #zig
haliucinas has joined #zig
omglasers2 has joined #zig
omglasers has joined #zig
AlbinoDrought has quit [Remote host closed the connection]
AlbinoDrought has joined #zig
AlbinoDrought has joined #zig
omglasers2 has quit [Ping timeout: 272 seconds]
skuzzymiglet has joined #zig
skuzzymiglet has quit [Ping timeout: 260 seconds]
cole-h has quit [Ping timeout: 264 seconds]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
jjido has joined #zig
sord937 has quit [Quit: sord937]
sord937 has joined #zig
earnestly has joined #zig
hlolli__ has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
msingle has joined #zig
msingle has quit [Ping timeout: 240 seconds]
marnix has quit [Ping timeout: 260 seconds]
marnix has joined #zig
_whitelogger has joined #zig
marnix has quit [Read error: Connection reset by peer]
xackus has joined #zig
marnix has joined #zig
lucid_0x80 has joined #zig
xackus has quit [Quit: Leaving]
xackus has joined #zig
lltt has quit [Ping timeout: 240 seconds]
covfefe2proofs has joined #zig
covfefe2proofs has quit [Remote host closed the connection]
msingle has joined #zig
techtirade has quit [Read error: Connection reset by peer]
techtirade has joined #zig
donniewest has joined #zig
kristoff_it has joined #zig
Enrico2048 has joined #zig
Enrico204 has quit [Ping timeout: 264 seconds]
Enrico2048 is now known as Enrico204
donniewest has quit [Remote host closed the connection]
CodeSpelunker has joined #zig
techtirade has quit [Remote host closed the connection]
techtirade has joined #zig
waleee-cl has joined #zig
a_chou has joined #zig
osa1 has quit [Quit: osa1]
osa1 has joined #zig
donniewest has joined #zig
Kena has joined #zig
<Kena> Please how can I read what I wrote in a file? I tried several times with `print` but that does print the bytes written. https://zero.hurtig.ninja/?699e74331f90d8fc#By97/P++ArXJQ0v7lxVnVyu2RTiHE4JXB1UjvN3FWIM=
<Kena> I'm not a programmer so everything that is not on ziglang.org or ziglearn.org is beyond me.
<ifreund> you probably want to print what gets written to your buffer
<Kena> That's right.
<ifreund> oh readAll returns a slice doesn't it? thats what you want to print but it won't have an items field...
<ifreund> nope it does return a usize
hnOsmium0001 has joined #zig
<Kena> Its return a usize, so it doesn't have a field access to items.
<ifreund> then you want to print buffer[0..bytes_read]
<Kena> print("{}\n", .{buffer}); returns the bytes written but with a artifact after the string like: Cybernetics¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
kristoff_it has quit [Ping timeout: 260 seconds]
<ifreund> yeah, because you want to only print the bytes you actually read
<Kena> I think that the bytes allocated by the bufffer but not used.
<ifreund> so slice the buffer from 0 to bytes_read
<Kena> Yes you're right.
<Kena> Cool, thank you.
<Kena> Do you know what function to use to read a user input instead of hard code a string into the source?
<Kena> Instead of `writeAll` from the std.file.File type I mean.
<ifreund> you want to read from stdin assuming your on linux or something posixy
<ifreund> or do you mean take a file name as an argument?
donniewest has quit [Ping timeout: 260 seconds]
<Kena> I would like to prompt the user to enter a string to it have to be read from stdin, although I'm still on Windows for the moment.
<Kena> s/for/at
<Kena> But I'll go back to Debian in a few weeks, that's the plan since I failed a migration towards voidlinux.
Enrico204 has quit [Quit: Enrico204]
<ifreund> well, std.io.getStdIn() looks to support windows
<Kena> Allright, I'll take a look right away.
<Kena> By the way, `std.io` assumes that all methods trigger a system call, I am right?
<g-w1> I did `const stdin = std.io.getStdIn().reader(); const input = try stdin.readUntilDelimiterAlloc(gpa, '\n', 100000);`
donniewest has joined #zig
<ifreund> Kena: not necessarily, std.io.getStdOut() just returns a constant on linux for example
<g-w1> probably readUntilDelimiterOrEof is better
a_chou has quit [Remote host closed the connection]
<Kena> How can I understand the parameters you passed? readUntilDelimited{Alloc|OrEof} is not present in https://github.com/ziglang/zig/blob/master/lib/std/fs/file.zig
<g-w1> it is in std/io/reader.zig
<g-w1> part of the reader api
<Kena> The source code's nomenclatur has nothing to do with the documentation's nomenclatur, I'm lost.
<g-w1> you can just look at the paramater's name of the function
<g-w1> fyi, readUntilDelimiterAlloc takes an allacator, delimiter to read until, and max input size
<Kena> Yes I'm reading the signature at the moment but I don't know which one to choose.
<Kena> Because I do not know why would there be an allocator in the first place neither what would be the delimiter in a string entered by a user.
kristoff_it has joined #zig
<ifreund> usually pressing return "enters" a string. This shows up in stdin as a newline
<ifreund> so you probably want to use \n as your delimiter
<Kena> Yes I understand, then so far there is no need for an allocator it seems.
<ifreund> well the options are allocator or buffer, the input needs to go somewhere
<Kena> Lol I agree but I do not understand the difference between a buffer and an allocator.
<Kena> Is the allocator a kind of curser to navigate through the buffer?
<g-w1> an allocator gives you the memory, while you have to give it the memory for a buffer
lltt has joined #zig
<g-w1> to make a buffer, "var buf: [1000]u8 = undefined;"
<Kena> Please why does a slice of a non-array type should raise an error, isn't a slice of a slice authorized? https://godbolt.org/z/EPG6b8
Akuli has joined #zig
<dutchie> you have a ?[]u8: an optional slice, not a slice
<Kena> Yes I see it now, but what should I do? Like I said I'm not a programmer.
<Kena> It's so damn hard to learn programming without a teacher 2 times a week during 5 years.
<dutchie> there are a few ways to get a value out of an optional: you can use `if (optional) |val| { ... }` `optional orelse ...` and if you are sure that it's non-null `.?`
<Kena> Yes, I recall these syntaxes from the reference manual but I have not developped algorithmic thinking so it's extremely delicate to convert a task into some code.
<Kena> Thanks dutchie.
<dutchie> don't worry, it takes a while to get the hang of things, especially if you are trying to teach yourself
<dutchie> keep at it and before you know it you'll be answering beginners' questions yourself
<g-w1> Kena: do you know any other programming languages, so that I can maybe make relations when explaining stuff
<Kena> Thanks for your support it's warming because I'm failing for several years.
<Kena> Not I just babbled with zsh last year but now i don't remember anything.
<g-w1> ok
<Kena> what shall I do with the `else` branch? because there is nothing useful to do it's it's not an optional value.
<dutchie> you don't need an else branch with the `if (optional) |value|` pattern
<dutchie> or if you want to bail out you can just `return` from your main function
<dutchie> for example if there's more code afterwards that you don't want to run if the optional was null
<Kena> return from main will exit the program right?
<dutchie> yes
cole-h has joined #zig
<Kena> I encompassed the print function in a `if` like you said but it still raises the same error, and I can't use `.?` because it could be null if the user accidently press enter without a input.
<g-w1> could you send the code?
<Kena> the child type return is ?[]u8
<g-w1> I don't see what the problem is? it is compiling fine on compiler explorer with master
<Kena> yes but it prints nothing between the ''
<Kena> the user input is not read.
<g-w1> you are using buf for two things, reading from stdin, and also reading from a file?
<g-w1> it is getting overwritten
<g-w1> kena, this works https://paste.rs/1Rb
frmdstryr has quit [Ping timeout: 256 seconds]
<g-w1> i would reccomend reading the documentation comments on the functions that you are using to see what value that they are returning means.
<g-w1> they start with /// and are above the function
<Kena> I'm a bit lost, I just want to read a user input then read from the file afterwards.
<g-w1> if you are using the same buffer, it will get overwritten
<Kena> because it would prove that the writing happened successfully instead of reading from the stdout.
nrdmn0 has quit [Quit: The Lounge - https://thelounge.chat]
<Kena> Are you saying that it needs a buffer for `readUntilDelimiterOrEof` and another one for `readAll`?
<Kena> what's the point?
nrdmn0 has joined #zig
<g-w1> when you create a file, you are writing nothing to it
<g-w1> library.txt has nothing in it
<Kena> Since the user input reading has finished, it can be overwritten safely to read the the "same" data in the written file.
<Kena> I agree, create it does nothing else.
<g-w1> at what line in your example do you write the data to the file?
<g-w1> since it reads the data from the file and the file has nothing, the buf is just ''
<Kena> I don't know, either the one with std.io.getStdIn().reader() or the one with readuntildelimiteroreof()
<g-w1> look at my example that i sent, it is working
<Kena> I'm not sure about their role
<Kena> Yes, I read it thanks. But isn't it sub-optimal instead of reusing the same?
<g-w1> if you reuse the same buffer, it gets overwritten by the data in the file which is nothing.
<Kena> You're right I misinterpreted the result in the terminal.
<Kena> But is it std.io.getStdIn().reader(); or stdin.readUntilDelimiterOrEof(&buf, '\n'); which reads the user input?
<g-w1> reader creates a reader, and then readUntil... actually reads
<Kena> I didn't even suspect this typology of mechanism, I keep thinking even ziglearn made a shit load of assumptions regarding to silently required prior knowledge. It's really discouraing but thanks for your patience.
<Kena> thereby, using seekTo(0) isn't needed anymore if I use a second buffer right?
<g-w1> yes
<Kena> running your file got the terminal stuck before emitt LLVM output, did you try it?
<Kena> *emitting
<Kena> Yours compile too but still doesn't print anything in stdout. :/
<ifreund> urgh, there is no dev_t definition for linux
<ifreund> wish I had noticed befor 0.7.0, but maybe I can get it in for 0.7.1
<ifreund> ok I take that back, it's defined for many linux archs but not x86_64 for some reason
<g-w1> kena it works on linux, maybe it doesn't work with windows though. im afraid this is the limit of my knowlege
Akuli has quit [Quit: Leaving]
<Kena> I'm not sure it is due to Windows, nothing is printed because nothing it's written in the file.
frmdstryr has joined #zig
<ugla> Did you change the code so that it writes to the file? Do you even want to write to a file? It's not needed if you just want to print back the user input.
<Kena> What I'm trying to do is the following:
<Kena> 1. create a file2. read a user input3. write the user input into a file4. print in stdout from the file
<Kena> But I'm stuck because `writeAll` takes a slice of bytes (i.e. []u8) whereas `readUntilDelimiterOrEof` takes a constant one (i.e. []const u8)
<Kena> https://godbolt.org/z/1x64bj raises `error: expected type '[]const u8', found '*const ?[]u8'`
<Kena> The error suggests it doesn't want a pointer so when I remove the address-of operator in front of `writeAll(input)` i get in return `error: expected type '[]const u8', found '?[]u8'`
marnix has quit [Ping timeout: 260 seconds]
<ifreund> Kena: kernel_stat
<ifreund> you need to unwrap the optional
<Kena> My bad, it was a optional one so i encompassed a input in a `if`
marnix has joined #zig
<Kena> Yes :)
<Kena> Now I need a function to read from a file.
<novaskell> `file.reader()`?
<Kena> in https://ziglang.org/documentation/0.7.0/std/#std;fs.File.Reader there doesn't seem to be any signature consisting of a file.
<Kena> only streams
<ifreund> you get the Reader from the File you want to read
<ifreund> using File.Reader()
skuzzymiglet has joined #zig
<Kena> Yes but which argument do I pass into file.readAll()? as I haven't any variable nor address pointing to the file.
<ifreund> std.fs.File.readAll() takes a buffer into which it will write what it reads
<ifreund> isn't that the first function we looked at today?
<Kena> Returns the number bytes read means "write" ? seriously? the naming is quite confusing.
<Kena> The compiler complains because it wants a usize and found instead an optional type. https://godbolt.org/z/759P6o
<ifreund> you can't put a usize in an if statement like that
<Kena> I understand the incompatibily between theses types but what is it necessary to do in order to obtain a usize that can be "returned" or "read" or whatever
<fengb> There’s no “peek” capabilities in the reader interface
<ifreund> Kena: you use that usize to know how much of your buffer has been filled with data read from the file
<Kena> I agree about the usize inadequate in a if but still I don't see which mechanics do I have to use
<ifreund> scroll up about half an hour, we already went over thies
g-w1 has quit [Quit: WeeChat 2.3]
<Kena> It was a different case, I was reading from stdin, now I need to read from the file which has just been created and seeded.
<ifreund> you're using the same function, std.fs.File.readAll()
g-w1 has joined #zig
<ifreund> which works the same way no matter what file you are reading from
<fengb> Aside: does readAll() work with stdin?
jjido has joined #zig
<ifreund> probably not what you want to use for that yea, it will hang untill stdin is closed
<ifreund> orignally Kena was using it to read from a file not stdin though
<Kena> In fact, I'm trying to but don't follow you
g-w1 has quit [Quit: WeeChat 2.3]
<Kena> I miss one mental step, the data has been written and I returned the proportion of buffer actually used, what is it missing before printing it in stdout?
g-w1 has joined #zig
<Kena> I returned the cursor at the beginning of the file with file.seekTo(0), what should I do with the usize?
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
lucid_0x80 has quit [Ping timeout: 260 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<earnestly> ifreund: (But stdin is a file)
skuzzymiglet has quit [Quit: WeeChat 3.0]
skuzzymiglet has joined #zig
<ifreund> technically correct is the best kind of correct, but don't tell me you don't know what I mean :P
<earnestly> Seekable files are real files
oats is now known as hafer
<earnestly> ™
nycex- has joined #zig
nycex has quit [Ping timeout: 240 seconds]
marler8997__ has quit [Ping timeout: 240 seconds]
skuzzymiglet has quit [Quit: WeeChat 3.0]
ur5us_ has joined #zig
skuzzymiglet has joined #zig
jjido has joined #zig
skuzzymiglet has quit [Quit: WeeChat 3.0]
skuzzymiglet has joined #zig
waffle_ethics has joined #zig
Joey152 has joined #zig
<Kena> Please do you know why the characters `'.`replace the first two characters in the print output? https://zero.hurtig.ninja/?5ff566e377cd4d43#s14maqDuvkYcFoKDIpAqW64LRP9rU+1Ht05KqdiQ4wY=
<Kena> The result will not be `bla bla bla ''<input>'.` but rather `'.a blabla <input>` (without `'.` at the end of line)
<Kena> I'm pretty sure it doesn't need specifier formats to print correctly.
<Kena> Not encompassing the curly braces prints correctly the output but would defeat the purpose of what I'll need to do next.
skuzzymiglet has quit [Read error: No route to host]
skuzzymiglet has joined #zig
<ifreund> does windows not care that you didn't open the file with the write permission?
<Kena> I'll check in the doc the other values possible but you may be right.
<Kena> *the other possible values, sorry for my language.
wootehfoot has joined #zig
<Kena> In https://ziglang.org/documentation/0.7.0/std/#std;fs.File.CreateFlags, there is nothing like `write`
<ifreund> indeed, I was being dumb
<ifreund> creating a file implies write access, it's when opening an existing file that you need to specify it
<Kena> yes so far I'm successfully writing a string in it, but it is overridden each time the script is executed.
<Kena> When you run it and enter a user input, do you have the last and before-last characters replacing the two first ones in the printed output?
<ifreund> ah I bet I know what's happening
<ifreund> windows has these dumb things called carriage returns
<Kena> Damn it.
<ifreund> try stripping your input string of whitespace?
<Kena> Does it mean my `\n` delimiter in readDelilimiterOrEof is replaced by `\r`?
<Kena> Allright.
<Kena> Same here without any whitespace.
<ifreund> windows uses both, \r\n, and you read until \n so there's a \r at the end of your input string I'd assume
<ifreund> which causes the terminal to move the writing head back to the start of the current line and continue writing there
<ifreund> which would cause exactly the behavior you see
<ifreund> Kena: how are you stripping whitespace?
<Kena> I entered a input without any whitespace in the sequence.
<ifreund> as a quick hack you could also just print all but the last character and see if that fixes it and I'm white
<ifreund> that wouldn't help, the \r is added by windows when you press return
<ifreund> you'd need something like std.mem.strip() with std.ascii.spaces
<Kena> 2 functions in a row? I will need some time to figure out how write that
<ifreund> const stripped = std.mem.trim(u8, input, &std.ascii.spaces);
<Kena> How do you know the existence of std.mem.strip()? It is not even in https://ziglang.org/documentation/0.7.0/std/#std;mem
<ifreund> std.mem.strip doesn't exist, I was thinking of std.mem.trim
<ifreund> see the line of code I just sent
<Kena> I'm sorry I lack focus.
<Kena> I must be the only idiot who try to learn programming starting with zig.
<ifreund> most people would probably start with C or javascript depending on what end of the spectrum they are on
<novaskell> Kena: just means you're in the perfect position to note down the process of learning zig as a first language such that a tutorial for absolute beginners can be written with input
skuzzymiglet has quit [Read error: No route to host]
<Kena> Yes you're right but that the ideal line of events, I'm frightened in advance where nobody will have the patience to keep answering my questions because it's too boring to help a total beginner.
<Kena> Nobody likes the noise on this channel and it's pretty easy to understand why.
<novaskell> I doubt most mind beginner questions and I'd even say some enjoy them
<novaskell> so don't worry
<Kena> Allright.
sord937 has quit [Quit: sord937]
<Kena> Your solution works ifreund thanks. But now I have a new quest to undertake, the utf-8 encoding support! Because all characters with a accent are replaced with a coma, do you know a function related to streams who allow utf-8?
<Kena> And on a side note, I wish to learn zig to aim at embedded systems programming. I think it's a stimulating choice of career.
<novaskell> streams are agnostic to encoding
layneson has quit [Quit: WeeChat 2.9]
<ifreund> isn't windows utf-16 and broken as fuck?
<Kena> When I entered `La modélisation des systèmes complexes`, the output stream in the file is `La mod‚lisation des systŠmes complexes`
<Kena> lol..
<g-w1> maybe your terminal can't handle accents?
<Kena> tell Microsoft their powershell cannot handle accents lol
<Kena> Are you sure It's the terminal?
<g-w1> i'm not
<Kena> Do you accept to run a test on your machine if a provide again the link to the source code?
<g-w1> ah, I don't think std.debug.print can handle unicode. https://github.com/ziglang/zig/pull/6390 I am waiting on this feature myself too
<Kena> Except C# and F#, Microsft windows does not seems to be developer-friendly, or even targeted for industry in 21st century...
<Kena> I'll try the master branch instead of 0.7.0 but the probability of an improvement over utf-8 encoding is low.
<g-w1> it is not
<g-w1> once that pr gets merged, it will work
<Kena> That's a pipe dream, there isn't even any milestone assigned, it could be resolved in several months at least.
<Kena> But I'm going to suscribe to the issue, thanks for pointing this out.
<ifreund> you can probably work around this by just writing the bytes directly to stdout
<justin_smith> Kena: I think the root issue here is that zig doesn't try to address unicode at all, and in the linux and osx ecosystems many things "just work" because of utf8 defaults, and you need extra effort or different tooling to make anything "just work" with the assumptions of windows
<Kena> Yes I admit the difficulty to implement anything with Microsoft Windows. I just wanted to learn seriously.
<justin_smith> the lowest friction thing, especially if you are just now learning to program, is probably to use a *nix system (linux or osx or some sufficienly compatible windows subsystem)
marnix has quit [Ping timeout: 260 seconds]
<justin_smith> otherwise your learning is going to be impeded by weird historical differences IMHo
<Kena> You're right.
<Kena> I'm terrorized to not be able to reinstall Debian since I lost my entire RAID1. My PC won't even boot it so I'm using a laptop with windows 10 from somebody else.
<Kena> It affected me real hard.
<justin_smith> Kena: depending on what you are trying to do you could even use a cheap virtual server, if you are comfortable going 100% CLI
retropikzel has joined #zig
<Kena> to host a GNU/linux instance from Windows 10 host you mean?
<earnestly> Any real learning is always a test of curiosity, just struggle
<Kena> I don't like using the mouse but I'm not 100% CLI-able either.
<justin_smith> Kena: I mean renting a cheap remote instance and using ssh to access it
<Kena> I didn't think about that but it could be a interesting way of dealing with the current situation I suppose.
waffle_ethics has quit [Ping timeout: 256 seconds]
<novaskell> 100% cli is just a case of removing your file/archive/etc manager
<pixelherodev> ... I mean, no? If you want 100% CLI you need to remove your display server (X11 / Wayland compositor)
<Kena> In order to append to the file instead of override it each time, I could replace `.{ .read = true} by `.{ .truncate = true}`, but then I have to move the cursor to the next line before writing to again right? I'm not sure to understand " it will be truncated to length 0. " explanation.
<pixelherodev> Truncated means deleted
<pixelherodev> It's new length will be zero
<pixelherodev> That is, there will be nothing left
<Kena> Allright, so it cannot be used to append anything. What field of std.file.CreateFlags should I use?
<novaskell> pixelherodev: it ends up with 99% terminal and the only other thing being either gimp or a web browser
<Kena> pixelherodev are you using 9front or is it LemonBoy?
tdeo has joined #zig
<waleee-cl> Kena: pixelherodev mentioned it sometime last week
<waleee-cl> (I think. Might have been this week)
<Kena> Allright, that's because I told myself that perhaps he could be interested to use and/or contribute to another fork of Plan 9.
<waleee-cl> 3 days ago, https://freenode.irclog.whitequark.org/zig/search?q=9front my memory was faulty
<Kena> Nice, I didn't know about the search parameter. Thanks.
Joey152 has quit [Remote host closed the connection]
<Kena> If I need to append to an existing file, what API should I use?
<Kena> Is std.json the easier way to do so?
swills has quit [Ping timeout: 265 seconds]
swills has joined #zig
hafer is now known as didymos
wootehfoot has quit [Ping timeout: 240 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
skuzzymiglet has joined #zig
CodeSpelunker has quit [Ping timeout: 272 seconds]
donniewest has quit [Quit: WeeChat 3.0]
<ifreund> why isn't std.testing.refAllDecls() recursive?
midgard has joined #zig
skuzzymiglet has quit [Ping timeout: 246 seconds]
Kena has quit [Remote host closed the connection]
frmdstryr has quit [Ping timeout: 240 seconds]
<andrewrk> interesting idea
<ifreund> andrewrk: for context, I had to manually recurse one level and workound the missing opaque support to achieve the desired effect here: https://github.com/ifreund/zig-xkbcommon/commit/51f65196c12e7fc589d8edd744dc44c72deac1d3
<ifreund> As you can see though, it caught two things that didn't compile though so that's a win
<andrewrk> I've been thinking recently about how we could maybe walk back the laziness a little bit and have zig look at all top level decls
<andrewrk> conditional compilation would have to be with comptime branches
CodeSpelunker has joined #zig
<ifreund> I think that would be a lot more intuitive tbh
frmdstryr has joined #zig
<g-w1> Right now, I feel like it is python, having code that can run, while it still has weird errors. IMO that would help a lot with development speed.
<ifreund> could also reconsider the zig check proposal: https://github.com/ziglang/zig/issues/5208
<g-w1> Kena: good news, std.fmt mets UTF-8 just got merged. im pretty sure it will be in 0.7.1
jj__ has quit [Ping timeout: 264 seconds]
jjsullivan has joined #zig
<ifreund> (they left)
<ifreund> (I may have been about to tell them the same thing 10 min ago :P)
<g-w1> lol