ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.30.1 | 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
<FromGitter> <Blacksmoke16> `Example.new.to_json` made an alias method
<FromGitter> <Blacksmoke16> just does `serialize JSON, context` under the hood
<FromGitter> <Blacksmoke16> was thinking it would be cool to have something that would cause a method to use its default value
<FromGitter> <Blacksmoke16> like if the type isnt nilable and has a default value, passing nil would use the default
<FromGitter> <Blacksmoke16> type restriction*
<FromGitter> <watzon> Awesome! Now in Tourmaline instead of having to do ⏎ ⏎ ```def some_command(message, params) ⏎ send_message(message.chat.id, "Hello world") ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d759c65ae44a84124a4d7f5]
<FromGitter> <Blacksmoke16> seems a bit better indeed
<FromGitter> <watzon> Or even ⏎ ⏎ ```def some_command(message, params) ⏎ message.reply("Hello world") ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d759c99767de913fca7c1cd]
<FromGitter> <watzon> Much better
<FromGitter> <watzon> Since with reply you'd normally have to do `send_message(message.chat.id, "Hello world", reply_to_message_id: message.message_id)`
<FromGitter> <Blacksmoke16> oh yea quite a bit less typing
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d759d6254e7c649d4b015bb]
<FromGitter> <Blacksmoke16> figure out how to supply the bot i take it?
<FromGitter> <watzon> Yeah I went with the `BotContainer` idea for now
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <watzon> Also, obligatory "You know nothing, Jon Snow`
<FromGitter> <Blacksmoke16> 😉
<FromGitter> <Blacksmoke16> serializable has `after_initialize`
<FromGitter> <Blacksmoke16> but cant do anything before
<FromGitter> <Blacksmoke16> er sorry, thats for deserialization
<FromGitter> <Blacksmoke16> it was `on_to_json` which happens after everything has already been serialized
<FromGitter> <Blacksmoke16> what other features would be useful...
alex`` has quit [Quit: WeeChat 2.5]
<companion_cube> so, I imagine code is linked into an executable only if it's in a C lib or if it's transitively used, right? Which would mean the stdlib can be big and not bloat executables
<FromGitter> <Blacksmoke16> yea if you dont use a method its not included in the binary
<companion_cube> and if I don't require a module, same, right?
<FromGitter> <Blacksmoke16> prob
<companion_cube> I hope this kind of semantics will be clarified before 1.0 ;-)
<companion_cube> also, static dispatch vs dynamic dispatch
<FromGitter> <Blacksmoke16> dunno
<companion_cube> I mean, if some people are to use it as a replaement for C++… ;)
chemist69 has quit [Ping timeout: 276 seconds]
chemist69 has joined #crystal-lang
ht_ has joined #crystal-lang
hightower3 has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
ht_ has quit [Quit: ht_]
absolutejam1 has joined #crystal-lang
<FromGitter> <watzon> Cool, someone is using my ngrok shard https://github.com/Willamin/quicksand
absolutejam1 has quit [Ping timeout: 244 seconds]
sagax has quit [Read error: Connection reset by peer]
gangstacat has quit [Quit: Ĝis!]
absolutejam1 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 245 seconds]
<FromGitter> <DanilaFe> Hi all! I've got a question about JSON decoding: the API I'm accessing encodes JSON as `{"type": "object type", ... fields specific to type}`. I'm trying to easily ⏎ decode this in my client code - but it seems like JSON.mapping generates code that always asks for an object, and thus I can't use the resulting code (after reading the "type" field, there will be no object before the other fields need to be
<FromGitter> ... read). Is there an easy way to implement a parser for this, or do I have to stay away from JSON.mapping?
absolutejam1 has joined #crystal-lang
sagax has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <yxhuvud> So you need to parse what amounts to a serialized union type? see https://stackoverflow.com/questions/48029005/how-does-json-mapping-macro-work-with-union-types-of-arguments . I'm not certain how to differentiate between variants with compatible attributes though
<FromGitter> <dscottboggs_gitlab> This is a question which has come up before and there are two options, and depending on the source of the data there is probably only one: ⏎ ⏎ 1) A custom overload of `self.new(JSON::PullParser) : self`. Here is an example (https://github.com/dscottboggs/pingas/blob/10000e631f54fbcd3410c52fd1878d43e73838bd/src/notifier.cr#L5-L32) from one of my projects. The disadvantage to this approach is it
<FromGitter> ... always requires the `"type"` or `"kind"` key to be assigned first, so that you can use it to determine which Union member you want to deserialize. ⏎ 2) Use JSON.parse. This incurs a somewhat significant hit to performance. [https://gitter.im/crystal-lang/crystal?at=5d7624ec54e7c649d4b3b176]
absolutejam1 has quit [Ping timeout: 268 seconds]
erdnaxeli has joined #crystal-lang
gangstacat has joined #crystal-lang
absolutejam1 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> im hoping to revisit that again when i get the deserialization side of things,is something that would be *super* useful
absolutejam1 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 245 seconds]
absolutejam1 has joined #crystal-lang
ton31337 has joined #crystal-lang
<FromGitter> <Blacksmoke16> how are you running crystal?
<FromGitter> <Blacksmoke16> built from source? what os?
<ton31337> centos7
<ton31337> from package
<ton31337> 0.30
<ton31337> actually
<ton31337> Crystal 0.30.1 [5e6a1b672] (2019-08-12)
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> id make a forum thread about it, deff shouldnt be doing that
<ton31337> one more interesting
<ton31337> Error: can't find file 'prelude'
<ton31337> ;/
<FromGitter> <Blacksmoke16> yea something is borked
<FromGitter> <Blacksmoke16> maybe with the centos package?
<FromGitter> <Blacksmoke16> i dont know enough about it to say for sure
<ton31337> yeah, reinstalled
<ton31337> all good
<ton31337> ;/
<FromGitter> <Blacksmoke16> :shrug:
lkw has quit [Quit: ZNC 1.7.3 - https://znc.in]
absolutejam1 has quit [Ping timeout: 245 seconds]
absolutejam1 has joined #crystal-lang
<FromGitter> <jwoertink> if I want to override the enum `to_s`, do I get access to the specific enum through `{{@type}}`?
<FromGitter> <Blacksmoke16> i.e the current enum member?
<FromGitter> <jwoertink> yeah
<FromGitter> <Blacksmoke16> it would just be `self`
<FromGitter> <jwoertink> oh..
<FromGitter> <jwoertink> hahah
<FromGitter> <jwoertink> duh
<FromGitter> <Blacksmoke16> :p
<FromGitter> <jwoertink> need more coffee!
<FromGitter> <jwoertink> 😂
lkw has joined #crystal-lang
<FromGitter> <jwoertink> ok, actually, it's not working how I figured
<FromGitter> <Blacksmoke16> oh?
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7660add5c7bd579460ef17]
<FromGitter> <jwoertink> how do I get "Bar boo"?
<FromGitter> <Blacksmoke16> `Foo::Bar.to_s`?
<FromGitter> <Blacksmoke16> ah
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d766131ae44a84124a9f502]
<FromGitter> <jwoertink> ah, gotcha
<FromGitter> <Blacksmoke16> using self in the string makes it call `.to_s` to convert it to a string
<FromGitter> <Blacksmoke16> but ends up in a infinite loop
<FromGitter> <jwoertink> yeah, that's what I was running in to
<FromGitter> <Blacksmoke16> so in this case we just want to call the parent `to_s` to convert the member to its string form, then handle our logic
<FromGitter> <jwoertink> makes sense
<FromGitter> <jwoertink> I'm running in to an error that I'm kind of confused on
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d766856ae44a84124aa2aa5]
<FromGitter> <jwoertink> in this case, `Direction` is an enum
<FromGitter> <jwoertink> doing this example compiles though
<FromGitter> <jwoertink> as it should
<FromGitter> <jwoertink> anyone see something I'm missing?
<FromGitter> <asterite> `direction` is a Symbol? Converting from Symbol to Enum only works for symbol literals
<FromGitter> <asterite> like, if it's `OrderBy.new(:foo, :bar)`
skryking has joined #crystal-lang
<FromGitter> <jwoertink> oh right
<FromGitter> <jwoertink> Yeah, I'm passing a symbol literal in to the top method, but that passes it down
<FromGitter> <asterite> I think you could fix it by specifying those restrictions in that top method
<FromGitter> <asterite> I'm still not entirely convinced about Symbol literal -> Enum conversion
<FromGitter> <jwoertink> It's handy and clean, but does lead to a little confusion here and there
<FromGitter> <jwoertink> ok, cool, thanks. Easy fix 😄
<FromGitter> <jwoertink> yeah, in this case, it's like
<FromGitter> <jwoertink> ```def order_by(col, dir) ⏎ OrderBy.new(col, dir) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d766a54d5c7bd57946136ec]
<FromGitter> <Blacksmoke16> symbols should just be removed and reserved for enum conversion
<FromGitter> <Blacksmoke16> considering (AFAIK) they dont provide any benefit over strings?
<FromGitter> <jwoertink> would that mean NamedTuple would go away?
<FromGitter> <jwoertink> or are those not technically Symbol?
<FromGitter> <Blacksmoke16> can still use strings as NT keys
<FromGitter> <Blacksmoke16> but yea, their keys are inherently symbols atm
<companion_cube> why are symbols bad‽
<FromGitter> <Blacksmoke16> im not saying they're bad, just that they dont provide any benefit over a string (AFAIK)
<companion_cube> well, perfect sharing, and they're an int at runtime, I think
<companion_cube> much faster than a string
<companion_cube> ie symbol comparison is super cheap
ton31337 has quit [Quit: leaving]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d766c00c5939027203eaae2]
<FromGitter> <Blacksmoke16> :shrug:
<companion_cube> could be an interned string too, that's a really tiny microbenchmark..
<companion_cube> what if you sort them?
<FromGitter> <j8r> Enum are usually better
<FromGitter> <j8r> because they are type-safe
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d766ca82f93ab5a1532974b]
<companion_cube> what I'm curious about is, did anyone consider full algebraic datatypes?
<FromGitter> <Blacksmoke16> essentially the same
<companion_cube> maybe crystal is good at interning string constants…
<FromGitter> <Blacksmoke16> but yea, most of the time a symbol could be an enum
<FromGitter> <j8r> But what is your use case?
<FromGitter> <Blacksmoke16> which at that point the only thing a symbol would be used for is namedTuple keys and auto casting enums
<FromGitter> <Blacksmoke16> crystal already has enums tho?
<companion_cube> not enums as in rust/haskell/…
<companion_cube> ie proper sum types
<FromGitter> <Blacksmoke16> im not familiar with those, got an example?
<companion_cube> it's relatively close to unions, I think, but with some interesting distinctions
<companion_cube> unions of structs*
<companion_cube> in particular `case` would warn if some cases are forgotten
<FromGitter> <Blacksmoke16> isn that essentially the same thing as like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d766e9a50508949d304cb07]
<companion_cube> and there's typically syntax to bind members in each case
<companion_cube> yeah but you don't get the exhaustiveness check in case (or do you?)
ht_ has joined #crystal-lang
<companion_cube> scala does this, but you can have a "sealed" class to get exhaustiveness
absolutejam1 has quit [Ping timeout: 244 seconds]
<FromGitter> <Blacksmoke16> no but is an RFC for that https://github.com/crystal-lang/crystal/issues/8001
<FromGitter> <j8r> And if we put this types in a module?
<companion_cube> yeah cool
<companion_cube> I think sealed abstract struct would do it
<FromGitter> <Blacksmoke16> had an idea for my assertion lib. I think it would be easy to support using the assertions outside of a property/annotation context
<FromGitter> <Blacksmoke16> i.e.
<FromGitter> <Blacksmoke16> ```... ⏎ Assert.not_blank value ⏎ ...``` [https://gitter.im/crystal-lang/crystal?at=5d76731f50508949d304eec0]
<FromGitter> <Blacksmoke16> which would raise an exception if it fails
absolutejam1 has joined #crystal-lang
<FromGitter> <wontruefree> I was reading through this issue (https://github.com/crystal-lang/crystal/issues/4613) and it seems like markdown is overkill for docs
<FromGitter> <wontruefree> it is just used because people are use to it?
<companion_cube> generally speaking, if I write code in 0.30, is it going to be broken a lot by 1.0? or relatively minor changes only?
<companion_cube> wontruefree: what else would you write docs with?
absolutejam1 has quit [Ping timeout: 244 seconds]
<FromGitter> <Blacksmoke16> broken, most likely yes
<FromGitter> <Blacksmoke16> by how much depends on what gets changed
<FromGitter> <Blacksmoke16> kinda hard to say, maybe look at the breaking changes past few releases and go from there?
<companion_cube> :s
teardown has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> i can say lately its mostly been smaller stuff
teardown has joined #crystal-lang
<companion_cube> nice.
<FromGitter> <Blacksmoke16> be sure you compile/run specs with warnings
<FromGitter> <Blacksmoke16> can give you a heads up if something will be changing in a later version so you can fix it
<companion_cube> like, deprecation warnings?
<FromGitter> <Blacksmoke16> yea
<FromGitter> <Blacksmoke16> i usually lump them in with my specs, so it'll fail CI if there are warnings
<FromGitter> <Blacksmoke16> `crystal spec --warnings all --error-on-warnings`
<FromGitter> <paulcsmith> @asterite I'm with you on the Symbol -> Enum. I like it when it works, but when it doesn't it can be confusing. Lots of edge cases, especially for newcomers.
<FromGitter> <paulcsmith> Or if you mistype a symbol it tells you that it expects an Enum and not a Symbol (would expect it to give a "Did you mean" or hint that you need a different Symbol) but that's kind of the problem with passing a Symbol in place of some other object. Can be a bit tricky
absolutejam1 has joined #crystal-lang
<FromGitter> <kingsleyh> hey - what does this mean when I compile my Crystal program: `Program received and didn't handle signal ILL (4)`
<FromGitter> <kingsleyh> I'm not doing any kind of spawn or anything like that
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Signal.html think it means this kind of signal
Human_G33k has joined #crystal-lang
<FromGitter> <Blacksmoke16> i.e. something is giving the `ILL` signal but crystal doesnt know how to handle it
<FromGitter> <kingsleyh> wow no idea what could be causing that
HumanG33k has quit [Ping timeout: 258 seconds]
absolutejam1 has quit [Ping timeout: 245 seconds]
<FromGitter> <kingsleyh> figured it out - I was raising in a method but not returning a string from it
<FromGitter> <kingsleyh> it was being used in a proc - so I guess that was causing the issue
<FromGitter> <Blacksmoke16> gotcha
alex`` has quit [Ping timeout: 244 seconds]
alex`` has joined #crystal-lang
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
alex``` has joined #crystal-lang
alex`` has quit [Ping timeout: 268 seconds]
alex``` has quit [Ping timeout: 246 seconds]
alex``` has joined #crystal-lang
alex```` has joined #crystal-lang
alex``` has quit [Ping timeout: 244 seconds]
absolutejam1 has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
alex`` has joined #crystal-lang
alex```` has quit [Ping timeout: 244 seconds]
<companion_cube> any chance that using a shebang for one-file scripts, could cache the binary, so it's fast to (re-)run?
<FromGitter> <Blacksmoke16> while devving?
absolutejam1 has quit [Ping timeout: 244 seconds]
absolutejam2 has joined #crystal-lang
<companion_cube> well, so I can just have the script, and run it without compiling explicitely
<companion_cube> (same as python's .pyc files)
<FromGitter> <Blacksmoke16> why not just compile it and use the binary?
<FromGitter> <Blacksmoke16> other than that you would have to do `crystal my_file.cr` every tiem
<companion_cube> not with a shebang
<companion_cube> #!/usr/bin/env crystal
<FromGitter> <Blacksmoke16> does that work?
<companion_cube> yep, I tried
<companion_cube> it's quite nice
<FromGitter> <Blacksmoke16> neat
<companion_cube> but there's a delay because it recompiles every time
<FromGitter> <Blacksmoke16> any reason to not just build it and add it into your path?
<companion_cube> convenience, if it's for small scripts. anyway.
<companion_cube> I'm still exploring the boundaries :p
<FromGitter> <Blacksmoke16> pretty sure it caches binaries
<FromGitter> <Blacksmoke16> but imo just build it, only have to do it once
<FromGitter> <bew> no it doesn't, https://github.com/Val/crun does though :)
alex`` has quit [Quit: WeeChat 2.5]
<companion_cube> interesting
alex`` has joined #crystal-lang
alex``` has joined #crystal-lang
<FromGitter> <Blacksmoke16> neat
alex`` has quit [Ping timeout: 268 seconds]
<FromGitter> <bew> yeah I use it for a few "scripts", I don't really like the implementation (use of constants to read ARGV for example) but overall it works well, so I don't want to rewrite everything for now :P
<FromGitter> <Blacksmoke16> still dont really see the benefit of like `crystal build --release script.cr -o ~/bin/script`
<FromGitter> <Blacksmoke16> vs*
<companion_cube> I'd rather put a small script into git, than a binary
<companion_cube> (the kind of custom script in my dotfiles, I mean)
<FromGitter> <bew> no separate step? / install step
<FromGitter> <Blacksmoke16> but the source into git and build it on pull
<FromGitter> <Blacksmoke16> put*
<companion_cube> how is that more convenient than a shebang? :)
<FromGitter> <Blacksmoke16> binary would still work if there is breaking change since its not dependent on the current version you have installed
<companion_cube> otoh if you modify the script you have to recompile explicitely
<FromGitter> <Blacksmoke16> right, would be assumed you use the binary once the script is done, if you edit it just rebuild it
<companion_cube> the shebang version is convenient if you use crystal as a replacement to python/ruby, imho
<companion_cube> for small cli utils
<FromGitter> <Blacksmoke16> if that floats your boat
<FromGitter> <bew> yes for cli utils, with almost no possible breaking change (or easily fixed) easier to use than having that separate build/install step
alex``` has quit [Quit: WeeChat 2.5]
ht_ has quit [Quit: ht_]
absolutejam3 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 246 seconds]
<FromGitter> <DanilaFe> @dscottboggs_gitlab A custom overload of `self.new(JSON::PullParser) : self` sounds like the right idea; in fact, isn't that what `JSON.mapping` does? ⏎ The `type` field does always come first; once I read it, I will need the exact same code as `JSON.mapping` generates with the exception of the object parsing. Maybe this can be abstracted from the `JSON.mapping` macro by splitting it into two macros?
skryking has quit [Quit: WeeChat 2.4]
<FromGitter> <wontruefree> @compainion_cube I guess I dont know
<FromGitter> <wontruefree> I am sure there are some issues on github were people have discused it
<FromGitter> <wontruefree> I like the minimalist doc formats
<FromGitter> <wontruefree> but that would be more work to design and stuff
<companion_cube> markdown is reasonable minimalistic imho, and a lot of people know it
<companion_cube> (cmark, hopefully, not old ugly unspecified markdown)
absolutejam3 has quit [Ping timeout: 245 seconds]
<FromGitter> <DanilaFe> wait, can Crystal macros only have 1 level of nesting? a macro can't invoke another macro?
<FromGitter> <Daniel-Worrall> Nested Macros?
<FromGitter> <DanilaFe> yeah, that's that I'm asking about
<FromGitter> <DanilaFe> I was musing about breaking up `JSON.mapping` into reusable chunks, but if Crystal doesn't have nested macros...
<FromGitter> <DanilaFe> that could be used
<FromGitter> <DanilaFe> actually that's not even necessary
absolutejam3 has joined #crystal-lang
<FromGitter> <Blacksmoke16> `{% verbatim do %}`
<FromGitter> <Blacksmoke16> macros within that you dont have to do the `\{%` thing
jhass has quit [Ping timeout: 264 seconds]
asterite_ has joined #crystal-lang
asterite has quit [Ping timeout: 252 seconds]
asterite_ is now known as asterite
DeBot has quit [Ping timeout: 252 seconds]
jhass has joined #crystal-lang
<FromGitter> <DanilaFe> Oh, sweet! Though I think I'm over complicating it. In principle, can't there be an "object" parameter to the `mapping` macro that serves as a switch? If it's of, no read_begin_object? This would make implementing discriminated JSON unions pretty nice
<FromGitter> <DanilaFe> Off*
absolutejam3 has quit [Ping timeout: 244 seconds]
<FromGitter> <DanilaFe> Because hypothetically, you could then dispatch to an `.new` method generated by the `mapping` macro depending on the first json field you read
asterite has quit [Ping timeout: 245 seconds]
DeBot has joined #crystal-lang
asterite has joined #crystal-lang
jhass has quit [Ping timeout: 276 seconds]
jhass has joined #crystal-lang
<FromGitter> <Blacksmoke16> i been thinking about this today
<FromGitter> <Blacksmoke16> and came up with an idea
<FromGitter> <Blacksmoke16> but let me see if it works first :S give me a while
<FromGitter> <watzon> I've never learned what the `\%{` thing is with macros
<FromGitter> <Blacksmoke16> it prevents the macro from executing if the macro is in another macro
<FromGitter> <Blacksmoke16> i.e. macro included etc
<FromGitter> <watzon> Ahhh interesting
<FromGitter> <DanilaFe> @Blacksmoke16 great! I'd be interested in what you come up with. Discriminated unions are very common in this API
<FromGitter> <Blacksmoke16> alright so, \cc @dscottboggs_gitlab will want in on this too
<FromGitter> <Blacksmoke16> we've been thinking about this wrong i think
<FromGitter> <Blacksmoke16> the main issue is you cant know what type to deserialize into until you're done serializing the data right?
<FromGitter> <Blacksmoke16> deserializing*
<FromGitter> <DanilaFe> until you're at least halfway through. In my case, the `type` key is first, but it's still too late
<FromGitter> <Blacksmoke16> exactly, SO i remembered girng's thread about `JSON.parse` vs `.from_json`
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d76d9d52f93ab5a1535c51a]
<FromGitter> <Blacksmoke16> is the tl;dr
<FromGitter> <Blacksmoke16> essentially just as fast
<FromGitter> <Blacksmoke16> so now if you let `JSON.parse` do the serialization, then new up your class based on the resulting `JSON::Any` you can do it
<FromGitter> <Blacksmoke16> via something like https://play.crystal-lang.org/#/r/7j9d
<FromGitter> <Blacksmoke16> very contrived example to show off the idea/concept
<FromGitter> <DanilaFe> assuming you have `type` at the beginning, won't this work without JSON::Any?
<FromGitter> <DanilaFe> you could just as well call `new` depending on what you pull
<FromGitter> <Blacksmoke16> sure but relying on property order is not good enough in the real world
<FromGitter> <DanilaFe> (just thinking about my more specific case)
<FromGitter> <DanilaFe> that's true
<FromGitter> <Blacksmoke16> for a shard or the stdlib to implement
<FromGitter> <DanilaFe> of course
<FromGitter> <DanilaFe> I'm not familiar with annotations. what's happening there?
<FromGitter> <Blacksmoke16> im defining the mapping of partner name to the clas
<FromGitter> <Blacksmoke16> and the name of the key it should read from the json
<FromGitter> <Blacksmoke16> uses that to build out the case statement for determining which child it should new up
<FromGitter> <DanilaFe> neat
<FromGitter> <Blacksmoke16> imma play with this more then compare it to the current `from_json` and see how big the diff is
<FromGitter> <DanilaFe> awesome! thank you :)
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d76dc1c2f93ab5a1535d440]
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <DanilaFe> that 1% performance hit is too much. into the trash it goes! /s
<FromGitter> <Blacksmoke16> ill have to run that again when its more complete
<FromGitter> <Blacksmoke16> prob going to go this route for my serializer shard
<FromGitter> <Blacksmoke16> got arrays working