ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
jcs_ is now known as jcs
yxhuvud has quit [Ping timeout: 268 seconds]
yxhuvud has joined #crystal-lang
brw has quit [Quit: The Lounge -]
brw has joined #crystal-lang
brw has quit [Client Quit]
<FromGitter> <> I'm having trouble casting a type to a more permissive type. For example, suppose I define my type as: ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <> It seems like since `PermissiveType` is strictly more permissive than `Array(String)` this cast should be possible - any possible value of that more restrictive type should satisfy the more permissive type.
<FromGitter> <> How do I accomplish that?
Welog has joined #crystal-lang
^raz^ has quit [Changing host]
^raz^ has joined #crystal-lang
^raz^ is now known as raz
<FromGitter> <wyhaines> What you are running into is that while one can logically look at an *Array(String)* and see that an *Array(String | Int32)* can store everything in it, type specifications are very specific, and your type specification is for two things, either an *Array(String | Int32)*, or *String*, and what you are trying to assign is an *Array(String)*, which is not either of those things. ⏎ ⏎
<FromGitter> ... ```ss : PermissiveType = Array(String | Int32).new + ["hello", "world"]``` ⏎ ⏎ That will create an array with a type signature that matches what PermissiveType allows. []
<FromGitter> <naqvis> ^ or provide the type of literal ⏎ `ss : PermissiveType = ["hello", "world"] of String | Int32`
<FromGitter> <naqvis> if yo don't provide the type, compiler will infer that as `Array(String)`
<FromGitter> <wyhaines> Thanks. My daughter interrupted me to move the van, and you finished for me. :)
<FromGitter> <naqvis> :P
viole has quit [Ping timeout: 264 seconds]
fifr is now known as fifr_
Guest20 has joined #crystal-lang
fifr_ is now known as fifr
jhass[m] has quit [Read error: Connection reset by peer]
fifr[m] has quit [Read error: Connection reset by peer]
jhass[m] has joined #crystal-lang
fifr[m] has joined #crystal-lang
<FromGitter> <wyhaines> are you the current maintainer of crystal-readline? I have a private fork of it that I have been forced to maintain because the mainline lacks proper Crystal 1.0+ support. If I provide a PR, can we get the mainline project updated and a new release built?
<FromGitter> <> I'm not the maintainer but that would be useful for me too
avane has quit [Ping timeout: 272 seconds]
krthr has joined #crystal-lang
krthr has quit [Quit: Client closed]
mattt has joined #crystal-lang
<FromGitter> <wyhaines> OK. I saw a commit from you on the main repo, so I was wondering.
viole has joined #crystal-lang
avane has joined #crystal-lang
Guest20 has left #crystal-lang [#crystal-lang]
<FromGitter> <kalinon> Anyone know how to build with `-Dpreview_mt` in the `alpine-build` docker image?
<FromGitter> <Blacksmoke16> try in the nightly image
<FromGitter> <Blacksmoke16> was merged recently but not sure if it's actually in the nightly image atm or if there's another step that needs done to enable it
<FromGitter> <kalinon> oh nice ill try it out
<FromGitter> <didactic-drunk> Is there a macro or easy way I can store the caller of `\.new`for reference later in `finalize` to track potential API misuse? I would prefer easy single line way to add this to any class
<FromGitter> <kalinon> Ah, didnt work. but worth a try.
<FromGitter> <Blacksmoke16> should be included in the next release or something at least
<FromGitter> <kalinon> yeah, thats good to know. Dont need it right now, so no worries. glad its on the roadmap
<FromGitter> <wyhaines> @didactic-drunk that complete functionality doesn't exist so far as I am aware, but all of the building blocks exist. Maybe it can be my macro-hacking project of the week to build it. ⏎ ⏎ Right now I am picturing something such as simple as `include CallTrace`, followed by an annotation on top of any method that one want's to build a call tracing stack for. ⏎ ⏎ The actual call trace would be
mattt has quit [Quit: WeeChat 1.4]
mattt has joined #crystal-lang
brw has joined #crystal-lang
postmodern has joined #crystal-lang
<FromGitter> <mixflame> hello guys... this code pings out on Rizon (Ping Timeout) after it joins the #8chan channel... I asked in #Help on Rizon but I'll post the code here in case anyone wants to try to find the issue.... it has to do with the level of chatting... I suspect I need a "spawn" somewhere.
<FromGitter> <mixflame> note that rizon is a custom network with special requirements that other networks don't possess.... like pinging on connect... might look wrong for other networks or just be fine... not sure about IRC internals as much as others might be
<FromGitter> <mixflame> if you want to use it to build a bot, go ahead, it's based on the irc lib for crystal on github
<FromGitter> <mixflame> be aware of the ping issue and if you find a solution let me know
<FromGitter> <mattrberry> How do you properly case over a runtime type of an object?
<FromGitter> <Blacksmoke16>
<FromGitter> <mattrberry> Ah
<FromGitter> <mattrberry> Thank you
<FromGitter> <mattrberry> I feel like mine should still work though
<FromGitter> <mattrberry> Or am I misunderstanding something? ⏎ (sorry for sending 4 messages when I could have sent 1 lol)
<FromGitter> <mattrberry> Also as a side note, I feel like we shouldn't need to include `A` as one of the branches of the case since it cannot have an instantiation at runtime
<FromGitter> <HertzDevil> crystal-lang/crystal#9116
<FromGitter> <Blacksmoke16> Is nothing preventing you or someone else to extend it and break it
<FromGitter> <HertzDevil> well you definitely cannot omit `A.class` for the original snippet because `A` is indeed an instantiation of `A.class`
<FromGitter> <mattrberry> Ah, gotcha
<FromGitter> <mattrberry> If I wanted to check the runtime type of an object in my example there, but I defined === on A, how would I go about doing that? Or would I just have to use a conditional expression to check the class?
<FromGitter> <Blacksmoke16> sure you want `===` and not `==`?
<FromGitter> <mattrberry> I don't actually have a use-case for it
<FromGitter> <mattrberry> I'm just wondering
<FromGitter> <Blacksmoke16> `===` should only be needed if you need custom case equality logic
<FromGitter> <Blacksmoke16> it might just work tbh, like see the the `when` value is a type as the compiler expands it to `is_a?`
<FromGitter> <mattrberry> Oh does the compiler special-case that?
<FromGitter> <Blacksmoke16> i think so yea
<FromGitter> <Blacksmoke16> be easy enough to try
<FromGitter> <mattrberry> Yeah seems like it does
<FromGitter> <mattrberry> Only other thing then would be that this should technically be able to compile I believe, since foo.is_a? cannot be an A, right?
<FromGitter> <HertzDevil> that's what that rfc discusses
<FromGitter> <mattrberry> Ah gotcha, thank you
<FromGitter> <Blacksmoke16> well technically `foo.is_a? A` would be true in either case
<FromGitter> <Blacksmoke16> since its a parent to both
<FromGitter> <Blacksmoke16> e.g.