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> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d76e78450508949d308390e]
<FromGitter> <bew> good job, really nice what you're doing with that!
<FromGitter> <Blacksmoke16> yea should be pretty click
<FromGitter> <Blacksmoke16> slick*
<FromGitter> <Blacksmoke16> But first I need to finish up the serialization side of things
<FromGitter> <watzon> It would be really nice if `from_json` allowed you to include a key that contained the json object you want to parse.
<FromGitter> <bew> what's missing?
<FromGitter> <Blacksmoke16> @watzon it does
<FromGitter> <watzon> Does it? With `JSON::Serializable`?
<FromGitter> <watzon> Or with yours?
<FromGitter> <Blacksmoke16> both
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7jae
<FromGitter> <watzon> I know you can do `@[JSON::Field(key: "some_key")]`
<FromGitter> <Blacksmoke16> but can only go one level deep
<FromGitter> <watzon> Oh nifty
<FromGitter> <watzon> I didn't know that existed
<FromGitter> <Blacksmoke16> i could prob do something with `#dig` and an annotation
<FromGitter> <Blacksmoke16> since the whole thing is parsed
<FromGitter> <Blacksmoke16> like `@[CRS::Path("data", "some_key", "value")]`
<FromGitter> <watzon> That would be cool
<FromGitter> <Blacksmoke16> also going to steal https://serde.rs/field-attrs.html#alias :P
<FromGitter> <Blacksmoke16> would help (i think it was @DanilaFe) who's data has multiple keys for the same thing
<FromGitter> <watzon> You know what else would be kind of nice? The ability to use a Regex as a key. Sometimes APIs are shitty and do stuff like `"page1": {...}, "page2": {...}"` and it becomes difficult to deserialize.
<FromGitter> <Blacksmoke16> Hmm
<FromGitter> <Blacksmoke16> That would probably be a good situation for a converter
<FromGitter> <watzon> Yeah possibly
<FromGitter> <Blacksmoke16> I'll keep you posted, probably a little ways out on this side of things
<FromGitter> <Daniel-Worrall> Weird, in crystal play I can use `URI.parse`, but if I add `HTTP::Params.parse` below it, it says URI is an undefined constant.
<FromGitter> <watzon> That is weird. Be sure to always `require "uri"` if you're planning on using it though. Just a good practice.
<FromGitter> <Daniel-Worrall> Yup
<FromGitter> <bew> Hey guys, I think I've found a weird bug, I need confirmation: https://carc.in/#/r/7jaq the two typeof should give the same things, no? Might be related to the auto deconstruction of block args in some cases? (might only be too tired to process the output.....)
<FromGitter> <bew> no nevermind
<FromGitter> <bew> will need to find a better example... I have a nasty bug somewhere in these lines but I can't get a smaller exemple yet..
<FromGitter> <Blacksmoke16> 😬
<FromGitter> <bew> my symptom is that I have a `some_call do |*args| ... end` and `args` ends up with a `String` type instead of a `Tuple(String, String)`
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> wouldnt the `*` splat the tuple and since there is only one block arg make that the value?
<FromGitter> <Blacksmoke16> just a guess
<FromGitter> <bew> I thought about that, but I hope not... it would be pretty counter intuitive imo
<FromGitter> <bew> and no, I tested that here some time ago https://carc.in/#/r/7jan
<FromGitter> <Daniel-Worrall> the twitch lib is coming along nicely
jokke has joined #crystal-lang
<FromGitter> <Qard> Is there a way to make something generic over a not only a *type* but also a *count* when trying to create a class that wraps a set-size array from `Pointer(T).malloc(count)`? I want to be able to *inherit* from this generic type, specifying the size it should be.
<FromGitter> <Blacksmoke16> you can pass a number as a generic
<FromGitter> <Blacksmoke16> `MyType(MyClas, 5)`
<FromGitter> <Qard> Oh, that works? I thought it could only be classes.
<FromGitter> <Blacksmoke16> it does indeed
<FromGitter> <Blacksmoke16> (only for numbers tho)
<FromGitter> <Blacksmoke16> you cant pass strings or bools etc
<FromGitter> <Qard> Ah, well numbers are the only thing I need, so works for me. :)
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <bew> ok I think I recreated my error: https://carc.in/#/r/7jb0
<FromGitter> <bew> can someone confirm that there is a bug? or tell me if you understand something?
<FromGitter> <bew> note: the fact that `SomeCollection` and `ProxyModule` are modules instead of classes is intentional, I can't change that
chachasmooth has quit [Ping timeout: 250 seconds]
chachasmooth has joined #crystal-lang
<FromGitter> <bew> Updated with some notes: https://carc.in/#/r/7jb7
<FromGitter> <bew> will make an issue on GH
<FromGitter> <bew> looks like I've hit https://github.com/crystal-lang/crystal/issues/6473
<FromGitter> <bew> ftr, reduced it to https://carc.in/#/r/7jb8
<FromGitter> <Blacksmoke16> thats good at least
chemist69 has quit [Ping timeout: 250 seconds]
chemist69 has joined #crystal-lang
ht_ has joined #crystal-lang
ht_ has quit [Quit: ht_]
ht_ has joined #crystal-lang
ht_ has quit [Client Quit]
ht_ has joined #crystal-lang
_whitelogger has joined #crystal-lang
absolutejam3 has joined #crystal-lang
absolutejam3 has quit [Ping timeout: 276 seconds]
absolutejam3 has joined #crystal-lang
_whitelogger has joined #crystal-lang
chemist69 has quit [Ping timeout: 246 seconds]
absolutejam3 has quit [Ping timeout: 246 seconds]
absolutejam3 has joined #crystal-lang
chemist69 has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <raymanoz> Hi. I was using crystal `0.30.1`, installed via `crenv`
<FromGitter> <raymanoz> but when I did a `shards build --release`, I got this error:
<FromGitter> <raymanoz> ```Assertion failed: (cast<DISubprogram>(Scope)->describes(&MF->getFunction())), function getOrCreateRegularScope, file /var/cache/omnibus/src/llvm/llvm-6.0.1.src/lib/CodeGen/LexicalScopes.cpp, line 176.```
<FromGitter> <raymanoz> The cause of it seemed to be that the crenv version of crystal was using an old version of LLVM (`6.0.1` instead of `8.0.1`)
<FromGitter> <raymanoz> I changed to using the brew install'd version of crystal and it fixed this problem
<FromGitter> <raymanoz> is this a problem with `crenv` ?
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 258 seconds]
<FromGitter> <asterite> most probably
hightower2 has joined #crystal-lang
<FromGitter> <bcardiff> @raymanoz crenv might be using the github .tar.gz that stil uses 6.0.1
<FromGitter> <bew> for unions or virtual methods, what do crystal do internally: dynamic dispatch or static dispatch?
<FromGitter> <bew> especially for virtuals, is it like c++ with a vtable? or is there is dumb if elsif elsif else ?
hightower2 has quit [Ping timeout: 244 seconds]
MasterdonX has quit [Ping timeout: 245 seconds]
MasterdonX has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
<FromGitter> <asterite> dumb if elseif elsif else
<FromGitter> <asterite> no vtables anywhere
absolutejam3 has quit [Ping timeout: 276 seconds]
ht_ has quit [Quit: ht_]
ht_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Has anyone written a way to parse out a Link Header?
<FromGitter> <Daniel-Worrall> example return `<https://api.twitch.tv/helix/webhooks/hub>; rel="hub", <https://api.twitch.tv/helix/users/follows?first=1&from_id=1337>; rel="self"`
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <Daniel-Worrall> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d77d2c26e889c4bbdd185b2]
<FromGitter> <Daniel-Worrall> Any feedback appreciated
<FromGitter> <Blacksmoke16> i think you could use https://crystal-lang.org/api/master/Enumerable.html#each_with_object(obj,&block)-instance-method
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d77d3d654e7c649d4bff233]
<FromGitter> <watzon> This regex should work as well to get all parts you need `/<(\S+)>;\s+rel="(\S+)"/`
<FromGitter> <Daniel-Worrall> Thanks boios
<FromGitter> <Blacksmoke16> actually sec
<FromGitter> <Daniel-Worrall> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d77d537b9abfa4bd38472b6]
<FromGitter> <Blacksmoke16> looks there isnt a global regex option
<FromGitter> <Blacksmoke16> oh wait
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d77d631460a6f5a16fcd74a]
<FromGitter> <Blacksmoke16> :P
<FromGitter> <watzon> Nice 😁
<FromGitter> <Daniel-Worrall> Benchmarking em
<FromGitter> <Daniel-Worrall> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d77d6de32e48c5df26fc86e]
<FromGitter> <Daniel-Worrall> ofc, tested them to make sure they give the same results
rohitpaulk has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
HumanGeek has joined #crystal-lang
HumanGeek has quit [Remote host closed the connection]
HumanGeek has joined #crystal-lang
Groogy has quit [Read error: Connection reset by peer]
Human_G33k has quit [Ping timeout: 244 seconds]
<FromGitter> <Daniel-Worrall> How can I see what a file looks like once macros have run
<FromGitter> <Daniel-Worrall> Okay, `crystal tool expand` but I don't know how it works :^)
<FromGitter> <Blacksmoke16> its like `crystal tool expand -c ./src/my_file.cr ./src/my_file.cr:10:15`
<FromGitter> <Blacksmoke16> line/col number might go on the other file, i dont remember
<FromGitter> <Daniel-Worrall> I'm just getting `no expansion found` so idk
<FromGitter> <Blacksmoke16> have to put it at the first char of the macro
<FromGitter> <Daniel-Worrall> What about inline macros
<FromGitter> <Blacksmoke16> same thing
<FromGitter> <Blacksmoke16> oh
<FromGitter> <Blacksmoke16> could also do like `{{debug}}`
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Crystal/Macros.html#debug(format=true):Nop-instance-method
<FromGitter> <Daniel-Worrall> I'm surprised I can't just expand the file
<FromGitter> <Blacksmoke16> like if you have all your macro code in a `{% begin %} {% end %}` can add that before the last end
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <zbaylin> Is there a way to have a non-fixed length array as an argument in C function bindings? For example, I'm trying to write bindings for libxlsxwriter's `worksheet_write_rich_string`, but I can't find a way to say the length can vary in the `fun` declaration
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <j8r> Pretty sure you can't
<FromGitter> <j8r> That's the purpose of StaticArray
<companion_cube> if it's C bindings, you probably have to pass pointer + length anyway, right?
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <zbaylin> hmm okay. then can someone guide me as to how to translate this into crystal bindings? https://libxlsxwriter.github.io/worksheet_8h.html#a62bf44845ce9dcc505bf228999db5afa
absolutejam3 has joined #crystal-lang
absolutejam4 has joined #crystal-lang
absolutejam3 has quit [Ping timeout: 276 seconds]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 246 seconds]
<FromGitter> <kingsleyh> evening - if anyone would like to help out on my blockchain project: https://sushichain.io please message me. Looking for all and any help. In particular I have a few small programming tasks which could be quite fun which I need doing but don't have any time or money. So it would be for the πŸ’Œ
<FromGitter> <Blacksmoke16> is there a way to override an alias within your specs?
<companion_cube> aren't blockchains on the decline these days?
<FromGitter> <wontruefree> what is the new tech hotness?
<FromGitter> <kingsleyh> depends where you look :)
<companion_cube> crystal, hopefully?
<FromGitter> <kingsleyh> blockchains are still around
<FromGitter> <Blacksmoke16> nvm, took a diff approach
<FromGitter> <watzon> @kingsleyh any progress on the Crystal plugin for Idea?
<FromGitter> <wontruefree> what is the crystal plugin idea?
<FromGitter> <wontruefree> interesting
<FromGitter> <watzon> Doesn't look like there has been any progress since the last time I checked haha
<FromGitter> <absolutejam_gitlab> I'm hedging my bets on Scry
<FromGitter> <Blacksmoke16> *java*
<FromGitter> <absolutejam_gitlab> I want LSPs to be the future, but even the biggest languages don't seem to have flawless LSPs
<FromGitter> <wontruefree> is there work happening on scry
<FromGitter> <watzon> @absolutejam_gitlab I wouldn't haha. It hasn't had much good progress either.
<FromGitter> <watzon> Idk what the plan is for it
<FromGitter> <wontruefree> looks like yes https://github.com/crystal-lang-tools/scry
<FromGitter> <absolutejam_gitlab> I just want something that'll work with my editor haha
<FromGitter> <Blacksmoke16> anyone use it with sublime?
<FromGitter> <wontruefree> I used it with VSCode and now I use it with Vim
<FromGitter> <watzon> They fix some bugs every now and then, but the things marked WIP have been like that for as long as I've been watching the project
<FromGitter> <wontruefree> I prefer VSCode and recommend that to people
<FromGitter> <watzon> I do too
<FromGitter> <watzon> Especially now that I'm back on Windows for now. WSL integration is actually great now.
<FromGitter> <Blacksmoke16> boo windows
<companion_cube> typescript has a very good LSP plugin
<companion_cube> hopefully crystal can get that too
<FromGitter> <watzon> Yeah I hope
<FromGitter> <watzon> We're missing out on a lot right now
<FromGitter> <wontruefree> I did a migration to windows last year and thought it was way better then it was
<FromGitter> <wontruefree> but I am on OSX now
<FromGitter> <absolutejam_gitlab> I was big on VSCode but now I'm too deep using Kakoune and the keyboard-centric workflow
<FromGitter> <absolutejam_gitlab> I just need to train myself to rely on stuff like fzf more
<FromGitter> <absolutejam_gitlab> I like the LSP route because it's editor agnostic
<FromGitter> <absolutejam_gitlab> they all have an LSP client now
<FromGitter> <absolutejam_gitlab> and the protocol handles some good stuff, it just has to be implemented πŸ˜†
<FromGitter> <watzon> Yeah it's nice
<FromGitter> <absolutejam_gitlab> what's everyone using as web language/framework these days?
<FromGitter> <absolutejam_gitlab> not asking for advice, just curious what you're using and why
<FromGitter> <watzon> I like to try out new things. I think my favorite right now is still Vue, but I like Svelte a lot.
<FromGitter> <absolutejam_gitlab> not heard of svelte
<FromGitter> <Blacksmoke16> angular, but only if you're building a bigger app
<FromGitter> <Blacksmoke16> would be overkill for a like one page or so type thing
<FromGitter> <watzon> Svelte is super lightweight and pretty vue-like
<FromGitter> <watzon> It's missing some things though
<FromGitter> <wontruefree> I liked vue but I am at a job right now where we have a mix of react and pure javascript
<FromGitter> <watzon> Eww react
<FromGitter> <watzon> Never been a fan
<FromGitter> <rmarronnier> Any reason why NamedTuple has such a small size limit : `Error: named tuple size cannot be greater than 300 (size is 412)` ?
<FromGitter> <watzon> That is a good question. I've never hit that before.
<FromGitter> <Blacksmoke16> any reason why you need to have a named tuple that big?
<FromGitter> <rmarronnier> I its keys are Symbols (Int32), there should be no problem
<FromGitter> <Blacksmoke16> using a struct would prob be better no?
<FromGitter> <rmarronnier> Its a conversion table for language iso codes
<FromGitter> <watzon> Hash shouldn't have that limit
<FromGitter> <watzon> You could still have Symbol keys
ht_ has quit [Remote host closed the connection]
<FromGitter> <rmarronnier> I wanted to use NamedTuple for performance reasons and consistency (I want languages codes to be symbols)
<FromGitter> <watzon> Idk why NamedTuple has that (seemingly) arbitrary limit though
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <Blacksmoke16> prob a good use case for a NT
<FromGitter> <Blacksmoke16> maybe make an issue for it?
<FromGitter> <rmarronnier> NT ?
<FromGitter> <watzon> Makes sense. Just go ahead and set it up as a Hash with Symbol keys for now.
<FromGitter> <Blacksmoke16> namedtuple, sorry i got lazy
<FromGitter> <Blacksmoke16> :p
<FromGitter> <rmarronnier> hehe :-) np
<FromGitter> <watzon> @asterite might know the reason for the 300 limit
<FromGitter> <watzon> Or maybe @bew
<companion_cube> well, why would you have a record of 300 fields? :D
<companion_cube> seems like code generation
<FromGitter> <rmarronnier> I hope so, I didn't find anything in the API ;-)
<FromGitter> <rmarronnier> Thanks @Blacksmoke16 ! Good catch
<FromGitter> <watzon> Hmm seems like a temporary patch. Maybe some better optimizing could be done somewhere so that error occurs? Idk haha.
<FromGitter> <watzon> I guess we have our answer though
<FromGitter> <rmarronnier> Compilers are quite magical creatures tome, why would the size crash it? :-D
<FromGitter> <Blacksmoke16> random guess, namedTuples are in stack memory which is a limited size?
<FromGitter> <watzon> Probably
<FromGitter> <rmarronnier> Thanks for the pointer @Blacksmoke16 , now I'm reading about stack vs heap memory. I'll make good dreams tonight :-p
<companion_cube> I think it's more a termination issue when specializing
<companion_cube> specialization + recursion are a tricky mix
<FromGitter> <watzon> That's a fun rabbit bole to go down haha
<FromGitter> <rmarronnier> Yeah, I always thought I shouldn't have to care about these kind of things because the compiler would optimize everything. I am so naive :-p
<FromGitter> <wontruefree> as Mike Acton would say a compiler is a tool not a magic wand
<FromGitter> <wontruefree> basically a compiler can only work in the spaces it was designed for
<FromGitter> <wontruefree> he is a little harsh but right
<companion_cube> there's lots of stuff for reusing buffers and arrays in the stdlib, once you want to optimize
<companion_cube> and even printers all take `IO`, so you can use `IO::Memory` instead of concatenating lots of strings
<FromGitter> <rmarronnier> Thanks Jack for the link.
<FromGitter> <rmarronnier> In a few months maybe I'll be ready to go low level but for now, I just want to be at ease with the Crystal syntax.
<FromGitter> <Daniel-Worrall> Someone should make an Event Handler shard
<FromGitter> <Blacksmoke16> is https://github.com/onyxframework/eda but idk anything about it
<FromGitter> <Daniel-Worrall> Ooh
gangstacat has quit [Quit: Ĝis!]
absolutejam4 has quit [Ping timeout: 246 seconds]
<FromGitter> <bew> @zbaylin still need help with your lib binding?
absolutejam4 has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 246 seconds]
coderobe has quit [Read error: Connection reset by peer]
ukd1 has joined #crystal-lang
<ukd1> does anyone know how to detect if a client has disconnected from a server mid-request? I'm doing a long-lived request, and wanna abort if they do.
<FromGitter> <Blacksmoke16> Can you set a timeout
sorcus has quit [Ping timeout: 250 seconds]
alex`` has quit [Ping timeout: 268 seconds]
alex`` has joined #crystal-lang