RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
hightower3 has quit [Ping timeout: 248 seconds]
sauer2 has quit [Quit: Page closed]
<FromGitter> <fgimian> @silasb Very interested in bindings to libssh2. I'm still rather new to Crystal, but will take a look and see if I can suggest any way to write this binding.
<FromGitter> <fgimian> are you aware of the existing ssh2-cr library too, maybe that can serve as a reference or a single point of collaboration
<FromGitter> <fgimian> This project may also be helpful, I haven't tried it on a project yet myself though - https://github.com/crystal-lang/crystal_lib
moei has quit [Quit: Leaving...]
zachk has quit [Quit: Leaving]
akaiiro has quit [Ping timeout: 276 seconds]
akaiiro has joined #crystal-lang
akaiiro has quit [Ping timeout: 260 seconds]
akaiiro has joined #crystal-lang
<FromGitter> <fridgerator> @bcardiff is he sqlite 0.25.0 branch going to be merged soon?
akaiiro has quit [Ping timeout: 260 seconds]
akaiiro has joined #crystal-lang
<FromGitter> <codenoid> this is our house this is our rule
<FromGitter> <fridgerator> is that quote from 3 ninjas?
<FromGitter> <codenoid> it's MileyCyrus(We Can't Stop) song lyrics
akaiiro has quit [Ping timeout: 256 seconds]
jfontan has quit [Ping timeout: 268 seconds]
akaiiro has joined #crystal-lang
<FromGitter> <fgimian> Hey guys, how do I check if a variable is nil inside a macro? `var.nil?` always returns
<FromGitter> <fgimian> πŸ˜„
<FromGitter> <fgimian> oh i found an example in a shard
<FromGitter> <fgimian> you must actually do `== nil`
<FromGitter> <fgimian> weird but cool πŸ˜„
<FromGitter> <fgimian> would be nice if `.nil?` did the usual thing there, that's a bit confusing
moei has joined #crystal-lang
<FromGitter> <fgimian> folks, can anyone suggest a way to accomplish this task using Crystal?
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b24a52232618e705ebefd49]
<FromGitter> <fgimian> this is the Ruby code that works
<FromGitter> <fgimian> I want to access the constant for the subclass using a method in the parent
<FromGitter> <fgimian> looks like macros is the way
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b24a66febf21755ca361766]
DTZUZO has joined #crystal-lang
hightower3 has joined #crystal-lang
<oprypin> fgimian, that's curious
<FromGitter> <fgimian> thanks, checking it out now πŸ˜„
<oprypin> not much to see there tbh, you just have a better workaround. maybe comment it there
<FromGitter> <fgimian> oh
<FromGitter> <fgimian> ok!
<FromGitter> <fgimian> looks like you've been on a longer journey than me on this one πŸ˜†
<FromGitter> <fgimian> done
<crystal-gh> [crystal] kostya closed pull request #6009: add json mapping extra fields (master...json_extra) https://git.io/vpcu6
<oprypin> thx
<FromGitter> <fgimian> my pleasure, glad to know it wasn't just me hitting this problem
<FromGitter> <fgimian> ok onto the next problem
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b24bb2482b1b355c95c8db6]
<FromGitter> <fgimian> suppose I'm in this scenario where I don't know what types of data the user will pass in
<FromGitter> <fgimian> Crystal doesn't like converting an empty namedtuple to a hash (fair enough too), but ... what's a pumpkin to do?
<FromGitter> <fgimian> I was looking forward to the static typing, but it does sometimes hurt my brain (e.g. now)
<FromGitter> <fgimian> 🐌
<oprypin> fgimian, i would recommend against doing this conversion and ask the user to just add { } inside the call
<oprypin> if you insist, you can add `def doit(); {} of Symbol => String; end`
<FromGitter> <fgimian> I see what you mean yeah
<oprypin> in addition to `def doit(**data); data.to_h; end`
<FromGitter> <fgimian> gotcha, good point!
<FromGitter> <fgimian> thanks a lot!!!
<FromGitter> <fgimian> I think I'm going to avoid the double splats all together as you said
<FromGitter> <fgimian> and just ask the user to pass a named argument named `data` which is already a hash
<FromGitter> <fgimian> the data argument can have a default value of `[] of Symbol => String`
<FromGitter> <fgimian> think this is the most elegant way to go about it
<FromGitter> <fgimian> overloading doesn't work, because `(**data)` can also be ZERO arguments so the compiler actually uses that and it all gets hairy
<FromGitter> <fgimian> interestingly Python uses a mutable hash for its double splats
<FromGitter> <fgimian> tricky bit now will be that, I will need to set the type of the `data` argument, which is where it gets hard again, since each action calling this method could return anything, strings, nils, bools, arrays of strings .etc
<FromGitter> <fgimian> ok overloading helps me
<FromGitter> <fgimian> πŸ˜„
<FromGitter> <fgimian> that'll do
akaiiro has quit [Ping timeout: 256 seconds]
That_Guy_Anon has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <fgimian> i used macros in the end πŸ˜„
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b24c6bbd128fa71f66e5dff]
<FromGitter> <fgimian> Macros are the answer to everything in life
<oprypin> fgimian, daaamn, how are you so good at macros? ^^
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 264 seconds]
Raimondii is now known as Raimondi
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <fgimian> hahaha, honestly I'm still trying to get my head around em πŸ˜„
<FromGitter> <fgimian> sorry for the late reply, was just having some dinner
<FromGitter> <bendietze_twitter> Are you cheating? πŸ˜› πŸ’ͺ
<FromGitter> <fgimian> hahaha I sure hope so! πŸ˜„
<FromGitter> <codenoid> what
<FromGitter> <codenoid> btw can crystal works with Raspberry hardware ?
<FromGitter> <codenoid> *with ubuntu server os
<FromGitter> <fgimian> I'm pretty certain the guys said it's ARM compatible, Rasberry Pi is ARM-based right?
<FromGitter> <fgimian> I haven't tried it myself tho
<FromGitter> <codenoid> yeah, it's ARM cpu
<FromGitter> <fgimian> This looks like it will help ya: https://github.com/crystal-lang/crystal/issues/4299
<FromGitter> <fgimian> I'm going to ask another silly question, and this will likely be my last for the day
<FromGitter> <fgimian> I'm writing a tool whereby I have a plugin system, and the main runner will run certain plugins depending on what the user requests to do. Now each plugin returns a NamedTuple with a member called `data` that's a Hash of data that relate to the plugin. Of course, this data can be anything, any types, any keys, .etc.
<FromGitter> <fgimian> As the tool runs these plugins, I would like to collect the result from each plugin into an array, but of course, this is where it gets very tricky.
<FromGitter> <fgimian> e.g. something like this
<FromGitter> <fgimian> now as far as I can tell, this is simply not possible in a statically typed language like this
<FromGitter> <fgimian> and I would have to resort to using an approach similar to the YAML or JSON libraries in the stdlib
<FromGitter> <fgimian> are there any other ways that I can deal with this?
<FromGitter> <manveru> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b24e121202c8f71f506817a]
<FromGitter> <manveru> like this maybe?
<FromGitter> <fgimian> oooooooooooooooooooooooooooooooooooo
* FromGitter * fgimian tries it
<FromGitter> <fgimian> The only problem is when you create the array, you still can't say `items = [] of Data`
<FromGitter> <fgimian> but, you did give me a few ideas to try!
<FromGitter> <manveru> yeah, i'm not super good at this yet :)
<FromGitter> <fgimian> me either buddy πŸ˜„
<FromGitter> <fgimian> thanks so much for your help though!
<FromGitter> <fgimian> I started wondering about macros again, but this is a runtime thing so I don't think macros will get me out of this one hehe
<FromGitter> <fgimian> Python is staring at me right now and laughing πŸ˜†
<FromGitter> <manveru> i know the feeling :)
<FromGitter> <fgimian> heheheh πŸ˜„
<FromGitter> <manveru> i made a dashboard server with crystal with many different output types, and had the same issue
<FromGitter> <fgimian> yeah, it's hard when you get used to a dynamc language huh?
<FromGitter> <fgimian> for me the 2 biggest challenges coming from Python were the macros and the static typing
<FromGitter> <fgimian> now I think I have my head around the macros mostly, but the static typing is a bugger
<FromGitter> <fgimian> that's not Crystal's fault of course
<FromGitter> <fgimian> it's my brain's fault
<FromGitter> <fgimian> it is challenging though, esp when you can't determine the data types that you will receive
<FromGitter> <manveru> maybe you could instead use an interface?
<FromGitter> <fgimian> thanks so much, I was just thinking about interfaces in fact, but haven't done them with Crystal
<FromGitter> <fgimian> will check out the page you linked now! πŸ˜„
<FromGitter> <manveru> so instead of storing the data for your plugins, you call a method on them to write their stuff to some destination or so
<FromGitter> <fgimian> actually an idea like that could work
<FromGitter> <fgimian> I was just thinking of another interesting option too, related to using a base class
<FromGitter> <fgimian> let me try that idea first to see if it works and then will try yours too
<FromGitter> <fgimian> our ideas are actually similar
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b24e460c277fb705dd2fbea]
<FromGitter> <fgimian> this works
<FromGitter> <fgimian> I could probably use a struct for it in fact
<FromGitter> <fgimian> but the idea of using inheritance seems to be the trick
<FromGitter> <fgimian> this way you can create your array from the base class / abstract class
<FromGitter> <manveru> seems good :D
<FromGitter> <fgimian> yea! if you find a better way, please let me know
<FromGitter> <fgimian> and I'll do the same
<FromGitter> <fgimian> of course, we can use the `record` macro as a basis and create a macro that makes it easy to define a struct type in one line that indicates the fields and their types
<FromGitter> <fgimian> have you used `record` before?
<FromGitter> <fgimian> it's just a shorthand for creating a struct
<FromGitter> <manveru> no, haven't really seen it yet
<FromGitter> <manveru> gotta head out now... cu man
<FromGitter> <fgimian> take care bud
<FromGitter> <j8r> @codenoid you can compile Crystal statically for ARM64 (I do it for a project).
<FromGitter> <j8r> To do so i use qemu and docker running Alpine Linux
<FromGitter> <j8r> @fgimian please don't use symbols in Hashes :| , why you do this? There are already named tuples that use them.
<FromGitter> <j8r> Can you use only a namedtuple of named tuples etc? This can solver your type issue
<FromGitter> <fgimian> thanks @j8r, unfortunately NamedTuples wouldn't do for my use case as each plugin could return a NamedTuple with diferent fields, and this makes it a pain for the caller to obtain data from the result
<FromGitter> <fgimian> The reason I used symbols was because I found Hashes to work better for my use case and the docs say that NamedTuples are like immutable Hashes with Symbols as their keys
<FromGitter> <fgimian> perhaps the docs need to reflect that Symbols should not be used? Most people coming from Ruby will go straight to them.
<FromGitter> <fgimian> The best solution I've found is using a hierarchy of Data structs, this works perfectly for me and gives me the flexibility I need.
<FromGitter> <fgimian> I'm using a modified version of the `record` macro, I'll share my solution shortly
<FromGitter> <fgimian> so symbols :)
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b24f22b17cfd73e85431c1a]
<FromGitter> <fgimian> output
<FromGitter> <fgimian> ```code paste, see link```
<FromGitter> <fgimian> this is far more elegant than any solution using NamedTuples or Hashes imho
<FromGitter> <fgimian> and it makes it easy to pass this around, because the type can simply be `ActionResponse`, the parent class
<FromGitter> <fgimian> or struct
hightower3 has quit [Ping timeout: 256 seconds]
alex`` has quit [Ping timeout: 255 seconds]
alex`` has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
<FromGitter> <Daggerron> Do you guys have exemple of website source code done with kemal ?
alex`` has joined #crystal-lang
<FromGitter> <codenoid> @Daggerron https://github.com/codenoid/jihantoro.sd
<FromGitter> <Daggerron> Thank you ! @codenoid
That_Guy_Anon has quit [Remote host closed the connection]
jfontan has joined #crystal-lang
jerryskye has joined #crystal-lang
<jerryskye> hello everyone! I've just installed crystal with homebrew and it looks like it depends on llvm version 5, but i tried running a simple crystal program and it works fine with newest llvm version. Is there a reason that the homebrew formula has llvm@5 listed as dependency instead of just llvm?
<jerryskye> pls ping me, thank you 😊
<FromGitter> <S-YOU> Because it does not work with llvm6 or above?
<jerryskye> but I ran crystal with llvm 6 and it worked fine for me. but as I said it was a very simple program, I ran this sample code from https://crystal-lang.org/
<FromGitter> <S-YOU> Fine because it may not really using it, I guess.
<jerryskye> yeah you're right, thanks for your help ;)
<FromGitter> <S-YOU> Also brew is maintained by brew team I guess, not by Crystal developers.
<jerryskye> yes, of course
<FromGitter> <fredski02> is there here working on support for windows?
jerryskye has left #crystal-lang ["The Lounge - https://thelounge.github.io"]
<FromGitter> <bendietze_twitter> @fredski02 we are on a good way :) https://github.com/crystal-lang/crystal/issues/5430
<FromGitter> <kalinon> Anyone know if there are any plans to implement Protobuf/gRPC?
<FromGitter> <S-YOU> Havn't use it myself, but for protobuf, there seems to be one - https://github.com/jeromegn/protobuf.cr
<jeromegn> Yes :)
<FromGitter> <kalinon> Dang i missed that one in my searching. Nice! That + HTTP2 should mean we could get a gRPC lib going
<jeromegn> I think it works well, but I haven’t worked on it in a while!
<FromGitter> <kalinon> Did you build it from bottom up? or bind to the C++ libs?
<FromGitter> <kalinon> Also, good news your benchmarking is even better: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b251f1b1ee2d149ecc75a5d]
<FromGitter> <kalinon> decoding is faster now
<jeromegn> @kalinon: from scratch
<FromGitter> <kalinon> nice thanks for the lib
<jeromegn> Was fun to implement!
<FromGitter> <vladfaust> Just a quick question - does Crystal work on ARM flawlessly?
akaiiro has joined #crystal-lang
greengriminal has joined #crystal-lang
<FromGitter> <j8r> AFAIK yes
<FromGitter> <j8r> But for now you can only compile it statically for ARM64
akaiiro has quit [Ping timeout: 276 seconds]
<FromGitter> <vladfaust> I'm sorry, what limits does this imply? I'm not familiar with "static compilation" concept. Will it work on Scaleway ARM64 cloud?
alex`` has quit [Quit: WeeChat 2.1]
alex`` has joined #crystal-lang
alex`` has quit [Client Quit]
alex`` has joined #crystal-lang
<FromGitter> <vladfaust> I got it, it links to libs
<FromGitter> <vladfaust> That means that it could only be built on the machine itself, right?
<FromGitter> <Daggerron> is there a better way to obtain a hash(key, value) from an sql request than ``` ⏎ arr = {} of String => String ⏎ SQL.query query do |data| ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5b252bb5e87f0c7bee90be1e]
<FromGitter> <Daggerron> Is there a better way to obtain a hash from a SQL request than ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b252c1d32618e705ebfd4d2]
sherjilozair has joined #crystal-lang
<FromGitter> <vladfaust> `arr["title"], arr["content"] = data.read(String, String)` - AFAIK `.read` supports multiple args
<FromGitter> <vladfaust> I'd consider using `struct` or `NamedTuple` for readability
<FromGitter> <drujensen> have you considered a structure or class instead of a hash? Then you could add a constructor that takes the query results and sets the typed values.
<FromGitter> <Daggerron> @drujensen You mean specify the type in the constructor ?
<FromGitter> <Daggerron> @vladfaust Nice tip thx !
sherjilozair has quit [Quit: Leaving...]
pippin has joined #crystal-lang
<FromGitter> <drujensen> that and each property will be typed so you can take advantage of it
<FromGitter> <drujensen> avoid runtime errors
<FromGitter> <eliasjpr> We need to have the `Teeplate ` shard updated ⏎ Specs are failing because `lib/teeplate/src/lib/file_tree/macros/directory.cr:33: undefined method 'stat' for File:Class` ⏎ `::Teeplate::StringData.new("#{rel}", io.to_s, #{File.stat(abs).perm})`
<FromGitter> <eliasjpr> Nvm it has been updated :)
<FromGitter> <GuskiS> Hello. How can I run some yarn command from crystal? Looking into Process module, but can't seem to figure it out(not even sure it is right place to look)
akaiiro has joined #crystal-lang
<FromGitter> <S-YOU> ``yarn``?
<FromGitter> <GuskiS> ?
<FromGitter> <S-YOU> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b253242d128fa71f66f0a90]
<robacarp> this is an unexpected change in Crystal 0.25: https://play.crystal-lang.org/#/r/4b2z
<FromGitter> <GuskiS> @S-YOU :O thanks
TCZ has joined #crystal-lang
<jeromegn> robacarp: looks like a bug
<robacarp> jeromegn: thanks for confirming, I'll make an issue
<FromGitter> <j8r> I there a way to pass a variable by reference without using `pointerof`?
<FromGitter> <j8r> I noticed types of types like `Array(Array(String))` is passed by reference automatically, but not single types `Bool` or `String`
<FromGitter> <S-YOU> .to_unsafe for String, I think.
TCZ has quit [Quit: Leaving]
<FromGitter> <j8r> lol that's worst πŸ˜•
<FromGitter> <S-YOU> sorry, It become different type xD
<RX14> @j8r no
<FromGitter> <j8r> `pointerof` is quite ok, but I was searching the opposite of `.dup`
<FromGitter> <S-YOU> no other I believe
snsei has joined #crystal-lang
akaiiro has quit [Ping timeout: 264 seconds]
Groogy has joined #crystal-lang
faustinoaq has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <vlazar> @bcardiff FYI https://crystal-lang.org/blog/ is missing link to latest post about 0.25 release
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Jenz has joined #crystal-lang
<FromGitter> <j8r> @vlazar no, it's on release notes.
<FromGitter> <vlazar> hmmm, ok, but not very intuitive :)
<Groogy> aaaalright time to try and make Boleite work with 0.25
snsei has joined #crystal-lang
faustinoaq has quit [Read error: Connection reset by peer]
<Groogy> luckily I have a good infrastructure so the YAML changes aren't too breaking
<Groogy> or hmmm something crashes
<Groogy> I'm trying to see if there's an issue reported on it already
<FromGitter> <S-YOU> Does that solve if you clear the cache?
greengriminal has quit [Quit: Leaving]
akaiiro has joined #crystal-lang
<Groogy> how do I clear the cache?
<FromGitter> <bararchy> ```rm -rf .shards/ ⏎ rm -rf .libs/``` [https://gitter.im/crystal-lang/crystal?at=5b254f608864a936cc8db0d2]
<FromGitter> <bararchy> `lib` without s
<FromGitter> <bararchy> for shard cache
<FromGitter> <bararchy> and Crystal have global cache
<FromGitter> <bararchy> at `~/.cache/crystal/`
<FromGitter> <bararchy> you can just remove it
<Groogy> deleted .shards and deleted the cache in home directory, still happening
<Groogy> didn't have a .libs
<Groogy> if I build release it works fine though
<Groogy> is there any other spot I might have forgotten?
<FromGitter> <S-YOU> if --no-debug flag works, I think I saw similar, may be in this chat.
<Groogy> hmmm yeah if all I do is remove the --debug flag
<Groogy> it works perfectly fine
<FromGitter> <S-YOU> ah, --debug flag, it never worked for me xD
akaiiro has quit [Ping timeout: 248 seconds]
wontruefree has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
That_Guy_Anon has joined #crystal-lang
GoldenBear has quit [Ping timeout: 245 seconds]
<FromGitter> <fredski02> Hi Guys, I wanna help contribute to the windows version of Crystal. Not sure where to start though
<FromGitter> <fredski02> any good pointers / guides / recommendations ?
<That_Guy_Anon> probably talk to RX14, since he seems to be one of the people most involved in the windows port.
<FromGitter> <fredski02> Cheers
Jenz has quit [Ping timeout: 240 seconds]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <faustinoaq> Wow, scaleway has very cheap VPSs https://www.scaleway.com/virtual-cloud-servers/#anchor_starter
<FromGitter> <faustinoaq> even cheaper than Vultr https://www.vultr.com/pricing/
ua has joined #crystal-lang
ua_ has quit [Ping timeout: 240 seconds]
akaiiro has joined #crystal-lang
<FromGitter> <fridgerator> nice!
<FromGitter> <j8r> @faustinoaq They are cheap, but they have increased the pricing of the x86-64 VPS to 2.99 to 3.99 for 2GB of RAM, and included one of 1.99 for 1GB
p0p0pr37 has quit [Read error: Connection reset by peer]
p0p0pr37 has joined #crystal-lang
GoldenBear has joined #crystal-lang
<FromGitter> <fridgerator> looks like their only in Amsterdam and France
<FromGitter> <fridgerator> they're*
Groogy has quit [Quit: WeeChat 2.1]
<FromGitter> <HCLarsen> You guys got rid of Time::Kind in 0.25.0?
<FromGitter> <fridgerator> yeah, was replaced with Time::Location I think ?!?
akaiiro has quit [Remote host closed the connection]
wontruefree has quit [Quit: bye]
<FromGitter> <HCLarsen> Yeah, reading the documentation now. I think it's an improvement. I just have to change my ongoing project.
Jenz has joined #crystal-lang
<FromGitter> <eliasjpr> @ysbaddaden when you get a chance there is a couple of PRs open to upgrade https://github.com/ysbaddaden/selenium-webdriver-crystal to crystal v0.25.0
Jenz has quit [Quit: leaving]
<FromGitter> <eliasjpr> I have been thinking of forking, to extend and maintain it with @paulcsmith since we are using this shard heavily to support Capybara like testing for Amber and Lucky frameworks
<FromGitter> <stronny> Hi! Is it okay to subclass Hash? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ The two types seem the same to me, what does crystal complain about? [https://gitter.im/crystal-lang/crystal?at=5b258a19fd5b835b2d6198ae]
<FromGitter> <stronny> `Crystal 0.25.0 [7fb783f7a] (2018-06-11)`
<FromGitter> <eliasjpr> Quick question should `JSON::Type` (Crystal 0.24.1) be replaced with `JSON::Any::Type` (Crystal v0.25.0) for the migration to work smoothly? I have seen a lot of code changes from `JSON::Type` to `JSON::Any` and it kinda does not make sense since `JSON::Any` its is own type
<FromGitter> <stronny> No, it probably wouldn't work, I've hit this
<FromGitter> <eliasjpr> Im not sure if thats the correct way. Is there any guide provided by Crystal team to perform the migration?
<FromGitter> <stronny> I'm afraid you'll have to redesign the relevant part. What are you doing with JSON::Type now?
<FromGitter> <stronny> note that `JSON.parse_raw` is gone as well
<FromGitter> <eliasjpr> Im confused because previously JSON::Type was simply an union, which meant that a method defined as ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2591d26712b704d8d0bf02]
<FromGitter> <eliasjpr> So all you methods needs to pass now an instance of JSON::Any, and not a String, or Nil or etc..
<FromGitter> <stronny> That's why I'm sceptical that a simple migration is possible
<FromGitter> <eliasjpr> From the example above this method call would work `some_method(nil)` since is a valid type in the union
<FromGitter> <stronny> You have choices. You can use JSON::Any and cast to `.raw` as needed, or you can still use the union, just keep in mind that it's a new union now
<FromGitter> <stronny> You can always wrap your `nil` into `JSON::Any.new(nil)` though
<FromGitter> <eliasjpr> Thats what I was thinking I can continue using the union. Now if I parse the JSON upfront I can expect a JSON::Any
<FromGitter> <eliasjpr> So I think the migration should be to support both types
<FromGitter> <eliasjpr> `def some_method(json : JSON::Any | JSON::Any::Type)` for methods define with `def some_method(json : JSON::Type)`
<FromGitter> <eliasjpr> I think that would make things backward compatible
<FromGitter> <stronny> If that's what you want, but I wouldn't do that. I would rather define overloads, not handle unions of `JSON::Any::Type` and `JSON::Any` simultaneously
<FromGitter> <eliasjpr> Β―\_(ツ)_/Β―
<FromGitter> <eliasjpr> Good point @stronny I always forget about overloads
<FromGitter> <stronny> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2593d01ee2d149ecc819c2]
<FromGitter> <eliasjpr> Definitely
<FromGitter> <eliasjpr> πŸ™Œ
<FromGitter> <stronny> or the other way around: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b25940737a2df7bed42a6e6]
<FromGitter> <stronny> still, you have to keep in mind that the backwords compatibility will not be possible, the old union has gone away =)
<FromGitter> <eliasjpr> It looks the same union
<FromGitter> <eliasjpr> whats the Difference
<FromGitter> <eliasjpr> It is just in a different location
<FromGitter> <stronny> it was `Array(JSON::Type)` before, it's `Array(JSON::Any)` now
<FromGitter> <stronny> not `Array(JSON::Any::Type)`
<FromGitter> <eliasjpr> Good catch
<FromGitter> <stronny> that wasn't mine! I was also completely surprised
<FromGitter> <stronny> well, my code exploded
<FromGitter> <stronny> good luck! =)
<FromGitter> <eliasjpr> a lot of shards a bleeding today
<FromGitter> <eliasjpr> An upgrade guide would have been nice, maybe I miss it
<FromGitter> <eliasjpr> Is there any blog out there explaining the changes, I mean I saw the JSON and YAML prs with these changes, but I lost track of them
<FromGitter> <stronny> At least it deserved an explicit mention, definitely
<FromGitter> <eliasjpr> Yes, I guess that sine is not `v1` is β€œfine”
<FromGitter> <stronny> I understand the reasons behind this, so I'm not angry
<FromGitter> <eliasjpr> Mee too
<FromGitter> <stronny> Come to think of it, my new code is probably even better
<FromGitter> <eliasjpr> But I think the method overload and supporting both types is the better way to upgrade. I would like to hear from the team wht they think. @RX14 Whats your take?
<FromGitter> <stronny> It's your choice of course, however since stdlib is already incompatible, I would drop the old api as well
zachk has joined #crystal-lang
zachk has joined #crystal-lang
<FromGitter> <HCLarsen> Wow. Some serious breaking changes in that update.
_whitelogger has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]