ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
JinShil has joined #zig
sherjilozair has joined #zig
sherjilozair has quit [Quit: Leaving...]
<donpdonp>
andrewrk: nod.
<donpdonp>
im having a different, more basic zig prob
<donpdonp>
do("string")
<donpdonp>
fn do(word: []u8) I figured would cover any string
<donpdonp>
but im getting cant cast [6]u8 to []u8
<donpdonp>
which I understand "string" is a fixed sized string and not a slice
<donpdonp>
but do I have to really "string"[0..] or somethiing?
<andrewrk>
donpdonp, you either need to make it a []const u8 or figure out where the memory will go
<andrewrk>
because you can't mutate string literals - they end up in the read-only .data section of the ELF
<donpdonp>
oh thats all it needed, the const. ok thx
<andrewrk>
this has come up a few times before. I'll make a mental note to improve the error message
<donpdonp>
error: expected type '[]u8', found '[7]u8'
<donpdonp>
its just not obvious that the fix for that is []const u8
<donpdonp>
yeah.
<andrewrk>
there's a lot more we can do to report why exactly types do not match
<andrewrk>
in fact the internal functions return a recursive struct that has a complete explanation - we just don't convert this data into human readable error messages yet
<andrewrk>
Hejsil, I think this will be enhanced by the addition of tuples (and removal of var args)
Hejsil has joined #zig
<Hejsil>
andrewrk, true. Especially if we can "explode" the tuple into the remaining args of a function.
<andrewrk>
I'm thinking that will look like @call(function, tuple)
darithorn_ has quit [Ping timeout: 252 seconds]
<Hejsil>
Could it do, @call(func, arg1, arg2, tuple) ?
<Hejsil>
You know, provide some args, and then give a tuple for the rest
<andrewrk>
@call(func, [arg1] ++ [arg2] ++ tuple)
<Hejsil>
Aah
<andrewrk>
where [foo] is a tuple of size 1
<Hejsil>
Powerful
<Hejsil>
The more I hear of tuples, the more I want them!
<andrewrk>
btw last night I got zig fmt to the point where it handles all same line comments correctly
<Hejsil>
Nice
<andrewrk>
the parser ignores all comments and skips over the tokens. the renderer looks "nearby" tokens for line comments to findthem
<andrewrk>
so now I'm going to use this to change all &T to *T and move one with pointer reform
<andrewrk>
*move on
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Hejsil>
Would love to try out zig fmt with the new pointer syntax, but I have a branch I wonna finish up before I get to that :)
<andrewrk>
fixing the inability to have a pointer to a type at comptime should fix a lot of comptime bugs
<andrewrk>
this interface example is really neat
<Hejsil>
One thing that would be nice, is to have methods on the interfaces
<Hejsil>
Which is not really possible without @reify
<andrewrk>
I see
Hejsil has quit [Quit: Page closed]
t5c has joined #zig
davr0s has joined #zig
bheads has quit [Ping timeout: 245 seconds]
bheads has joined #zig
darithorn_ has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
SimonNa has left #zig ["Leaving"]
davr0s has joined #zig
bheads_ has joined #zig
bheads has quit [Ping timeout: 248 seconds]
MajorLag2 has quit [Ping timeout: 245 seconds]
MajorLag1 has joined #zig
steveno_ has joined #zig
<t5c>
hi, I'm adding OpenBSD syscalls and errnos to zig right now. I'm wondering why the values like pub const O_CREAT = 0o100; are in octal notation, does that have any particular reason? for simplicity I would just use the hex values from OpenBSD.
<t5c>
the 0u100 example is from os/linux/x86_64.zig
<t5c>
oh I see that the darwin modes are also in hex or decimal, so it shouldn't be a problem
<MajorLag1>
probably because they're in octal in the C source and documentation.
<t5c>
yeah, my question was more about style. but since there are hex and decimal already in...
<andrewrk>
hi t5c
<andrewrk>
hex decimal is preferable I think. the ones that are in octal are from code that was ported
<t5c>
hi andrewrk
<t5c>
I guess its fine to use the exact values from the header of the os
<t5c>
makes porting easier not having to calculate everything
<t5c>
so many syscalls, signals and stuff :/
<t5c>
man its a lot
bheads has joined #zig
bheads_ has quit [Ping timeout: 260 seconds]
steveno_ has quit [Quit: Leaving]
Ichorio has joined #zig
<andrewrk>
t5c, are you aware of zig's lazy top level declaration evaluation?
<andrewrk>
my strong suggestion to you is to follow this process: 1. port nothing to OpenBSD and try to run the zig std lib tests
<andrewrk>
2. see what compile errors you get. port over the OpenBSD functionality that is necessary to fix them
<andrewrk>
repeat step 2 until all std lib tests passing
<andrewrk>
it will be a small manageable subset of OpenBSD that we can merge and iterate on
<andrewrk>
even the linux support right now is not complete
<andrewrk>
we have only added syscalls that we needed
bheads_ has joined #zig
bheads has quit [Ping timeout: 256 seconds]
<t5c>
andrewrk: yes that is a good plan.
<andrewrk>
oh, and before all std lib tests - you can start with something simple such as hello world
<andrewrk>
that should only require read/write and some constants