<mq32>
Spacemonkey2126: yeah, Zig has *real* array values
<Spacemonkey2126>
Oh, cool. I'll definitely take advantage of Godbolt.
<mq32>
so arrays are value types and are expected to copy when assinging to a new variable
<andrewrk>
Spacemonkey2126, I'm happy to look at godbolt examples or other codegen comparisons
<mq32>
this allows for some very nice code compared to C
casaca has joined #zig
<Spacemonkey2126>
Something like 3804, yes
<Spacemonkey2126>
I'd even be more in favor of a loud copy like `@copy(val)`
<Spacemonkey2126>
I hate all implicit copies.. it's a big reason for bad and slow code (see C++ std::string => const char * => std::string => ... etc etc )
<Spacemonkey2126>
Okay, thanks for the explaination
<andrewrk>
3804 won't improve codegen in any way, it will only add compile errors to prevent mistakes
<Spacemonkey2126>
That's fine.
<andrewrk>
what implicit copy are you talking about? zig has even less implicit copies than C
<mq32>
Spacemonkey2126: > I hate all implicit copies
<Spacemonkey2126>
Codegen is good enough at this stage .. C has had decades of tuning compiler heuristics..
<mq32>
copying arrays as in your example above is definitly an explicit copy
<andrewrk>
oh, you copied an array. that's not implicit, that's explicit. simply remove the copy :)
<andrewrk>
if you're concerned about accidental copies, you could make the array a pointer at the site you declared it in
<lupine>
zig master, or zig 0.5 ?
<Spacemonkey2126>
0.5
<Spacemonkey2126>
andrewrk You can make it a ptr without affecting the memory layout?
<Spacemonkey2126>
Are you saying in the struct? Or in the code?
<andrewrk>
var array = [_]i32{1, 2, 3}; // array value
<daurnimator>
lupine: oh right I forgot about that. I should go do todays :)
<lupine>
you've got 5 hours to wait :/
<lupine>
I figured I might as well set up the compiler though
<andrewrk>
lupine, too bad nobody made InStream.scan yet
<Spacemonkey2126>
The struct was: ```const Array = struct {
<andrewrk>
maybe I'll do it tomorrow
<lupine>
:p
<daurnimator>
lupine: oh. right. timezones
<Spacemonkey2126>
(Argh.. sorry)
<andrewrk>
daurnimator, const. if you want mutable you have to make a separate var and take that pointer
adamkowalski has quit [Quit: Lost terminal]
<lupine>
d'oh, no llvm8 in buster. binaries it is
<daurnimator>
lupine: you mean 9?
<andrewrk>
lupine, there is also apt.llvm.org if you like
<Snektron>
that or you can even download llvm and clang as pre-built binaries
adamkowa1ski has quit [Ping timeout: 265 seconds]
ky0ko has quit [Remote host closed the connection]
<lupine>
I meant 9, aye. I'll just slum it with the binaries for now
<lupine>
an arm laptop is showing up next week so I'll probably have to navigate builds at that point anyway ^^
<andrewrk>
lupine, is that the pine book pro?
mahmudov has quit [Ping timeout: 245 seconds]
adamkowalski has joined #zig
<lupine>
andrewrk: yeah
<lupine>
hmm, is there a gtksourceview language file for zig hanging around anywhere? found the sublime bundle, but don't see a quick way to convert
<daurnimator>
lupine: not that I know of: if you created one we'd (probably... don't want to put words in andrewrk's mouth) be happy to host it under the ziglang github org
<lupine>
I'll give it a poke. funny all the little things a programming language "needs" ^^
<emekankurumeh[m]>
i just realized that if we implement #3806 for floats as well we could eliminate all divide by zero exceptions by having `/` be an inline function that takes two `@Float(-math.f64_max, math.f64_min) ∪ @Float(math.f64_max, math.f64_min)`
<daurnimator>
emekankurumeh[m]: we don't have unions of types though
<emekankurumeh[m]>
it's a shame we don't though /s
Spacemonkey2126 has quit [Ping timeout: 260 seconds]
<andrewrk>
lupine, I was able to run the aarch64 binary from ziglang.org/download on a pinebook pro, but when I tried to compile LLVM from source I got a compile error
muffindrake has quit [Quit: muffindrake]
<lupine>
Oh, i see it, only there for master ^^
muffindrake has joined #zig
<andrewrk>
lupine, yeah, CI builds for aarch64 is new
<andrewrk>
daurnimator, if you look at page_size usage in the std lib, there are a lot of places where it must be compile-time known. for example the size of an array on the stack
<daurnimator>
andrewrk: most of that is just picking a nice performant size for buffers
<daurnimator>
rather than anything *required*
<daurnimator>
infact I can't find any usages that *aren't* that
<daurnimator>
okay I found one test in PackedIntArray that uses it to make a sort of bad assumption
ky0ko has joined #zig
<andrewrk>
daurnimator, you can try changing that to `var` in the std lib and see what breaks
<daurnimator>
andrewrk: I think its evident what will break: the issue is that we've been using page_size where we meant BUFSIZ
<daurnimator>
andrewrk: I'll send a patch in a minute if you want
ky0ko has quit [Remote host closed the connection]
<andrewrk>
do not want
<andrewrk>
sorry, I'm being dramatic. I'll take a look, but I don't want to break everything with regards to page_size until it's clear what the decision on #2564 is
<daurnimator>
andrewrk: does the panic on non-matching page size exist? I'm not seeing it
<andrewrk>
hmm I don't see it either. I wonder why I thought we were doing that
kaano has joined #zig
kaano has quit [Client Quit]
adamkowalski has quit [Ping timeout: 268 seconds]
<daurnimator>
also I don't think we can put it in a variable: that wouldn't work in a library as there is no libc variable with the page size in it: we need a `mem.get_page_size()` function
<andrewrk>
I think the only thing that should change is to add: /// this is the minimum page size of the target
<daurnimator>
I think we need to be explicit and have mem.min_page_size, mem.max_page_size and mem.bufsiz
<andrewrk>
what's bufsiz?
<daurnimator>
andrewrk: BUFSIZ is the traditional C macro that contains the "recommended" size for buffers
<andrewrk>
sounds misguided
<daurnimator>
why? that's exactly what the majority of our mem.page_size usage is
<andrewrk>
there isn't a single buffer size that makes sense in all contexts, and mem.page_size isn't that value either
<daurnimator>
andrewrk: yet we use it.... as I said, I only found a single usage of mem.page_size in the standard library that *wasn't* that.... and it was in a test.
<andrewrk>
damn, lazy values mean hanging on to references to IrAnalyze longer than preferable
<mikdusan>
I don't know where/when but some copy-on-write management of stage1 structs might be in order
<andrewrk>
completely agree
ky0ko has joined #zig
<andrewrk>
daurnimator, I do welcome you to create a well-thought-out pull request addressing page size if you are empassioned to do so
<daurnimator>
not so much empassioned as procrastinating
<andrewrk>
I wonder what that Unknown_8 is taking up 227 MiB
<andrewrk>
maybe it's eval_branch_quota
<mikdusan>
just going to guess any pointer allocations?
<andrewrk>
oh right we do that with struct fields now
<mikdusan>
Q. in C++ if given a template param type, can it be converted to string name portabily?
kapil_ has joined #zig
<andrewrk>
I briefly looked into that, and concluded implementation and debugging time would far exceed simply adding an optional name parameter
<mikdusan>
ah ok
<mikdusan>
ah now I remember. some platforms would need demangling. boohoo
<andrewrk>
hmm, ZigList (stage1's array list) hides from the memory profiling
<andrewrk>
oh, it just doesn't count frees
<andrewrk>
fixed
<mikdusan>
also I think it's time for arena allocator ported to stage1/c++
<andrewrk>
custom names also allow this: allocate<IrExecutable>(1, "IrExecutablePass1"); allocate<IrExecutable>(1, "IrExecutablePass2");
<marler8997>
what is alignment supposed to be for array types?
<marler8997>
is it just always 0 or something?
<mikdusan>
I think it should be the same alignment as element of array
muffindrake has quit [Ping timeout: 276 seconds]
<marler8997>
thanks that makes sense
muffindrake has joined #zig
<daurnimator>
andrewrk: uh, so why is alignment a u29 again?
<daurnimator>
did you know that the s390x supports 2G pages?.... how are we meant to align to one of those?
<marler8997>
in that case you just wouldn't use zig's type system to ensure alignment of pages
<marler8997>
[*]align(N) is a type superset of [*]align(M) where M is a multiple of N
<andrewrk>
u29 is a limitation of llvm, but that's a good point that the zig language shouldn't be specified by llvm
<daurnimator>
even if we can't support larger aligns on types.... we should at least be able to pass it to .alignedAlloc
<daurnimator>
hell; I'm not even sure how I'm meant to pass 1G to .alignedAlloc and that's available on x86_64
<andrewrk>
mikdusan, I definitely agree with you on the bringing arena allocator into stage1
<marler8997>
hey I'm trying to figure out the right way to fix this sentinel issue
<marler8997>
it looks like TypeInfo.Pointer is storing a dynamically typed value
<marler8997>
sometimes it's optional, and sometimes it isn't
<marler8997>
is it supposed to be dynamic, or should the compiler check the type before it instantiate an instace of TypeInfo.Pointer?
<andrewrk>
it's always supposed to be optional
<marler8997>
ok that makes sense
Spacemonkey2126 has joined #zig
Spacemonkey2126 has quit [Remote host closed the connection]
Spacemonkey2126 has joined #zig
<marler8997>
I see you can use ir_implicit_cast to go from IrInstruction to ZigValue, is there a way to implicit cast one ZigValue to another?
<andrewrk>
mikdusan, after #3787 there is only 1 failing behavior test case with inlining ConstGlobalRefs into ZigValue, and it seems fixable without reverting
<marler8997>
of course I could be doing this wrong, trying to cast the sentinel value to it's optional type, but I only have a ZigValue where I"m looking, maybe I need to find out where it's analyzing IrInstruction?
<andrewrk>
marler8997, if you're looking at the typeinfo related code, who person who contributed it converted the IrInstruction into a ZigValue too early
<andrewrk>
it will be more obvious what to do if that is corrected
<marler8997>
ok I think I gotcha
<meowray>
zig doesn't call InitTargetOptionsFromCodeGenFlags() to initialize llvm::TargetOptions. this is strange
<andrewrk>
what other level are you referring to? types?
<marler8997>
hardcoded interning
<marler8997>
vs what I'm assuming is runtime interning
<andrewrk>
zig code at runtime? I'm talking only about ZigValue
<marler8997>
lol
<marler8997>
compiler runtime
<andrewrk>
what hard coded interning are you talking about?
<marler8997>
the Intern struct in all_types.hpp
<andrewrk>
ok that's 1, what's the other level you are refering to?
<marler8997>
I assume you're interning more than just these 6 values
<andrewrk>
nope
<marler8997>
oh!!
<marler8997>
k, I got it
<andrewrk>
other than types
<marler8997>
I hope I'm not being too annoying with these questions, it's definitely helping me go alot faster
<andrewrk>
nope no worries, sorry if I sound grumpy, I'm about to go to bed
<mikdusan>
andrewrk: wow another 225 MiB. nice
<andrewrk>
if we can sever those other refs to IrAnalyze it will go down a lot more
<daurnimator>
andrewrk: oh I have a couple of misc non-coding tasks if you're finished coding for the day :)
<leeward>
a
<leeward>
whoops
* daurnimator
now tries to remmeber what they were
<leeward>
Hmm, got a segfault on build.
<daurnimator>
oh, one thing was: can we set up a discord webhook => if I give you a string can you put it into the repository settings?
<mikdusan>
in five days, net change in maximum resident-set-size for building test for std has gone from 4.8 GiB -> 4.3 GiB (macOS). that's a whopping 0.5 GiB reduction
<daurnimator>
zig/lib/std/io/test.zig:599:23: error: expected token ';', found 'StringLiteral'
<daurnimator>
uh... are io tests not being run on master or something?
<daurnimator>
andrewrk: ^?
<daurnimator>
nevermind, I'm an idiot
<leeward>
I have a function that takes a pointer to a thing, then tries to modify the thing. I'm getting an error saying that I'm trying to discard const qualifier, but `fn (thing: *Thing) void { thing.val += 1; }` doesn't have const in it.
<leeward>
What am I missing?
<daurnimator>
leeward: all arguments are const. ==> the thing pointer itself is const. you probably have a body that does something like: `thing = thing.next;`
<leeward>
Oh, I'm being dumb.
<leeward>
Never mind, nothing to see here.
spacemonkey2126 has quit [Ping timeout: 268 seconds]
leeward has quit [Quit: Leaving]
ky0ko has quit [Ping timeout: 276 seconds]
knebulae has quit [Read error: Connection reset by peer]
riba has quit [Ping timeout: 268 seconds]
adamkowalski has joined #zig
wootehfoot has joined #zig
riba has joined #zig
mahmudov has joined #zig
adamkowalski has quit [Ping timeout: 265 seconds]
adamkowalski has joined #zig
riba has quit [Ping timeout: 268 seconds]
adamkowalski has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 265 seconds]
gonzus has joined #zig
<gonzus>
Hello!
<gonzus>
I just had my hour of fun with AoC day #1. :-)
<gonzus>
I am sure my zig code sucks. I have not kept up to date and basically just hammered on it until it ran.
<gonzus>
And now I am wondering: do we have an "official" place where we could upload the code and receive some constructive criticism?
adamkowalski has joined #zig
<gonzus>
I would love to hear how I can make my code more idiomatic.
<gonzus>
Also, I don't want to spoil the fun for anybody by simply posting the code here or in the mailing list.
<lupine>
I tend to just create a repository called aoc20xx - that makes it obvious what the code is goiung to be
clktmr has joined #zig
adamkowalski has quit [Ping timeout: 276 seconds]
<gonzus>
lupine that would also work. In fact, it might be better to just take a look at other people's code, rather than asking others to look at mine.
<lupine>
heh. trying to compile that locally I get: error: type 'std.os.windows.GetStdHandleError!std.fs.file.File' does not support field access
<lupine>
my own attempt was foundering on readUntilDelimiterOrEof not being found
<daurnimator>
lupine: are you on master?
<lupine>
no, 0.5.0
<daurnimator>
that'll be why :)
<lupine>
I did ask in here :D
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 245 seconds]
adamkowalski has joined #zig
<lupine>
I'll come back to it with master later
riba has joined #zig
adamkowalski has quit [Ping timeout: 245 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 268 seconds]
adamkowalski has joined #zig
<gonzus>
Yeah, my code is pretty much the same. There isn't much room for variety here anyway :-) but I did have to fight the boilerplate a bit.
mahmudov has quit [Ping timeout: 240 seconds]
adamkowalski has quit [Ping timeout: 268 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 268 seconds]
<Snektron>
daurnimator: Do you have any plans for a mixin-style iterator?
<lupine>
Last year (rust) i was opening files and stuff. Never even thought to use stdin
<daurnimator>
Snektron: no.... what would it do?
<daurnimator>
lupine: easier to copy/paste into my terminal than copy/paste into a file, save it, name it, and open it :P
<Snektron>
daurnimator: i was thinking something along the lines of java streams/rust iterators/c++ ranges
* daurnimator
is waiting for the *first* mixin to get accepted before doing much more
<daurnimator>
the stream one will have huge usability improvements though
<Snektron>
i suppose thats a good idea
riba has quit [Ping timeout: 265 seconds]
mahmudov has joined #zig
knebulae has joined #zig
FireFox317 has joined #zig
<FireFox317>
andrewrk: did you know you are mentioned on the homepage of sourcehut?
<FireFox317>
you probably do, but just wanted to mention it xd
aranea has joined #zig
<gonzus>
lupine: that's funny, last year I also tried AoC with Rust. It made it clear to my how much I did NOT like Rust. :-)
benjif_ has joined #zig
benjif has quit [Ping timeout: 268 seconds]
traviss has quit [Ping timeout: 276 seconds]
_whitelogger has joined #zig
<pixelherodev>
There's a zig mailing list?
<pixelherodev>
Ohhh, there's an AoC mailing list?
deesix has quit [Ping timeout: 276 seconds]
gonzus has quit [Remote host closed the connection]
leeward has joined #zig
<leeward>
Is there an easy way to use a [_]u8 to initialize something that I can pass to a function that accepts a File?
<daurnimator>
"something"?
<leeward>
A File, preferably
<leeward>
I want to mock out a File to test a function.
<leeward>
io.File
<leeward>
Which seems to be std.fs.File
<daurnimator>
leeward: a file is very tied to having an FD backing it: to test it you'd need to create a file descriptor and give it over.
<leeward>
Should I have my function under test accept a stream instead maybe?
<leeward>
This is one of those bits of the standard library documented with "read the code."
<daurnimator>
sure, if you want to only test stream functionality that's much simpler to mock
<leeward>
Yeah, all it needs to do is read the whole thing 2 bytes at a time.
<daurnimator>
leeward: use a io.SliceInStream
<leeward>
daurnimator, That's what I was looking for, thanks.
kapil_ has quit [*.net *.split]
D3zmodos has quit [*.net *.split]
tav has quit [*.net *.split]
jonathon has quit [*.net *.split]
SimonNa has quit [*.net *.split]
Flaminator has quit [*.net *.split]
nikoala has quit [*.net *.split]
THFKA4 has quit [*.net *.split]
crimson_penguin has quit [*.net *.split]
lucus16 has quit [*.net *.split]
hoppetosse has quit [*.net *.split]
daurnimator has quit [*.net *.split]
<leeward>
Hmm, I'm confused a bit.
SimonNa has joined #zig
D3zmodos has joined #zig
Flaminator has joined #zig
nikoala has joined #zig
jonathon has joined #zig
kapil_ has joined #zig
THFKA4 has joined #zig
tav has joined #zig
daurnimator has joined #zig
hoppetosse has joined #zig
lucus16 has joined #zig
crimson_penguin has joined #zig
<leeward>
If I want a function to accept a stream from a file, does it have to take std.io.File.InStream?
kapil_ has quit [Max SendQ exceeded]
<leeward>
That seems like it would defeat the purpose.
kapil_ has joined #zig
FireFox317 has quit [Ping timeout: 265 seconds]
<leeward>
Alright, this shouldn't be a hard thing to do, and I'm running around in circles: I want to read a file, 2 bytes at a time, and do stuff with its contents. I also want to test the function that does this. I was thinking that I could just @embedFile a test file and have the function under test accept a generic stream of some sort, but my head keeps slamming into the wall.
* lupine
celebrates by rewriting all of work in zig
<mikdusan>
leeward: I'm not 100% up-to-date with std.io, but my last experience was "stream" type for a file vs slice (byte memory), well they are not equivalent because they differ by errorset,
<andrewrk>
leeward, obtain a BufferedInStream, repeatedly call read() with a slice of len 2. what's the problem there?
<mikdusan>
for example a slice stream doesn't error on reads, while a file stream can
<andrewrk>
mikdusan, I added the ability to set a Zig IR breakpoint on a file + line number. total debugging game changer
<andrewrk>
and then also you can do (gdb) p ira->break_debug_id = 21
<andrewrk>
now the only thing that's missing is the ability to rewind :)
<mikdusan>
so ("test.zig",9) will break in IR0 at first node of line 9?
<mikdusan>
first AST node
<andrewrk>
it will break when it's looking at a pass1 instruction, about to produce a pass2 instruction, where the pass1 instruction source node matches
<mikdusan>
i like
<marler8997>
been having a heck of a time triaging an issue
<marler8997>
did you know that the lld tool calls _exit on error?
<andrewrk>
yes
<marler8997>
it's weird because I'm not getting an error message
<andrewrk>
upstream lld never tests in non-standalone-binary mode
<andrewrk>
we've had to send several patches to fix issues when using it as a library
<andrewrk>
which is maybe an argument for taking a similar strategy as we do with clang, zig invoking itself as a child process. but that makes it a bit harder to collect error messages
<marler8997>
yeah makes sense
<marler8997>
to figure out what's goin on, I wrote a custom _exit implementation, asserted an error and used gdb to get a stack trace
<marler8997>
took me a while to figure out there is a difference between exit and _exit though
<andrewrk>
it's not supposed to call exit or _exit when you invoke it as a library
<emekankurumeh[m]>
andrewrk is it planned for zasm to read instruction sets from files so we can define custom instruction sets?
<andrewrk>
yes
<emekankurumeh[m]>
nice
<mq32>
interesting
<marler8997>
hitting line 519 of InputFile.cpp with my sentinel change
<mq32>
i'm keen to see how that will work out
<marler8997>
lld just calls "fatal" which ends up calling _exit
<marler8997>
*InputFiles.cpp
<andrewrk>
marler8997, I'm surprised that your patch affected the linker in any way
<mikdusan>
maybe the sentinal is not working. and inputfiles end is not marked
<marler8997>
yeah, must be something to do with how the sentinel value is translated to llvm?
<marler8997>
we were storing the sentinel value as a regular type, my change changed it to an optional type
<marler8997>
what's also weird is that I don't get an error message
<andrewrk>
emekankurumeh[m], if you're asking whether such instruction set data will be available as comptime values for the zasm implementation, I do want that to be a thing. so maybe you would have to recompile after adding a custom instruction set. but one of the main ideas is to make the instruction set data format describe everything about an architecture
<marler8997>
I noticed using strace that LLVM is trying to call lseek on stdout though
<marler8997>
which you can't do, it returns - ESPIPE
<marler8997>
sh_size is 2840 and entSize is 16
<marler8997>
so the size of the section header is not divisible by 16, only divisible by 8
<marler8997>
the size of the SHF_MERGE section
<marler8997>
any idea what goes in there?
mahmudov has quit [Ping timeout: 245 seconds]
<emekankurumeh[m]>
oh, i meant that perhaps you could have an architecture defined through a json file and load it a runtime
waleee-cl has quit [Quit: Connection closed for inactivity]
<marler8997>
it's the ".rodata.cst8" section in the "build.o" object file
<andrewrk>
emekankurumeh[m], what use case(s) are you thinking of that require runtime-known architecture definition?
<marler8997>
actually I mean, ".rodata.cst16" (not cst8)
<marler8997>
entry size is 16 but the full size is not divisible by 16
mahmudov has joined #zig
<marler8997>
a weird section, contains a bunch of strings that are 16-bytes wide
<emekankurumeh[m]>
allowing users to add many different targets that aren't included by default without "bloating" the core assembler
<emekankurumeh[m]>
like for example custom architectures
<mq32>
i'm definitly trying to add my own arch to zasm
FireFox317 has joined #zig
<pixelherodev>
Wait, so zasm takes Zig IR and produces asm?
adamkowa1ski has joined #zig
<pixelherodev>
Or is it just an assembler?
<adamkowa1ski>
is there a reason literals don't work with std.testing.expectEqual?
<adamkowa1ski>
you need to write std.testing.expectEqual(@as(i32, 5), @as(i32, 10))
<pixelherodev>
It's not that function - at the moment, comptime_int doesn't implicitly cast within function calls IIRC
<pixelherodev>
It's a compiler bug
<adamkowa1ski>
Hmm, okay thanks
<emekankurumeh[m]>
that way zasm can be "done" but still continue to grow
<marler8997>
I think I know what's going on. I saw a section with 2 entries, one was a string literal and the size was off by 1
<marler8997>
I think when a string literal gets put into a cst section (when it's length is divisible by 4, 8, 16, 32, etc), it's adding 1 to the size of the section for some reason
<adamkowa1ski>
[] isn't being used for anything besides array literals anyway, so we might as well remove the cruft and infer the shape and element type
<adamkowa1ski>
you could provide the type if desired
<adamkowa1ski>
And do we have "type traits" in the standard to get things like the element type of an nd array
<marler8997>
does anyone know if zig has any control over the sections in the elf file, if so, where that would be?
<pixelherodev>
e.g. `var name: type linksection(".bss") = value;` IIRC
<marler8997>
sorry, not the zig language, the compiler
<pixelherodev>
Ah
<pixelherodev>
That I can't help with
<pixelherodev>
Maybe do a grep?
<marler8997>
yeah been doing that
<pixelherodev>
`grep -r linksection` might help find where that's implemented, from there it;s probably a matter of following the IR
<marler8997>
already tried, not there
<marler8997>
LLVMSetSection looks promising
<marler8997>
I can use grep/investigate myself, just wondering if anyone has pre-existing knowledge that can help :)
traviss has joined #zig
return0e_ has joined #zig
<leeward>
mikdusan: Thanks. I was missing the inferred input variable type.
mixi has quit [Remote host closed the connection]
mixi has joined #zig
return0e has quit [Ping timeout: 265 seconds]
adamkowa1ski has quit [Quit: Lost terminal]
<mq32>
adamkowalski, you can try using the new syntax for array literals:
<mq32>
.{ 1, 2, 3 }
<mq32>
but i don't know if it will work out
riba has joined #zig
<lupine>
one thing I couldn't find offhand. I had a `var x [255]uint8 = undefined;` to act as a buffer, but I'd actually have preferred it to be zero-initialized, without typing out `0` 255 times
<lupine>
var buf: [255]u8 = undefined;
<lupine>
is there a shorthand to . { 0,0,0,0,0,0,0....} that I missed?
<mq32>
pixelherodev, regarding the scas assembler: can you do "particles" in it? (so 'functional bits' that can modify any instruction)?
<mq32>
or is it just "mnemonic op, op, …"?
<fengb>
[_]u8{0} ** 255
<lupine>
oooooooh
<riba>
if i worked with e.g. fmt.allocPrint to get a string, what is the best way to get a null-terminated string to pass back to c? i used the .ptr but the null is probably missing
<lupine>
I'm not sure I even want to look at the precedence rules for that :D
<riba>
i tried adding \0 to the format string but that just lead to a compile error
<marler8997>
yes found it!
<mq32>
riba: try "foo" ++ [_]u8{0}
<mq32>
:D
<lunamn>
that or std.cstr.addNullByte
<marler8997>
problem was in get_const_val, need to check that sentinel pointer is both null and whether the optional value is also null
<gonz_>
Does anyone have a GL project that doesn't use libepoxy?
<riba>
lunamn: is that new after 0.5.0 or am i blind?
<gonz_>
Preferrably also a project that builds out of the box on Linux & Windows.
<riba>
mq32: that... sounds good
<lunamn>
riba: I think that existed before 0.5.0
<mq32>
or you can probably use "\x00" in the string
<riba>
lunamn: oh, maybe the doc generation tool didn't pick it up then? i'll try to find it in the code
<lunamn>
riba: docgen isn't finished, you're much better off with source
<andrewrk>
gonz_, it compiles sdl from source for windows, but I didn't do that work for other targets yet
<gonz_>
Thanks. :)
<mq32>
gonz_: i have one right now, that runs on linux with OpenGL ES
<mq32>
but never had the chance to test/compile for windows
<riba>
lunamn: i sit down for internet-less 15-minute coding sessions in the train and had not downloaded the source, while the docs are one page which i just keep open so it was pretty useful
<riba>
but i guess i should download the source, yes
<leeward>
riba: I'm intrigued by this 15-minute train ride you have where you can sit down. What country are you in?
<riba>
leeward: germany, but i have to take the very first one if i want to find a seat
<mq32>
riba: hello fellow german! i'm using my 45-minute train rides to code every day :D
<riba>
mq32: nice! probably a bit more useful that way
<mq32>
yeah, you can *actually* code some stuff
<mq32>
and i even have "internet"
<Snektron>
gonz_: if you just wana use OpenGL, i recommend the glad headers
<Snektron>
This has been my go-to tool for OpenGL development
<riba>
i'm stuck doing string manipulation for at least a week now
<gonz_>
Ah, yeah, this would probably be relevant.
<gonz_>
Have you run them through `@cInclude`?
<Snektron>
no i haven't done any opengl development on Zig yet
<riba>
using the ptr field of a slice is not the right way to pass a zig string to a c lib it seems?
<Snektron>
but the headers are fairly simply, so i think that it should work
<andrewrk>
riba, we have our first bug prevented by sentinel-terminated pointers!
<Snektron>
actually, theres also a c part to those files, but you can easily incorporate them into your Zig project
<gonz_>
I'll probably take a look at this as well. I'm currently looking at which solution I should use for a vim clone I'm making. It's not going to be some monster thing but I'd probably like a chance to make it in something foundational so as to gain that experience as well.
<gonz_>
I haven't done any GL since ~2008 or so
<Snektron>
it does depend on libc though i just noticed
<leeward>
mq32: That explains why you were online at 3 in the morning.
<Snektron>
Thats a long time, much has changed
<Snektron>
If you're for a general OpenGL project that doesn't use libepoxy, i have one that uses fairly modern OpenGL
<Snektron>
but its c++
<leeward>
andrewrk: That's a pretty great feature. Sentinels are good juju.
<gonz_>
For convenience I'd probably want a zig thing but if the glad headers run fine through the zig machinery I'll most likely just use them with glfw
<gonz_>
And just learn everything from the ground up
<mq32>
gonz_, i wouldn't use GL for a text editor. Text rendering is pure hate ;)
<Snektron>
Its not so bad
<mq32>
Snektron: it depends. i just say "ligatures"
<Snektron>
gonz_: glad + glfw is definitely the way to go
<gonz_>
mq32: Yes, I'm aware. I just think it's a fairly constrained project and I already have a TTF solution for generating textures.
<Snektron>
who uses ligatures anyway
<mq32>
leeward: i *was* actually awake at 3:00 am local time :D
<gonz_>
And I have the opportunity to constrain myself as needed. Ligatures would be nice but whatever, I'll probably just have the editor hardcode Consolas forever anyway.
<Snektron>
jokes aside, you can implement those using the same rendering method
<Snektron>
just make Freetype render a distance texture and render with that
<mq32>
Snektron, does freetype provide distance textures now?
<mq32>
that would be sooo sexy :D
<Snektron>
im not sure actually, i think i saw it somewhere
<Snektron>
Doesn't look like it
<Snektron>
Then implement a nice compute shader to do that
<gonz_>
Granted, this isn't something I've tried out.
<pixelherodev>
Ah, stb - love those headers
<Snektron>
I'm not a particular fan of stb
<mq32>
pixelherodev, yes, didn't help :D
<pixelherodev>
mq32, details? What do you want to accomplish?
<mq32>
gonna do it in query, would spam this channel too much with offtopic
<mq32>
or is anyone else interested in "unusual assembler architectures"?
<gonz_>
Snektron: Thanks for the reminder about glad; I'd actually seen it in a video series someone made about making their own engine a while ago but had forgotten.
<Snektron>
Well im a Z80 fan
<leeward>
mq32: Sure, but I wouldn't have found it unusual for someone to be awake at 9PM my time.
<gonz_>
I'll check it out and if I remember I'll ping you about it working well or not. Also might bother you about stuff I don't get, I suppose.
<Snektron>
no problem, i love to help
<mq32>
Snektron: I'm talking about my own ISA and the one of the propeller by parallax
<leeward>
mq32: I'm writing an emulator for a somewhat unusual architecture.
<leeward>
So...interested, yes.
<mq32>
i have an ISA that has a 16 bit instruction set, using 10 'functional' bits and 5 'command' bits
<mq32>
'functional bit' means that those bits are the same for every possible instruction and can be changed in a meaningful way for each of the 32 possible "commands"
<pixelherodev>
Yeah you can do that
<mq32>
there is one "command" add (which adds two values) that has 1024 possible ways of execution
<mq32>
most of them would respond to a mnemonic "add"
<pixelherodev>
If you give me an example command, I can show you the line needed
<leeward>
So like 2 5-bit registers?
<mq32>
nah
<leeward>
er, not registers, register indices
<mq32>
nah
<mq32>
*very* different :D
<mq32>
pixelherodev, okay i'm trying to make an example, not with "real" bit values because i'm lazy :D
<leeward>
Okay then
<pixelherodev>
I thought that's how the z80 table worked...
<mq32>
example: "cmp stack top with immediate value"
<pixelherodev>
e.g. `INS LD_@A<g3>-,-%B<8> 00@A110 %B`
<leeward>
I'm guessing "cmp" is the command.
<pixelherodev>
That matches e.g. `ld a, 20` and produces `00 $REGCODE 110 00010100`
<pixelherodev>
For a, regcode is 111, so 00111110 00010100
<Snektron>
mp32: Everything is so horribly inefficient. I mean it works, but someone made an actual 3D grapher that works in real time
<mq32>
yeah i know
<Snektron>
compare that with the default grapher for which you had to wait a few seconds before it had finished drawing
<mq32>
but you cannot really implement 9byte fp efficient on z80 :D
<mq32>
f32 yeah
<mq32>
f72? nah :D
<Snektron>
but even without that
<mq32>
all operations work on the REAL datatype
<mq32>
which makes the basic so damn slow
<Snektron>
Its not just the basic interpreter, but the whole thing
<Snektron>
take the screen refresh bcall
<Snektron>
the custom implementation is so much faster
<mq32>
now the hard question: But is it in spec?
<mq32>
or does it "just" work?
<mq32>
that's a difference between homebrew and industry hardware
<mq32>
we use a display in our company that is specified for 14 MHz
<mq32>
i can use that with 75 MHz in my demo, because "it works"
<mq32>
but we cannot ever rely on the display to even work with 15 MHz clock
<leeward>
mq32: That is wacky.
<mq32>
Display thing or cpu arch? :D
<mq32>
probably both :P
<leeward>
The CPU arch
<mq32>
yeah, but it's beautiful as well
<mq32>
coding assembler on a propeller feels more like a highlevel language than lowlevel
<mq32>
except for that weird memory model :D
<Snektron>
mq32: thats a good point yeah
<Snektron>
i just think that TI is very anti people having fun with their products
<leeward>
The display thing reminds me of the story of the engineer who found an extra bit of memory when poking around IO registers on a chip. Then depended on it. Then the manufacturer bumped to a new process and millions of dollars were lost.
<mq32>
maybe ^^
<mq32>
leeward: yeah. always rely on the datasheet, not on the real hardware
<mq32>
you can always argue with the datasheet, but not with "but it worked with the device on my desk!"
<leeward>
Datasheet + errata
<mq32>
yeah
<mq32>
btw, they are building a propeller 2
<mq32>
which is crazyness in perfection
<leeward>
5mA at 80mHz is not too crazy, but that's per cog.
<leeward>
er MHz
<mq32>
milli would be really slow :D
<leeward>
yes
<mq32>
yeah you got 3 cycles per hour
<leeward>
Also, 5mA at basically DC is way too much.
<mq32>
this thing isn't the most efficient CPU
<leeward>
It's not.
<mq32>
but a damn powerful design for 2006
<leeward>
It's certainly interesting.
dimenus has joined #zig
Akuli has quit [Quit: Leaving]
<leeward>
I think the weirdest processor I ever worked on was the Tile64, which is like MIPS but VLIW and 64 cores.
<leeward>
also MIMD
<mq32>
for me it's definitly "Diehl Combitron"
<mq32>
and i think it's unbeatable in strangeness :D
<leeward>
certainly rare
<mq32>
yes
<mq32>
i know of two devices of combitron and one decitron
<pixelherodev>
The what?
<mq32>
pixelherodev: archicture by Stan Frankel, made in the late 60ies
<pixelherodev>
huh
<mq32>
55 bit architecture, has hardware multiply, uses only 120 transistors
<pixelherodev>
...
<pixelherodev>
I'm sorry *what*
<mq32>
has no address comparator or instruction counter
<mq32>
there is no english documentation available, as afaik it was only used and produced in germany
<mq32>
it's absolutly whack
<Snektron>
Huh
<mq32>
there's also an american patent on a similar architecture by frankel
<Snektron>
You didn't write your Bachelor's thesis in English?
<Snektron>
Here in the Netherlands that is pretty much standard
riba has quit [Ping timeout: 252 seconds]
<Snektron>
i got already frowned upon for doing my half-way presentation in Dutch
<mq32>
Snektron: i did not because i would have to invent a whole lot of terms for that thesis
<mq32>
i thought about it, but as i only had german source material ¯\_(ツ)_/¯
<Snektron>
anyway, looks impressive
<Snektron>
nice work
<mq32>
it sure was fun
<mq32>
at one day, a transistor broke and the CPU stopped adding :D
<mq32>
i went to my supervisor and told him: hey, you're better with electronics than me, could you solder my CPU back toghether
<mq32>
and he was like: "No way the CPU broke! you're doing something wrong."
<mq32>
but i could prove with software that the CPU stopped adding, but otherwise worked :D
<pixelherodev>
That's hilarious :)
<mq32>
pixelherodev: YES! :D
<lupine>
Needs more soviet cpus
<Snektron>
My bachelors thesis was just a lot of stress tbh
<pixelherodev>
How does it work if there's no PC?
<mq32>
pixelherodev: it's all about timing
<mq32>
you don't have "RAM"
<mq32>
you have "RCM"
<mq32>
Re-circulating memory
<mq32>
in a delay line
<pixelherodev>
Whoa
<mq32>
(a long string of metal and some super sonic wave signals)
<mq32>
this string holds 10889 bits of data
<mq32>
there's another string with less bits (218)
<mq32>
and the data is running "in circles"
<mq32>
if you need to "fetch the next instruction"
<mq32>
you just link your "instruction register" to the short delay line and let 5 bits cirulate from and to the instruction register
<mq32>
→ you just rol-shift your next instruction
<mq32>
as instructions are 5 bit, but word size is 55 bit
<mq32>
so every word has 11 instructions contained, one is required to be a guaranteed jump
<mq32>
to access memory, you have to "nop" until the right address in the long delay line is "at position" to be circulated through your CPU
<mq32>
=> addressing by waiting
<pixelherodev>
There a C compiler for it? :P
<mq32>
no
<leeward>
Sounds like a good way to go crazy.
<leeward>
LLVM support experimental.
<mq32>
pixelherodev: to write *normal* (linear) assembler you need a non-determinstic compiler
<mq32>
as assembling linear code is (probably) NP-hard
<mq32>
also there is "no" indirect addressing available
<leeward>
Trying to zig fmt my file, and...
<leeward>
src/decode.zig:1:1: error: expected '}', found invalid bytes
<leeward>
const std = @import("std");
<mq32>
ah
<mq32>
known bug
<mq32>
search and replace all tabs
<mq32>
you have a tab in a comment :D
<leeward>
There are tabs?
<mq32>
(or something similar)
<mq32>
at least for me zig fmt does die when having tabs in comments
<leeward>
Yep, that was it.
<leeward>
I had pasted stuff direct from objdmp in comments.
<leeward>
I actually did replace most of the tabs, but missed 1 line.
ky0ko has joined #zig
muffindrake has quit [Quit: muffindrake]
muffindrake has joined #zig
<leeward>
If I want to build an executable and drop it somewhere other than zig-cache/bin, what do I have to change in my Builder? I've tried install_prefix, install_dir, install_path, and cache_root.
<leeward>
Ah, it's the output_dir in my LibExeObjStep.
demizer has quit [Ping timeout: 240 seconds]
<leeward>
Trying to make a literal that I can turn into a `[]const ?[]const u8` and getting "error: expected type '[]const ?[]const u8', found '[]const []const u8'" Is there a way to make a string literal optional?
muffindrake has quit [Quit: muffindrake]
<traviss>
did you try @as(?[]const u8, "string") ?
<leeward>
I did.
<leeward>
expected type '[]const u8', found '?[]const u8'
<leeward>
pointing at the @
<leeward>
ugh, that doesn't say what I thought it said...
wootehfoot has quit [Read error: Connection reset by peer]
muffindrake has joined #zig
<leeward>
ahah, that was it but I had type annotations that needed updating
<leeward>
Of course, all this was to set exec_cmd_args and it turns out that doesn't do what I thought it would.
<traviss>
i know that feeling well
adamkowalski has quit [Ping timeout: 276 seconds]
mahmudov has quit [Remote host closed the connection]
<leeward>
I love it when I run a test for some brand new code and it finds a bug. So much better than finding the bug later.
kapil_ has quit [Quit: Connection closed for inactivity]