ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
yespal has quit [Quit: Connection closed]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter> <Blacksmoke16> would be cool if the compiler could handle flag enums with symbols
<FromGitter> <Blacksmoke16> `:required | :is_array`
chachasmooth has quit [Ping timeout: 268 seconds]
<FromGitter> <naqvis> Should be a piece of cake for HertzDevil to implement this :P
chachasmooth has joined #crystal-lang
<FromGitter> <Blacksmoke16> hehe, it currently sucks when the FQN of the enum members are long :(
<FromGitter> <naqvis> that's true
<FromGitter> <Blacksmoke16> `ACON::Input::Option::Value::OPTIONAL | ACON::Input::Option::Value::IS_ARRAY` 😢
<FromGitter> <naqvis> that's too much of typing
<FromGitter> <Blacksmoke16> ikr?
<FromGitter> <naqvis> yup
<FromGitter> <naqvis> might be worth if it you can raise a RFC
<FromGitter> <Blacksmoke16> ill check for an existing issue tomorrow and make one if not
<FromGitter> <naqvis> as this suggestion will get lost on gitter and difficult to see for others joining late
<FromGitter> <tenebrousedge> I feel like that one has come up before
<FromGitter> <naqvis> iirc there was whole lot of debate of having symbols removed
<FromGitter> <Blacksmoke16> yes, i would like that :P
postmodern has joined #crystal-lang
<postmodern> when you type in a floating point literal, is it a Float32 or Float64? I'm getting weird rounding issues in this algorithm I ported from chunky_png for converting RGB<->HSL/HSV
<postmodern> think it may be related to single vs double precission
Human_G33k has left #crystal-lang ["Leaving"]
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 252 seconds]
f1reflyylmao is now known as f1refly
<FromGitter> <tenebrousedge> Float64
<FromGitter> <tenebrousedge> `typeof(0.0)`
_ht has joined #crystal-lang
<FromGitter> <erdnaxeli:cervoi.se> I still don't see the point of symbols, but maybe I am missing something
<FromGitter> <naqvis> I also hate them :P
hendursa1 has joined #crystal-lang
hendursaga has quit [Ping timeout: 240 seconds]
postmodern has quit [Quit: Leaving]
fifr` has quit [Ping timeout: 265 seconds]
fifr` has joined #crystal-lang
mipmip has joined #crystal-lang
mipmip has quit [Ping timeout: 260 seconds]
alexherbo2 has joined #crystal-lang
mipmip has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <RespiteSage> You can also specify the type of the literal (https://crystal-lang.org/reference/syntax_and_semantics/literals/floats.html) if you need to.
<FromGitter> <RespiteSage> Is there a way to check whether one numeric type is coercable to another?
<FromGitter> <tenebrousedge> which types?
<FromGitter> <tenebrousedge> like you can try it and see if it goes boom
<FromGitter> <RespiteSage> Yeah, but I'm trying to avoid exception handling as logic. That's the way my shard (saline (https://github.com/RespiteSage/saline)) currently works, and I want to improve its speed.
<FromGitter> <tenebrousedge> I mean you can just take a look at how many bits you have and whether they're signed
<FromGitter> <RespiteSage> I'm thinking that what I want doesn't actually exist in the language. For some reason, I thought that the numeric types had `#to_i?`-style methods.
<FromGitter> <RespiteSage> Yeah, that's probably what I need to do. Thanks.
<FromGitter> <tenebrousedge> I think they might
<FromGitter> <tenebrousedge> but getting a nullable type isn't going to be an improvement, that's just a different way of doing error handling
<FromGitter> <RespiteSage> All I see are `#to_iX`, which throws an exception on overflow, and `#to_iX!`, which wraps on overflow (where `X` is a bit-length).
<FromGitter> <RespiteSage> And similarly for floats, unsigned ints, etc.
<FromGitter> <tenebrousedge> I must have been thinking of the wrapping thing
<FromGitter> <RespiteSage> Yeah, same here. Or I was getting mixed up with strings.
<FromGitter> <elementio:salt-rock-lamp.ems.host> does crystal have a formal grammar? if so, it might be nice to have a tree-sitter parser for it
<FromGitter> <elementio:salt-rock-lamp.ems.host> s/parser/grammar
<FromGitter> <elementio:salt-rock-lamp.ems.host> for example, ruby has a grammar: https://github.com/tree-sitter/tree-sitter-ruby
Dreamer3 has joined #crystal-lang
<FromGitter> <ryanstout> I'm trying to convert a c uint16 array to a crystal uint16 array. (from a c-binding). Can anyone point me to where the `as` pseudomethod is implemented in the compiler. (Having the toughest time finding it).
<FromGitter> <Blacksmoke16> pretty sure `.as` is for reducing unions, dont think thats what you want here?
<FromGitter> <ryanstout> there's a section about casting a pointer to an array
<FromGitter> <ryanstout> but I'm confused because I don't think it would know the size
<FromGitter> <oprypin:matrix.org> @ryanstout: no in that example it just was an array all along
<FromGitter> <oprypin:matrix.org> array as a type is a container of 3 values, one of them the pointer to the actual heap array
<FromGitter> <oprypin:matrix.org> so obvs you can't convert just a heap array to a Crystal Array
<FromGitter> <ryanstout> ok, got it. So it's pointing to the crystal struct for the array not the buffer
<FromGitter> <ryanstout> makes since
<FromGitter> <oprypin:matrix.org> @ryanstout: so basically you wouldnt convert it, you would copy over the data into a new array
<FromGitter> <ryanstout> ok, any way to go from a C pointer to a crystal array without the copy?
<FromGitter> <ryanstout> (open the array class and add a new constructor :-)
<FromGitter> <Blacksmoke16> 😬 that sounds like a bad idea
<FromGitter> <oprypin:matrix.org> cant go from C pointer to crystal array, you cant pass ownership of C-allocated memory to crystal, crystal only wants to deal with GC-allocated memory
<FromGitter> <oprypin:matrix.org> if possible, u should allocae memory in crystal, pass that to the C lib, and let it fill that
<FromGitter> <oprypin:matrix.org> if not possible, just .. yeah not possible
<FromGitter> <ryanstout> seems like you could wrap it and let C side handle freeing right?
<FromGitter> <ryanstout> bohem won't see it, but thats fine on my end
<FromGitter> <ryanstout> unless the pointer being on the stack is going to mess things up
sorcus has quit [Ping timeout: 246 seconds]
<FromGitter> <oprypin:matrix.org> @ryanstout: if it's "fine on your end" then why are you dealing with a Crystal Array at all
<FromGitter> <ryanstout> but bohem wouldn't know it was a pointer to malloced memory right?
<FromGitter> <ryanstout> for the bounds checks
<FromGitter> <oprypin:matrix.org> that's a Slice then
<FromGitter> <ryanstout> ah, good call
<FromGitter> <ryanstout> thanks
<FromGitter> <ryanstout> ^ coffee hasn't kicked in yet :-)
<FromGitter> <oprypin:matrix.org> thanks for reminding, gotta grab mine
sorcus has joined #crystal-lang
Dreamer3 has quit [Quit: Leaving...]
<FromGitter> <RespiteSage> Am I missing something with `crystal tool expand`? `crystal tool expand path/to/file` just prints the help message.
<FromGitter> <Blacksmoke16> iirc theres some `-C` argument you need to do like `-C path/to/file:line:col`
<FromGitter> <tenebrousedge> `crystal tool expand -c foo.cr:0:0 foo.cr`
<FromGitter> <RespiteSage> Excellent. Thanks!@
<FromGitter> <RespiteSage> *!
_ht has quit [Remote host closed the connection]
<FromGitter> <alex-kampa> I have a question about how to use HTTP::Client.post. Using "response = HTTP::Client.post(address, headers, msg)" I get the error
<FromGitter> <alex-kampa> Error: no overload matches 'HTTP::Client.post' with types String, HTTP::Headers.class, String
<FromGitter> <alex-kampa> Why can the msg not be a string?
<FromGitter> <Blacksmoke16> `HTTP::Headers.class` you're not passing it the headers correctly
<FromGitter> <Blacksmoke16> can you share more of the code?
<FromGitter> <alex-kampa> headers = HTTP::Headers ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=608b1277471bee582e217046]
<FromGitter> <Blacksmoke16> `headers = HTTP::Headers` idt you can make it multililine like that
<FromGitter> <Blacksmoke16> try at least having the first `{` next to `HTTP::Headers`, like `header = HTTP::Headers{`
<FromGitter> <alex-kampa> Indeed! Thx a lot @Blacksmoke16
<FromGitter> <alex-kampa> Indeed! Thx a lot @Blacksmoke16
<FromGitter> <alex-kampa> This worked:
<FromGitter> <alex-kampa> headers = HTTP::Headers { ⏎ ⏎ ```"Authorization" => "Bearer #{api_key}", ⏎ "Content-Type" => "application/json"``` ⏎ ⏎ } [https://gitter.im/crystal-lang/crystal?at=608b133269231732f4cb72ff]
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <elementio:salt-rock-lamp.ems.host> So `HTTP::Client` doesn't support raw `Bytes` in the body? https://crystal-lang.org/api/1.0.0/HTTP/Client.html#post(url,headers:HTTP::Headers?=nil,tls:TLSContext=nil,*,form:String%7CIO%7CHash,&)-class-method
<FromGitter> <Blacksmoke16> are looking at the wrong overload i think
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/HTTP/Client.html#post(url:String%7CURI,headers:HTTP::Headers?=nil,body:BodyType=nil,tls:TLSContext=nil):HTTP::Client::Response-class-method and the next one
<FromGitter> <elementio:salt-rock-lamp.ems.host> ah you're right
<FromGitter> <elementio:salt-rock-lamp.ems.host> `body` vs `form`
<FromGitter> <tenebrousedge> So if I have a macro like ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I get a bunch of newlines in the generated output. This is kinda obnoxious for debugging. Any way to avoid that? [https://gitter.im/crystal-lang/crystal?at=608b154aa05f8b582a15716c]
<FromGitter> <Blacksmoke16> iirc yes, but i dont remember what i was
<FromGitter> <Blacksmoke16> try doing like `%} \`
<FromGitter> <tenebrousedge> huh
<FromGitter> <tenebrousedge> those get output literally
<FromGitter> <riffraff169> in erb it was `-%}` i believe
<FromGitter> <tenebrousedge> syntax error
<FromGitter> <riffraff169> actually, erb used `-%>` i think, but since this uses `}`, maybe that...hmmm
<FromGitter> <Blacksmoke16> `%}\`
<FromGitter> <Blacksmoke16> no space
<FromGitter> <riffraff169> ha interesting
<FromGitter> <tenebrousedge> Thanks @Blacksmoke16
<FromGitter> <tenebrousedge> oh gumdrops 😾
<FromGitter> <tenebrousedge> the bug goes away when I add `focus: true` to the failing test
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
<FromGitter> <tenebrousedge> okay, great, now it's just segfaulting :plus1:
<FromGitter> <Blacksmoke16> lovely
<FromGitter> <tenebrousedge> it could be that I'm just allocating my strings wrong. I'll check in a minute