<oprypin>
postmodern: Pointer.malloc is fully hooked to GC
<FromGitter>
<ImAHopelessDev_gitlab> @j8r yeah, i think you can do primitives with random vertices. however, i've never done a 3d game so take my info with a grain of salt :D
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
darkstardev13 has quit [Ping timeout: 260 seconds]
darkstardevx has joined #crystal-lang
<FromGitter>
<grkek> @asterite Do I still make the issue for the bug?
<FromGitter>
<elorest> Is there a way to get the bytes from a struct without changing it to a pointer first? β β https://carc.in/#/r/8vku
ur5us has joined #crystal-lang
_ht has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
<oprypin>
elorest: no. do you know that it can be different depending on hardware?
<FromGitter>
<elorest> I know that the padding and Endianess could be. Are you saying the syntax would be too?
<FromGitter>
<elorest> <oprypin> So the pointer syntax is `the only` way to get them? `b = Bytes.new(pointerof(t1).as(Pointer(UInt8)), sizeof(Test1))`
<oprypin>
no; yes
<oprypin>
huh does it work without casting to Void* first
<FromGitter>
<elorest> *<oprypin>* :( ; :)
<FromGitter>
<elorest> Yeah that code works on both ARM linux, x86 Mac and Linux.
<FromGitter>
<elorest> It think in crystal casting it to `Pointer(UInt8)` is the same as Void in C.
<FromGitter>
<elorest> I'll try void though.
<oprypin>
why try it if your code already works π
<FromGitter>
<elorest> Sometimes things work but for the wrong reason and later they don't lol. β β Like how `2**31-1` worked for ever in crystal and gave the correct result but now it throws an overflow exception. Obviously it is an overflow but since subtraction is technically an overflow operation anyway it technically gave the correct result.
ur5us has joined #crystal-lang
<FromGitter>
<elorest> <oprypin> Anyway thanks. My pointer code works I was just trying to figure out if there was a way to do it without unsafe operations.
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 265 seconds]
claudiuinberlin has joined #crystal-lang
<hightower2>
Hey folks, any plans to support crystal on ppc64?
<oprypin>
i want thumbs up!!!!!!! validation!!! it's a good read though. about linux process exit codes and signals
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzzβ¦]
ur5us has joined #crystal-lang
gangstacat has quit [Quit: Δis!]
darkstardevx has quit [Ping timeout: 265 seconds]
<hightower2>
Hey folks, in Crystal's file spec/llvm-ir/test.sh , The last "test memcpy.cr" block is an identical copy of the previous one. Is this a copy/edit error? Should one of them be for i686 or something, instead for x86_64 twice?
ur5us has quit [Ping timeout: 260 seconds]
<oprypin>
hightower2, there are no identical lines in that file. memset.cr vs memcpy.cr
<FromGitter>
<acook> At some point `YAML::Any#each` was removed, so now my app breaks. I can't find it mentioned in the changelog when or why it happened. `#each` is still mentioned on the documentation for `YAML::Any` but it's not actually there anymore. What is the new strategy for iterating through arbitrary YAML documents?
<FromGitter>
<acook> Thanks for identifying that issue on github, I was grepping through the commits trying to figure out where it happened and why.
<FromGitter>
<acook> I can see from the discussion there that arbitrarily iterating over an unknown data structure could have different an unexpected results. It's less immediately convenient but I get why. If there are different types expected I can do an `is_a?` or a type switch or something.
<FromGitter>
<acook> I'll have to look into the lower level APIs they mention in that thread, but after the app is working again.
<oprypin>
u can consider PullParser too
<oprypin>
that answer i posted is for kinda arbitrary structure
<oprypin>
u can use `Any.raw` too
<jhass>
or map out the structure using YAML::Serializable
<FromGitter>
<acook> It looks like Crystal also lost the File::Stat type and it became File::Info. Looks like that change could be good for portability. I'm looking forward to being able to compile things for Windows.
<FromGitter>
<acook> Able to compile my existing programs I mean, and have them work as expected :)
<FromGitter>
<acook> I wrote a clone of Ruby's Pathname in Crystal with a few tweaks, that's what uses File::Stat. I appreciate that Crystal is building better tools and not just throwing them in. I'm fine building my own hacks in the meantime. I do like the kind of things I can do with Pathname. And Crystal's Path is becoming pretty interesting.
<FromGitter>
<acook> Ah, the downside of the `YAML::Any#as_h` is that I can no longer use the same code for other types. I'll have to ensure that the YAML is already converted to a Hash earlier in the process.
<FromGitter>
<stronny> that would force user to check the nature of the event and use appropriate methods to extract meaningful values
gangstacat has joined #crystal-lang
<FromGitter>
<acook> Interestingly, if I don't put the `.as_h` right after the `.parse` then Crystal thinks the value could be an array or a hash, even though it's never mutated. Pretty weird.
<FromGitter>
<acook> Oh I see why, nvm. I did something farther up to set the default value.
postmodern has quit [Quit: Leaving]
<repo>
hey Blacksmoke16! i saw you made a pr about better uuid support in granite. I'm struggling to set up uuid primary keys with postgres in granit. I get an error: Error: no overload matches 'Granite::Type.from_rs' with types PG::ResultSet, UUID.class
<FromGitter>
<Blacksmoke16> Are you using a converter?
<repo>
no, but i just think i figured it out from the specs
<FromGitter>
<Blacksmoke16> so yea, should just work and rollback on any exceptions
<repo>
ok nice
<repo>
thanks!
<repo>
ah :( granite doesn't support preloading associations
<repo>
so far crecto is still the most feature complete orm i've seen
<repo>
but it has some flaws which prevent me from using it for this
<FromGitter>
<acook> Looks like there was an old discussion about terminal libraries, someone saying it was "impossible" to write cross-platform ways to get terminal sizes in Crystal specifically. Bizarre. My code works fine, I ported it from one of my Ruby gems, and it works on every unix-like OS. The magic numbers are annoying but not that big of a deal. Anyway, I assume the decision to keep that kind of thing as a shard is still
<FromGitter>
... the case?
<hightower2>
repo Check also avram from the lucky project
<hightower2>
acook what code do you use?
<repo>
hightower2: i love avram but it's really annoying to use in a project separate from lucky
<repo>
hightower2: also it doesn't currently even support ORing wheres
<repo>
at least not when i last checked
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
xybre is now known as acook
<acook>
hightower2, what code? I don't think I understand
<repo>
hmm
<repo>
Error: no overload matches 'Redo::Api::Models::AuthorizationCode.create!' with type Hash(Symbol, Granite::Base | Redo::Api::Enums::CodeChallengeMethod | Slice(UInt8) | Nil)
<FromGitter>
<Blacksmoke16> id advise against using `create!`, probably best to just define a custom initialize to handle what you want to do
<FromGitter>
<Blacksmoke16> if you got some sample code i could prob give a better solution
<karchnu>
wmoxam: wait, you did port 0.34 on openbsd?
<wmoxam>
yep
<karchnu>
that's awesome, I just worked a whole night on it and still having a few linker problems :) Thanks!
<wmoxam>
I had trouble with 0.32 and 0.33, but 0.34 went pretty smoothly
<wmoxam>
karchnu: This is on the latest OpenBSD snapshot. I haven't tested on 6.6
<karchnu>
wmoxam: I tried to cross-compile it from a fresh alpine, but I suspect LLVM/Clang not to be compiled with the same parameters on both sides (but 8.0.1 on each side)
<wmoxam>
ah
<karchnu>
wmoxam: that's okay, I will just wait for the next release
<FromGitter>
<smprather> hi Pros. i'm having a problem with an Alpine Docker static build. when i get to the end of reading a file, i'm getting "Invalid memory access (signal 11) at address 0x0" on the next fh.read_line, instead of an exception that i normally handle w/ begin/rescue/end. no problem with a regular non-Docker build. ideas for a workaround?
<FromGitter>
<smprather> i just tried removing --static from the Docker build. it works ok when i do that. bummer, i was hoping to get away from doing a different build for each Redhat version i support and a wrapper script to dispatch to the proper platform exec. my static "Hello World" test worked on all platforms, so i was jazzed.
<FromGitter>
<Blacksmoke16> got some sample code that reproduces the issue?
<FromGitter>
<Blacksmoke16> using MT at ll?
<FromGitter>
<Blacksmoke16> all*
<FromGitter>
<smprather> i do use MT, but not in this area of the code. let me try to cut it down to the bare minimum that it takes to get a fail...
<FromGitter>
<Blacksmoke16> π probably a good step
<FromGitter>
<Blacksmoke16> and to be clear, MT being enabled would make anything that uses fibers be MT enabled
<FromGitter>
<Blacksmoke16> as its just based on fibers and `spawn` keyword
<claudiuinberlin>
I was thinking to rebuild du -h :) from linux, but then I have to read a lot of c :)
<FromGitter>
<Blacksmoke16> are plenty of web frameworks out there
<FromGitter>
<smprather> @Blacksmoke16 Never mind, i didn't re-create my test loop correctly. fixed. now it still segs. i'll file bug. thanks for all the help (esp fixing my bonehead to get me to 0.34.0)!
<FromGitter>
<Blacksmoke16> np
Human_G33k has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> in reality tho, id try to use `.each_line`, using higher level iterators is usually the way to go
<FromGitter>
<Blacksmoke16> unless there is a reason to go lower
Human_G33k has joined #crystal-lang
<FromGitter>
<smprather> well, like i said, i had a reason to use that, but honestly, it wasn't a very strong one. going to each_line is no big deal.
<FromGitter>
<Blacksmoke16> π
<FromGitter>
<Blacksmoke16> mainly its more stable, tested, and can sometimes come with perf bonuses as optimizations can be built in
alexherbo2 has joined #crystal-lang
<acook>
I don't suppose there's a way to re-namespace two shards which use the same module/class name internally?
<FromGitter>
<Blacksmoke16> are they not namespaced by the shard name?
<raz>
speaking shard, i wish it would fetch the deps in parallel
<raz>
i measured it and this would make me 4.15% more productive
<claudiuinberlin>
there is a way to list all the methods for a given class module?
<claudiuinberlin>
in python dir(x), or ruby x.methods
<FromGitter>
<Blacksmoke16> in a macro yes, `{{pp MyKlass.methods.map &.name}}`
<claudiuinberlin>
thx
<FromGitter>
<acook> @Blacksmoke16 No, they're namespaced by whatever code they put in the shard. In this case, they named both of their top level classes `Magic`.
<FromGitter>
<Blacksmoke16> ouch
<FromGitter>
<acook> Even though the repos and listed name in the shard.yml are different.
<oprypin>
acook, does `module M; require "foo"; end` work? :thinking:
<FromGitter>
<Blacksmoke16> what are the shards?
<FromGitter>
<Blacksmoke16> id be surprised if it did
<FromGitter>
<Blacksmoke16> is there a reason to use both?
<FromGitter>
<acook> Nope. `Error: can't require inside type declarations`
<FromGitter>
<acook> I wanted to do an incremental switchover from one library to the other and do some testing between them before going all in. But they clobber some of each other's constants and Crystal won't let them be redeclared even if they're set to the same value.
<FromGitter>
<Blacksmoke16> :/
<FromGitter>
<acook> It's not a huge changeset, I just wanted to see the output side by side in the same binary.
<FromGitter>
<acook> I humbly request that we be allowed to do something like `module M; require "foo"; end` or `require "foo" as Bar`.
<FromGitter>
<smprather> @Blacksmoke16 gotcha. i figured i wasn't the first to come across this. i hope it is resolved soon. i have to parse two files that can be many GB in size. i want to parse each in a thread. but it looks like i'll have to wait a while before i can do it with the Holy Grail static link (i'm sick of building separate for each platform).
<FromGitter>
<Blacksmoke16> ES6 style imports would be nice yes
<FromGitter>
<Blacksmoke16> one can dream :p
<oprypin>
yea this is a mess
<FromGitter>
<acook> But it seems like the way the Crystal compiler currently works that it's not just a semantic change, it'd likely have to approach the process of requiring different and that might make reopening classes weird. Like, if I do a `module M; require "foo"; end` and a normal `require "foo"` in the same file and reopen `module Foo` do both change or are they essentially instances?
<FromGitter>
<Blacksmoke16> namespacing is good, but only ways to avoid long names in code are aliases, or including that module (and all its methods etc) into another namespace
<FromGitter>
<Blacksmoke16> the former is doable for common stuff you need, but the latter is less than ideal
darkstardevx has joined #crystal-lang
<FromGitter>
<acook> Yeah I think aliases is a fine way to go, but it'd still require reworking the compiler's internals so two different files that declare the same name are considered separate entities instead of reopened. That could be a big change. I haven't looked at the compiler yet, so I might be wrong.
ht_ has joined #crystal-lang
<FromGitter>
<smprather> i found another one: `FileUtils.rm("#{@log_file}.bak") rescue nil` --> `Invalid memory access (signal 11) at address 0x0`
_ht has quit [Ping timeout: 265 seconds]
ht_ is now known as _ht
<oprypin>
smprather, wait what's the context on that?
<FromGitter>
<smprather> and Crystal has not implemented Ruby's FileUtils.rm_f :(
<FromGitter>
<smprather> that file does not exist, so the thrown exception is not rescued. oh, another context is that this is Docker/Alpine/Static build. local-host dynamic is ok.
<FromGitter>
<smprather> @FromIRC IMO, the assets are: you get to write Ruby'ish code and it is blazing fast including multi-threading (* see intertwined conversation for at least one caveat).
ur5us has joined #crystal-lang
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
<repo>
too bad instance variable types can't be inferred by an assignment with .as(Type)
<oprypin>
hm yea
<repo>
i'm in a situation where i can set these instance variables only after all other instance variables have been defined
ua has quit [Ping timeout: 264 seconds]
<FromGitter>
<ondreian> I'm having a problem writing raw `Bytes` instance to a `TCPSocket`, as soon as I do, I am unable to perform `socket.gets` anymore
ur5us has quit [Ping timeout: 260 seconds]
<oprypin>
ok, u wanna talk about it?
<claudiuinberlin>
if I import @[Link(framework: "Foundation")] , how do I call from example the method: NSUserName(), from FileManager class?
<claudiuinberlin>
sorry to just ask random questions
<oprypin>
claudiuinberlin, uh what i dont think there are classes
<FromGitter>
<asterite> I think it's possible to call objectivec methods, there were some experiments... but you need to call functions in a different way, I can't remember
ur5us has joined #crystal-lang
<claudiuinberlin>
another question, in ruby you could do [].map {|x| x.foo} or method(x)
<FromGitter>
<Blacksmoke16> `[].map &.foo`?
<FromGitter>
<Blacksmoke16> would call `#foo` method on each item in the array
<claudiuinberlin>
what is & in crystal, a proc?
<claudiuinberlin>
aaa
<FromGitter>
<Blacksmoke16> same as `.map &:foo` in ruby
<claudiuinberlin>
and if I want to use it in a method, aka [].map{|x| some_method(x)}
<FromGitter>
<smprather> @Blacksmoke16 I was going to report the bug, but it looks like it has already been done. It relates to *any* exception unrolling. https://github.com/crystal-lang/crystal/issues/4276
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzzβ¦]
<FromGitter>
<Blacksmoke16> ah, well that would do it
<FromGitter>
<Blacksmoke16> assuming the array is `Array(String)`
_ht has quit [Quit: _ht]
<FromGitter>
<ondreian> With regards to my `Bytes` & `TCPSocket` issue, I just made this reduced playground sample that demonstrates what I'm doing and some comments about what I problem I am having: https://play.crystal-lang.org/#/r/8voi
<FromGitter>
<ondreian> I have a working ruby implementation and the `Bytes` objects themselves are the same
claudiuinberlin has joined #crystal-lang
<oprypin>
ondreian, maybe you need `flush` / `sync`
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzzβ¦]
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
mistergibson has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter>
<stronny> @ondreian I would look at tcpdump to confirm what bytes actually go and come
<FromGitter>
<stronny> had a weird bug *twice* when some bytes were leaving early in separate packages (that was a bit of a problem because my task was to measure latency heh)