ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.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> back to the configuration discussion i started a few days ago
<FromGitter> <Blacksmoke16> how annoying would it be to have to include a yaml file along with a binary
<FromGitter> <Blacksmoke16> trying to think of a nice in code configuration method and im coming up blank...
ur5us has joined #crystal-lang
<FromGitter> <randiaz95> Guys, who wants to work on front end stuff while working with crystal as back end: ⏎ ⏎ https://gitter.im/DartProgramming/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link
<FromGitter> <randiaz95> Dart Programming lang!!
<FromGitter> <Blacksmoke16> :thinking:
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 248 seconds]
yukai has joined #crystal-lang
<FromGitter> <thetrung> so ppl mostly use Crystal for Amber ?
<FromGitter> <randiaz95> For shizzzle
<FromGitter> <Blacksmoke16> amber/lucky/kemal are popular choices if building a webapp but deff arent the only things crystal can do
<FromGitter> <randiaz95> Crystal is good for fast probability computation because of simple data structure apis and methods like permutations
<FromGitter> <randiaz95> Crystal also has the best syntax for the runtime performance
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter> <kinxer> I can't give any specifics, but the company I work for uses Crystal for non-web applications that require heavy computation and network communication.
<FromGitter> <kinxer> So it's definitely not only for web stuff.
DTZUZO has quit [Read error: Connection reset by peer]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <thetrung> ya
<FromGitter> <thetrung> want to ask him about where the game engine on Crystal may go..
<FromGitter> <thetrung> remind me so much of chingu/ruby
<FromGitter> <thetrung> a fun time that I had before
<FromGitter> <thetrung> @kinxer that's really fun to take advantage of new stuff in company
<FromGitter> <thetrung> @Blacksmoke16 ya, mostly, web stuff
<FromGitter> <yorci> @kinxer +1
<FromGitter> <randiaz95> I got a bug on the demo project for that game engine
<FromGitter> <randiaz95> :(
<FromGitter> <thetrung> hey me too
<FromGitter> <thetrung> ```run -s -p examples/demo/main.cr```
<FromGitter> <thetrung> then
<FromGitter> <thetrung> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e00428b84c21677094bd3a9]
<FromGitter> <thetrung> i submitted the issue ```https://github.com/tfcat/Leafgem/issues/28```
<FromGitter> <randiaz95> thanks Nguyen!
<FromGitter> <randiaz95> same error as me
<FromGitter> <thetrung> you use chingu/gem before ?
<FromGitter> <randiaz95> idk wut that is
<FromGitter> <randiaz95> I know gem install
<FromGitter> <thetrung> it's pretty similar to this Leafgem
<FromGitter> <thetrung> but on Ruby
<FromGitter> <thetrung> :P
<FromGitter> <randiaz95> lol
<FromGitter> <thetrung> There's another solution that I see more viable, it's Love2D
<FromGitter> <thetrung> have you tried `crsfml` @randiaz95
DTZUZO has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
DTZUZO has quit [Ping timeout: 258 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <randiaz95> nope :(
<FromGitter> <randiaz95> guys.. what the heck is this? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e005d30b1701e50ca6f9225]
<FromGitter> <randiaz95> lol
<FromGitter> <randiaz95> I read that
<FromGitter> <randiaz95> all I got there was: `return and break can't be used inside a captured block. next can be used and will exit and give the value of the captured block.`
<FromGitter> <wontruefree> is there an upsert for lucky?
<FromGitter> <grkek> Hello
yukai has quit [Ping timeout: 260 seconds]
ht_ has joined #crystal-lang
ht_ has quit [Quit: ht_]
return0__ has joined #crystal-lang
<FromGitter> <grkek> @Blacksmoke16 I finally got it to work, it has the same capabilities as the dsl of the kemal framework had but it gets the path from the route() macro, I also updated the readme it is really nice, I love crystal
return0e has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
DTZUZO has quit [Ping timeout: 260 seconds]
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> nice one
<FromGitter> <grkek> Thank you ! <3
<FromGitter> <Blacksmoke16> i also slept on my yaml config idea and realized i can just include the string content at compile time, but not process it until you run it so that it can handle picking up env vars etc
<FromGitter> <grkek> sleep makes everything better
<FromGitter> <Daniel-Worrall> Yes storing defaults in the app and then overriding with an optional config file is a common good practice
<FromGitter> <kingsleyh> Does anyone know why on JSON::Any there is no `as_u64` or any other as_u for that matter - but when using JSON.mapping you can set a field as UInt64 and it works fine? And also if you JSON.parse(json)["value"].as_s.to_u64 - although it seems fine - when you come to use it it throws a cast exception - so the only way to do it is to use the JSON.mapping way?
<FromGitter> <Daniel-Worrall> What does it give with as_i?
vitalyster has joined #crystal-lang
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <j8r> @kingsleyh Because JSON spec doesn't have unsigned ints
<FromGitter> <j8r> as @Daniel-Worrall said, you can use `as_i.to_u64`
<FromGitter> <kingsleyh> Yes works with as_i thanks
<FromGitter> <kingsleyh> Is that how Json mapping does it under the hood?
DTZUZO has quit [Ping timeout: 260 seconds]
duane has quit [Ping timeout: 260 seconds]
vitalyster has left #crystal-lang [#crystal-lang]
HumanGeek has joined #crystal-lang
HumanGeek has quit [Remote host closed the connection]
HumanGeek has joined #crystal-lang
duane has joined #crystal-lang
Human_G33k has quit [Ping timeout: 258 seconds]
return0__ has quit [Ping timeout: 268 seconds]
f1reflyylmao has quit [Quit: bye fags]
f1refly has joined #crystal-lang
return0e has joined #crystal-lang
edr has joined #crystal-lang
Flipez has quit [Read error: Connection reset by peer]
Flipez3 has joined #crystal-lang
Flipez3 is now known as Flipez
duane has quit [Ping timeout: 260 seconds]
<FromGitter> <j8r> Wow, I have a very nasty bug with `JSON::Serializable`
duane has joined #crystal-lang
<FromGitter> <j8r> On one hand, I am happy that's not my code and it is working with `JSON.mapping`. ⏎ On the other hand, hard to isolate
<FromGitter> <j8r> forget, still occurring 💀
<FromGitter> <tenebrousedge> can you isolate it and put it in a play for us?
<FromGitter> <j8r> i really wish I could
<FromGitter> <j8r> trying to do it
<FromGitter> <j8r> does `forall U` known to be buggy? ⏎ I have a method `def parse_response(klass : U.class, response) : Success(U) | Error forall U`
<FromGitter> <tenebrousedge> I think I've heard something to that effect
<FromGitter> <tenebrousedge> but I couldn't be sure
<FromGitter> <j8r> me too, I know generics are kinda limited
<FromGitter> <j8r> for example better avoiding abstract classes with generics with macros
<FromGitter> <j8r> I make it compiling by replacing a type to `JSON::Any`, definitely a JSON issue. ⏎ I have to look to the macro
<FromGitter> <j8r> hooooo
<FromGitter> <j8r> found it
<FromGitter> <j8r> if you put a type as `Nil`, but it is not - this will return an invalid memory access
<FromGitter> <tenebrousedge> that does sound like a bug
<FromGitter> <j8r> Yes, I am trying to reproducing it
<FromGitter> <grkek> I get segfaults sometimes when I code spaghetti as well lmao
duane has quit [Ping timeout: 240 seconds]
<FromGitter> <tenebrousedge> mmmm, spaghetti 😄
<FromGitter> <Blacksmoke16> i had that last night
<FromGitter> <Blacksmoke16> 🍝
<FromGitter> <j8r> I am able to reproduce it, and that's even no spaghetti :)
<FromGitter> <Blacksmoke16> @Daniel-Worrall ☝️ December 23, 2019 7:36 AM (https://gitter.im/crystal-lang/crystal?at=5e00b4bec5a23938b46abdca) thats the plan. have a parent struct that controls the sections, with other structs defining the options for a specific feature. this way defaults/documentation can be added, otherwise it would fail when going to do the `from_yaml`
<FromGitter> <Blacksmoke16> can also read in the yaml when building the binary so it doesn't actually have to be present to run. I.e. `read_file` macro then process the dynamic content at runtime when the binary starts so that env vars will be set correctly etc
<FromGitter> <grkek> mmmm, grip framework which handles lots of requests/s
<FromGitter> <grkek> https://github.com/grkek/grip
<FromGitter> <grkek> shilling time
<FromGitter> <j8r> Oh, that's because of `getter class : String`
<FromGitter> <j8r> https://carc.in/#/r/89cb
<FromGitter> <j8r> Further reduced https://carc.in/#/r/89ce
DTZUZO has joined #crystal-lang
<FromGitter> <jwoertink> Anyone see what I'm missing here? https://play.crystal-lang.org/#/r/89ch
<FromGitter> <jwoertink> I don't understand the error message
<FromGitter> <grkek> code maybe ?
<FromGitter> <grkek> oh there it is
<FromGitter> <Blacksmoke16> i think you have to use `next` to skip the block
<FromGitter> <Blacksmoke16> since you're using separate if statements
<FromGitter> <tenebrousedge> but why not? https://play.crystal-lang.org/#/r/89cl
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/89ck
<FromGitter> <Blacksmoke16> @tenebrousedge would be the better option
<FromGitter> <jwoertink> I'm not using the spaceship operator
<FromGitter> <jwoertink> ah, ok next is what I need
<FromGitter> <jwoertink> thanks
<FromGitter> <tenebrousedge> not using it because?
<FromGitter> <jwoertink> My actual code is a lot more complicated than that example
<FromGitter> <tenebrousedge> k
<FromGitter> <jwoertink> I was just making sure sort worked the way I expected it to
<FromGitter> <jwoertink> and then it didn't
<FromGitter> <Blacksmoke16> comparing objects?
<FromGitter> <jwoertink> yeah
<FromGitter> <Blacksmoke16> could always define `<=>` and include https://crystal-lang.org/api/master/Comparable.html
<FromGitter> <jwoertink> actually... comparing type declarations in a macro
<FromGitter> <jwoertink> lol
<FromGitter> <Blacksmoke16> ah fair enough
<FromGitter> <Blacksmoke16> then yea that wont work
<FromGitter> <firejox> with..yield statement
<FromGitter> <grkek> u guys better checc out my friggin repo
<FromGitter> <grkek> > :(
<FromGitter> <grkek> > :(
<FromGitter> <grkek> I wanted to create an angry face but the markdown ruins it all :(
<FromGitter> <tenebrousedge> use \
<FromGitter> <Blacksmoke16> 😠
<FromGitter> <Blacksmoke16> `😠`
<FromGitter> <tenebrousedge> \>:(
<FromGitter> <Blacksmoke16> thats a good one as well
<FromGitter> <grkek> :angery:
<FromGitter> <grkek> :spooky:
<FromGitter> <grkek> :aaaaaaaaaaa:
<FromGitter> <grkek> :oOOoOOooOOO: :booga booga booga:
<FromGitter> <j8r> never seen this ones
<FromGitter> <grkek> use imagination
<FromGitter> <grkek> thx
<FromGitter> <grkek> legend says that you can see them if you check out my repo
<FromGitter> <tenebrousedge> 😠 👻 😱
<FromGitter> <grkek> bruh its like check out my soundcloud
<FromGitter> <grkek> but now its repo
<FromGitter> <grkek> is 9.7k requests/s good ?
<FromGitter> <Blacksmoke16> single threaded?
<FromGitter> <grkek> yeah
<FromGitter> <Blacksmoke16> ehh, bit on the low end
<FromGitter> <grkek> so it is horrible ?
<FromGitter> <Blacksmoke16> not horrible, but not the fastest either
<FromGitter> <grkek> How much does yours bench
<FromGitter> <grkek> probably a 50k
<FromGitter> <grkek> or more
<FromGitter> <grkek> what a beast
<FromGitter> <tenebrousedge> once upon a time, web servers had a "c10k" competition
<FromGitter> <grkek> W8 let me try the same thing with kemal
<Yxhuvud> Now it is more like c1M.
<Yxhuvud> or even greater.
<FromGitter> <grkek> I hate internet
<Yxhuvud> I should continue on my bindings for liburing.
<FromGitter> <Blacksmoke16> ☝️ December 13, 2019 10:44 PM (https://gitter.im/crystal-lang/crystal?at=5df45a9555d9392300091379) got it up to 340k. granted this is with 6 worker threads, so ~56k single threaded?
<FromGitter> <Blacksmoke16> granted i have a good pc and there wasnt really anything going on in the route, just returns `"Hello world"` so i wouldnt call it official numbers ha
<FromGitter> <grkek> Damn that is strong as hell
<FromGitter> <grkek> I still havent figured how can I run workers with kemal
<FromGitter> <grkek> do you have some ideas about that ?
<FromGitter> <Blacksmoke16> each request is handled in its own fiber
<FromGitter> <Blacksmoke16> so you should just be able to enable MT mode and set the workers you want, defaults to 4
<FromGitter> <grkek> is there a cli command for that for the crystal compiler ?
<FromGitter> <Blacksmoke16> `crystal build -Dpreview_mt my_app.cr`
<FromGitter> <Blacksmoke16> oh, did you use the `--release` flag @grkek ?
<FromGitter> <Blacksmoke16> when testing your thing
<FromGitter> <grkek> yup
<FromGitter> <Blacksmoke16> 👍 cool
<FromGitter> <grkek> it increases a ton
<FromGitter> <grkek> at least I can be proud that it shtomped the django speeds
<FromGitter> <grkek> interesting default kemal seems to be achieving the same speed
<FromGitter> <grkek> @Blacksmoke16 after compiling it with multi threading how do you specify workers ? using an env variable ?
<FromGitter> <Blacksmoke16> yea `CRYSTAL_WORKERS`
<FromGitter> <Blacksmoke16> defaults to 5
<FromGitter> <Blacksmoke16> 4*
<FromGitter> <grkek> okay let me add some adjustments to my code
olbat[m] has quit [Quit: killed]
erdnaxeli has quit [Quit: killed]
ternarysolo has quit [Quit: killed]
beepdog has quit [Quit: killed]
<FromGitter> <grkek> It somehow got worse speeds now lol
<FromGitter> <Blacksmoke16> is possible, extra workers is extra overhead
<FromGitter> <grkek> Interesting
<FromGitter> <j8r> if you want to scale a lot more, make it stateless
<FromGitter> <j8r> then spawn a lot of them around
<FromGitter> <j8r> on multiple hosts
<FromGitter> <grkek> the more workers I use the worse it gets
<FromGitter> <Blacksmoke16> unless you have the computer that can handle more workers, that makes sense
<FromGitter> <kinxer> How many cores does your processor have?
<FromGitter> <grkek> 4 i think
<FromGitter> <grkek> or 8
<FromGitter> <grkek> 4
<FromGitter> <grkek> yeah
<FromGitter> <Blacksmoke16> prob dont want to run more than 4 then
<FromGitter> <grkek> that is interesting
<FromGitter> <Blacksmoke16> usually you want 1 worker per cpu core
<FromGitter> <kinxer> Does the scheduler use its own process?
<FromGitter> <grkek> I can use the reuse port feature of kemal to run multiple instances hehe
<FromGitter> <Blacksmoke16> that is also an option, but i would imagine the overhead of separate processes would be more than MT mode?
<FromGitter> <grkek> 11176
<FromGitter> <grkek> yay performance increase
<FromGitter> <grkek> 4 processes
<FromGitter> <kinxer> Er, in its own thread, I meant.
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <grkek> 2 processes
<FromGitter> <grkek> still 11k
<FromGitter> <grkek> interesting
<FromGitter> <Blacksmoke16> what does kemal proper get?
<FromGitter> <grkek> same probably
<FromGitter> <grkek> let me test
<FromGitter> <jwoertink> So I have this code where there's a macro method that takes a type declaration then shoves that in to an array. I want to sort that array where the nillable type declarations are at the end
<FromGitter> <jwoertink> but it fails to compile
<FromGitter> <grkek> seems like both perform the same
<FromGitter> <Blacksmoke16> oo i remember running into this
<FromGitter> <grkek> 11k on both
<FromGitter> <grkek> well I must say its about same as crystal but more of an object oriented approach
<FromGitter> <grkek> kemal*
<FromGitter> <Blacksmoke16> @jwoertink i remember this but i cant remember what i did :/
<FromGitter> <grkek> @Blacksmoke16 does your framework support unix sockets ?
<FromGitter> <jwoertink> ah. no worries. I'll keep hammering away
return0e has quit [Read error: Connection reset by peer]
<FromGitter> <jwoertink> I know I can break them out in to 2 separate arrays using `reject` and `select`, but the code got super verbose real quick. Maybe that's the best way though?
return0e has joined #crystal-lang
<FromGitter> <Blacksmoke16> oo nvm i figured it out
<FromGitter> <Blacksmoke16> `ASSIGNS.sort_by { |dec| dec.type.resolve.nilable? ? 1 : 0 }`
<FromGitter> <Blacksmoke16> try that
<FromGitter> <Blacksmoke16> @grkek dunno tbh
<FromGitter> <grkek> Mine does, ayyyy
<FromGitter> <Blacksmoke16> cant say i ever tried
<FromGitter> <grkek> using unix sockets I think you can bind it to nginx
<FromGitter> <grkek> that is really nice
<FromGitter> <jwoertink> oh shit! That worked 😂
<FromGitter> <jwoertink> and SO much cleaner
<FromGitter> <Blacksmoke16> actually no, currently it only allows binding `tcp` and `tls`
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <jwoertink> thanks!
<FromGitter> <Blacksmoke16> np
<FromGitter> <grkek> really ?
<FromGitter> <grkek> I thought it allowed binding unix sockets as well
<FromGitter> <Blacksmoke16> would be doable in that allow `host` to be a `Socket::UNIXAddress`
<FromGitter> <Blacksmoke16> and if its a socket, call `bind_unix` otherwise do the current logic
<FromGitter> <grkek> That would be a nice addition to your framework
<FromGitter> <grkek> I wonder how much requests can nginx bench
<FromGitter> <grkek> via the distributor
<FromGitter> <grkek> probably same
<FromGitter> <Blacksmoke16> ideally you would have these frameworks behind nginx
<FromGitter> <Blacksmoke16> or something similar
<FromGitter> <grkek> varnish and nginx
<FromGitter> <Blacksmoke16> and yea probably, ill wait for it to be requested tho
<FromGitter> <Blacksmoke16> goal is to keep things simple and iterate as needed, otherwise my brain hurts trying to solve all problems up front
<FromGitter> <grkek> the less complicated it is the better
<FromGitter> <Blacksmoke16> indee
<FromGitter> <grkek> Can you show me an example of your code >?
<FromGitter> <grkek> an example of
<FromGitter> <grkek> a handler
<FromGitter> <grkek> in athena
<FromGitter> <Blacksmoke16> handler for what?
<FromGitter> <grkek> like an api
<FromGitter> <grkek> https://github.com/grkek/grip
<FromGitter> <grkek> like the one in the readme
<FromGitter> <Blacksmoke16> sure sec
<FromGitter> <Blacksmoke16> rendering as HTML is still TBD, currently the rewrite only handles JSON
<FromGitter> <Blacksmoke16> so leaving out the document class, it would be something like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e0108d349314a1d45ca1f46]
<FromGitter> <grkek> So nice and lovely
<FromGitter> <grkek> I like the way you handle the route included information
<FromGitter> <Blacksmoke16> thanks :)
<FromGitter> <Blacksmoke16> the method return value just gets invoked with `.to_json` atm
<FromGitter> <grkek> how do you get json variables
<FromGitter> <grkek> same here
<FromGitter> <grkek> but in a different way
<FromGitter> <grkek> using a render function
<FromGitter> <Blacksmoke16> like `id` from `"/:id"`?
<FromGitter> <grkek> no like a post
<FromGitter> <grkek> json body
<FromGitter> <Blacksmoke16> ah, two ways
<FromGitter> <Blacksmoke16> if you want access to the raw request body you can do like
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ where you just type an argument as `HTTP::Request` [https://gitter.im/crystal-lang/crystal?at=5e0109a044e1fb33f6176db1]
<FromGitter> <grkek> also how do you return status codes >?
<FromGitter> <grkek> oh that is nice
<FromGitter> <Blacksmoke16> the other, more preferable option are param converters
<FromGitter> <Groogy> Yo! Long time no see o/
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e010a2cd2dadb389367fd7f]
<FromGitter> <Blacksmoke16> er `RequestBody` converter
<FromGitter> <grkek> Hello @Groogy
<FromGitter> <grkek> > also how do you return status codes >?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e010a703e3f133894e5e689]
<FromGitter> <grkek> where is the status code tho ?
<FromGitter> <Blacksmoke16> where the content is `.from_json`'d into an objt
<FromGitter> <Blacksmoke16> thats still a TODO :p
<FromGitter> <grkek> yeah I understood that it would go to json
<FromGitter> <grkek> oh my
<FromGitter> <grkek> well
<FromGitter> <grkek> you lost my friend
<FromGitter> <grkek> I am a winner
<FromGitter> <grkek> :p
<FromGitter> <grkek> hehe
erdnaxeli has joined #crystal-lang
beepdog has joined #crystal-lang
ternarysolo has joined #crystal-lang
olbat[m] has joined #crystal-lang
<FromGitter> <Blacksmoke16> havent thought of how i want to handle it yet
<FromGitter> <grkek> "content", 200
<FromGitter> <grkek> "content", 500
<FromGitter> <Blacksmoke16> naw i dont like that
<FromGitter> <grkek> damn
<FromGitter> <grkek> how are you going to handle it then
<FromGitter> <grkek> you would have to return it with the content right ?
<FromGitter> <Blacksmoke16> i have error codes working
<FromGitter> <grkek> in the right context for it to be relevant and not just some random number
<FromGitter> <Blacksmoke16> just not the ability to say, 201
<FromGitter> <grkek> "WHOAH I CREATED SOMETHING", 201
<FromGitter> <grkek> why does that look bad for you ?
<FromGitter> <grkek> or you could make an enum
<FromGitter> <grkek> "Hi", ART::StatusCodes::Created
<FromGitter> <Blacksmoke16> would be one option
<FromGitter> <grkek> but which is better
<FromGitter> <grkek> > "Hi", ART::StatusCodes::Created ⏎ ⏎ or ⏎ ⏎ > "Hi", 201 [https://gitter.im/crystal-lang/crystal?at=5e010c32e0131f50c993f0dd]
<FromGitter> <grkek> both could be an option
<FromGitter> <Blacksmoke16> well fwiw, id use enum symbol autocasting and do `"Hi", :created`
<FromGitter> <grkek> cuz it is an enum ?
<FromGitter> <grkek> that might be one as well
<FromGitter> <grkek> do it like
<FromGitter> <grkek> elixir
<FromGitter> <grkek> :ok, "Muh content"
<FromGitter> <grkek> :created, "ohoy"
<FromGitter> <grkek> :not_found, "sowwy"
<FromGitter> <Blacksmoke16> i still up in the air, however i think im missing a layer
<FromGitter> <Blacksmoke16> is*
<FromGitter> <grkek> do you have a response object as well ?
<FromGitter> <Blacksmoke16> no thats the part that im still debating
<FromGitter> <Blacksmoke16> in that like the response is supplied via the `HTTP::Server::Context`
<FromGitter> <Blacksmoke16> so one option would be like have my own `Response` object that can be returned that gets returned directly, otherwise have a view layer to handle the conversion of the return value into a `Response`
<FromGitter> <grkek> kemal is using HTTP::Server::Context directly so I went with it
<FromGitter> <grkek> comfy af
<FromGitter> <mattrberry> Hey! Sorry for interrupting, not sure if there's a way to have threaded conversation on gitter... ⏎ ⏎ Is there a way to create a macro that would automatically define a constructor for all properties on a class? I'd like all classes inheriting from a Parent class to have their constructors automatically defined. I was looking at the the `inherited` macro hook, but I'm a little confused at the minute. I
<FromGitter> ... figured that with ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5e010dcac62fdf33f7406033]
<FromGitter> <Blacksmoke16> `@type.instance_vars` only works in context of a method
<FromGitter> <grkek> rip
<FromGitter> <mattrberry> Is there a way to do what I'm looking for? Could I maybe define a catch-all `initialize` method that could then parse out the values given to it inside the of the constructor?
<FromGitter> <Blacksmoke16> @grkek sorry if i didnt make it clear before, but when im saying "doesnt support x yet" im talking about the rewrite of athena
<FromGitter> <Blacksmoke16> its possible in the latest release, just not in master/my WIP branch
<FromGitter> <Blacksmoke16> @mattrberry got a better example of what you're trying to achieve? just to save yourself from having to manually add an initializer?
<FromGitter> <grkek> that is a whole new level of programming
<FromGitter> <grkek> fuck initializers who need those
<FromGitter> <grkek> fuck it lets take it out of crystal
<FromGitter> <Blacksmoke16> you would make a macro that makes defining them easier, but otherwise you're out of luck
<FromGitter> <Blacksmoke16> could*
<FromGitter> <tenebrousedge> I feel like this should be possible <___<
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/7504 dont we all
<FromGitter> <tenebrousedge> but I suspect that the answer to this is "use a struct instead"
<FromGitter> <Groogy> I finally have time to look over my old libraries to make sure they are up to date to the latestest versions and now I have mentions on awesome-crystal and I don't understand at all what they are talking about
<FromGitter> <Blacksmoke16> you just need to setup periodic CI builds (assuming your project is testable, if not i can add it to the exempt list)
<FromGitter> <Groogy> Ah I don't do specs really but think I might have done some for the memory profiler
<FromGitter> <Groogy> Boleite I have not written specs for though since I use contract programming instead
<FromGitter> <Blacksmoke16> awesome-crystal is going thru some cleanup atm removing shards that dont have CI setup
<FromGitter> <Blacksmoke16> the goal being to ensure all the shards compile and work as intended
<FromGitter> <Groogy> Alright so Boleite and Trashman is sort of real hard to write specs for so I haven't put in the time to do that
<FromGitter> <Groogy> but I could probably set it up for crystal-clear but right now it does not have that
<FromGitter> <Blacksmoke16> doesn't *have* to be specs
<FromGitter> <Blacksmoke16> an example program to ensure it still compiles would be fine
<FromGitter> <Groogy> Hmm will see what I can do over my vacation
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Groogy> Boleite will be up to date to the latest version at least
<FromGitter> <Groogy> I am fixing all of the // problems
<FromGitter> <mattrberry> Essentially, I'd just like to not have to define a constructor, ==, hash, or a handful of other methods in each class, since the classes are primarly used as dataclasses. I'm coming from a project that used Python's dataclasses extensively, and I'd like to do something similar here. I've found lbarasti/dataclass (https://github.com/lbarasti/dataclass), but I don't love the syntax. @Blacksmoke16 do you think
<FromGitter> ... it's possible to do something similar with just a @[dataclass] annotation on a class?
<FromGitter> <mattrberry> If it's possible, I'll just hack around until I get it to work / get familiar with the Crystal macro system
<FromGitter> <Blacksmoke16> its not anything personal, see my response there and the rest of the thread for the reasoning
<FromGitter> <Groogy> Yeah I get it Blacksmoke don't worry
<FromGitter> <Blacksmoke16> ❤️
sagax has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> @mattrberry im assuming you cant use inheritance or something?
<FromGitter> <Groogy> I have like 3 jobs at same time at work right now otherwise I'd devoted more time to keeping track of crystals development
<FromGitter> <Blacksmoke16> or a module that defines the common logic that can be included into each type
<FromGitter> <Blacksmoke16> no worries bud
<FromGitter> <Groogy> So now I am "relaxing" by coding some crystal :D
<FromGitter> <Groogy> Drinking Spanish wine on my sisters balcony and being glad I don't have to deal with the Swedish misery of a winter
<FromGitter> <grkek> @Blacksmoke16 damn you evil
<FromGitter> <grkek> you be like
<FromGitter> <grkek> lets clap these bunch of repos
<FromGitter> <grkek> for no reason
<FromGitter> <Groogy> Oh dear god, so many warnings after getting things to compile
<FromGitter> <Blacksmoke16> :S
<FromGitter> <Groogy> is it now required to have a return type all the time?
<FromGitter> <Groogy> @grkek nah I get it
<FromGitter> <Blacksmoke16> for abstract defs, the children must have the same/stricter type set
<FromGitter> <Groogy> keeping a clean list for people to look over to find things that actually work and is maintained is important
<FromGitter> <grkek> yeah but its a bit rude to the creators
<FromGitter> <grkek> creating something which makes you happy being clapped is kinda sad
<FromGitter> <Groogy> Well if they don't want to put in the effort they can just opt out
<FromGitter> <mattrberry> @Blacksmoke16 Right, the fields different for each class
<FromGitter> <Blacksmoke16> > Well if they don't want to put in the effort they can just opt out ⏎ ⏎ this
<FromGitter> <Groogy> I was just overwhelemd by how much have changed since I last touched my code base
<FromGitter> <Groogy> luckily it seems memory profiler and the contract testing works as it should though
duane has joined #crystal-lang
<FromGitter> <Blacksmoke16> nice one, if to start you just want to write like 1 spec to cover the happy path, that would be a good start
<FromGitter> <dscottboggs_gitlab> I tend to notice mistakes a lot in that phase even on other paths
<FromGitter> <Blacksmoke16> @mattrberry i suppose you could define your own macro like `record`
<FromGitter> <Blacksmoke16> that creates what you want
<FromGitter> <Blacksmoke16> similar to that dataclass shard
<FromGitter> <tenebrousedge> I think `record` is the answer here
<FromGitter> <Blacksmoke16> afk a bit, drivin home
<FromGitter> <grkek> Go for it mate
<FromGitter> <dscottboggs_gitlab> yeah @mattrberry , I don't think an annotation will help you here -- annotations don't work at all like they do in python here
<FromGitter> <dscottboggs_gitlab> you could write a module that has your macros in it and then `include` it. like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e011338c5a23938b46d7446]
<FromGitter> <dscottboggs_gitlab> either that or just like ⏎ ⏎ ```dataclass Data ⏎ property data : Type ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e0113548dfce538b5f8a353]
sagax has joined #crystal-lang
<FromGitter> <Groogy> So what's the best way to write like a property these days?
<FromGitter> <dscottboggs_gitlab> the property macro?
<FromGitter> <Groogy> property backend = Boleite::BackendConfiguration.new
<FromGitter> <Groogy> would that remove the warning?
<FromGitter> <dscottboggs_gitlab> yes, like that
<FromGitter> <Groogy> nice thx
<FromGitter> <dscottboggs_gitlab> which warning is that?
<FromGitter> <mattrberry> Yeah i'm basically looking for the functionality of lbarasti/dataclass (https://github.com/lbarasti/dataclass) but with syntax closer to what you just shared @dscottboggs_gitlab! Do you think both of those are achievable? I'm still just trying to figure out how the crystal macro system works, so if those are things that *should* be achievable then I'll try to figure out how to do that!
<FromGitter> <dscottboggs_gitlab> sorry spoke too soon @Groogy I didn't see you had a warning
<FromGitter> <Groogy> The warning about that you should have explicit return types
<FromGitter> <Groogy> I'm trying to update my frameworks to fit the latest version of crystal
<FromGitter> <Groogy> What's the "prettiest" way to do this now?
<FromGitter> <dscottboggs_gitlab> Hm, I still seem to be a version behind, so I'm not getting that error, but adding ` : Typename` is the way to add a type restriction to a property
<FromGitter> <dscottboggs_gitlab> like `property backend : Boleite::BackendConfiguration`
<FromGitter> <Groogy> I know but that would make it end up being `property backend : Boleite::BackendConfiguration = Boleite::BackendConfiguration.new`
<FromGitter> <Groogy> and I am wondering if there's a prettier way to do this
duane has quit [Ping timeout: 258 seconds]
<FromGitter> <Groogy> It's this warning: ```Please add an explicit return type (Bool or a subtype of it) to this method as well. ⏎ ⏎ The above warning will become an error in a future Crystal version.```
<FromGitter> <tenebrousedge> you can usually do `property backend : BackendConfiguration = BackendConfiguration.new`
<FromGitter> <dscottboggs_gitlab> that's what he's trying *not* to do
<FromGitter> <Groogy> Well trying not to do is a bit strong, just wondering if there's a prettier way to do it
duane has joined #crystal-lang
<FromGitter> <Groogy> I could have the assignment on the next line for clarity
<FromGitter> <tenebrousedge> @dscottboggs_gitlab I'm saying you can omit the namespace
<FromGitter> <dscottboggs_gitlab> ah
<FromGitter> <grkek> @Groogy Your website is broken
<FromGitter> <tenebrousedge> another option is to pass the default in the initializer
<FromGitter> <grkek> http://groogy.se/mainsite/
<FromGitter> <Groogy> groogy.se? Yes I know
<FromGitter> <grkek> it has php erros
<FromGitter> <grkek> errors*
<FromGitter> <Groogy> I used that when I was a student and looking for a job :P
<FromGitter> <grkek> is it in wordpress
<FromGitter> <grkek> probably
<FromGitter> <Groogy> not much point to maintain it
<FromGitter> <Groogy> yeh
<FromGitter> <dscottboggs_gitlab> @mattrberry, yep, I'm looking over the code for that shard now and it looks like it would be pretty trivial to create something based off of that which uses nested macros to build out the methods from the `@type` macro value inside the generated class.
<FromGitter> <tenebrousedge> `initialize(@backend = BackendConfiguration.new)`
<FromGitter> <grkek> Still it would be nice to have it up
<FromGitter> <tenebrousedge> another option is to use aliases
<FromGitter> <dscottboggs_gitlab> that said it's not a small project for someone not familiar with Crystal macros as it touches a lot of different concepts
<FromGitter> <grkek> display your projects, etc
<FromGitter> <tenebrousedge> `alias Config = BackendConfiguration`
<FromGitter> <Groogy> @grkek I mean "my website" these days is paradoxplaza.com :P
<FromGitter> <Groogy> But yah you are probably right I should probably get it just not show an error message at least
<FromGitter> <dscottboggs_gitlab> nested macros, both kinds of macros, the `@type` special value, etc, etc
<FromGitter> <grkek> Thats a cool website
<FromGitter> <grkek> is it yours ?
<FromGitter> <Groogy> Haha no not really. It's just where I work :D
<FromGitter> <grkek> Aw nice
<FromGitter> <grkek> dont you just hate it when you have a beard and you pull out each one of the hairs while you think about how to implement something
<FromGitter> <grkek> it is a pretty horrible coping mechanism
<FromGitter> <grkek> :D
<FromGitter> <Groogy> For me it's gnawing on the nails
<FromGitter> <Groogy> But yeah I should fix my website so I can link the stuff I've done on Crystal in it
<FromGitter> <dscottboggs_gitlab> treat yo beard with respect lol
<FromGitter> <grkek> I used to do that
<FromGitter> <grkek> and now it went from nails to beard and eyebrows
<FromGitter> <grkek> once I got so mad at myself i shaved both of them lmao
<FromGitter> <grkek> and then got depressed
<FromGitter> <Groogy> take care of yourself, even though I bite my nails I know it is a super bad stress induced behaviour
<FromGitter> <Groogy> and try my best to get rid of it
<FromGitter> <grkek> > stress
<FromGitter> <grkek> that gave me baldspots on my head
<FromGitter> <grkek> humans weren't designed to think
<FromGitter> <grkek> something went wrong
<FromGitter> <grkek> I should be running around woods rn screaming ooga booga
<FromGitter> <bew> Lol, hey @Groogy welcome back!
<FromGitter> <Groogy> Hey @bew thanks!
<FromGitter> <Groogy> Got vacation so can finally try and update everything
<FromGitter> <Groogy> I am also Twitch affiliate now and I have been pondering if I should do a Game Design/Programming in crystal stream
<FromGitter> <grkek> I love talking to you guys, literally have no one to talk to about crystal or programming in general
<FromGitter> <grkek> @Groogy that would be nice
<FromGitter> <mattrberry> @dscottboggs_gitlab Alright well I'll dive in and give it a shot! I'm sure I'll have plenty of questions down the line. Thanks!
<FromGitter> <Groogy> @grkek you working with programming or it's your hobby?
<FromGitter> <grkek> Both
<FromGitter> <dscottboggs_gitlab> I'll do my best to be available! I don't get on here too much but if you @ me I'll notice it within a day or so. @Blacksmoke16 is always here though ;D
<FromGitter> <grkek> coworkers are always busy
<FromGitter> <grkek> and I am just left out alone
<FromGitter> <Groogy> eh sounds like boring place to work
<FromGitter> <Groogy> Programming chats at my place are always filled with people disagreeing which is the "proper way" to code C++
<FromGitter> <tenebrousedge> the best way to code C++ is to write Crystal instead :D
<FromGitter> <mattrberry> Thanks again!
<FromGitter> <grkek> C++ is horrible
<FromGitter> <grkek> I hate it so much
<FromGitter> <grkek> I prefer C
<FromGitter> <dscottboggs_gitlab> ☝️ December 23, 2019 2:46 PM (https://gitter.im/crystal-lang/crystal?at=5e01199cc5a23938b46d9d35) this x 💯
<FromGitter> <dscottboggs_gitlab> > I prefer C ⏎ ⏎ No.
<raz> does anyone know from the top of their head which one is slower: `if foo == :bar` or `if foo.is_a? Bar`?
<FromGitter> <dscottboggs_gitlab> nope
<FromGitter> <dscottboggs_gitlab> wouldn't take long to benchmark thoug
<raz> i know, just being lazy
<FromGitter> <dscottboggs_gitlab> heh
<FromGitter> <Groogy> I prefer Smalltalk derivative languages
<FromGitter> <grkek> @dscottboggs_gitlab why not ? C is really nice
<FromGitter> <Groogy> Hence I am so happy with crystal being sort of smalltalk deritative but can compete in my opinion with the more traditional ones
<FromGitter> <dscottboggs_gitlab> Have you ever written low-level code in Crystal?
<FromGitter> <grkek> So far nothing tops Crystal but still C is nice
<FromGitter> <grkek> No I have not
<FromGitter> <grkek> If you can provide an example
<FromGitter> <grkek> it would be nice
<FromGitter> <dscottboggs_gitlab> let me take a look
<FromGitter> <Groogy> ugh it's been so long since I did my macro crazy stuff in Crystal
<FromGitter> <Groogy> `def \{{name}}(\{{args.splat}}) \{{return_type ? ":" + return_type.stringify : "" }}`
<FromGitter> <grkek> oof
<FromGitter> <Groogy> I'm dding the last part to satisfy the warning
<FromGitter> <Groogy> and this doesn't work because the contract generates method like this: `def done?(world : World) ":Bool"`
<FromGitter> <Groogy> which somehow magically compiles
<FromGitter> <Groogy> but it's not the end result I want :D
<FromGitter> <grkek> Magic of crystal
<FromGitter> <mattrberry> > either that or just like ⏎ > ``` ⏎ > dataclass Data do ⏎ > property data : Type ⏎ > end ... [https://gitter.im/crystal-lang/crystal?at=5e011c8fcf771f77081b015b]
<FromGitter> <dscottboggs_gitlab> I found a snippet but I don't think I ever got the project working @grkek
<FromGitter> <grkek> show it
<FromGitter> <dscottboggs_gitlab> ```macro dataclass(typename, &body) ⏎ ... ⏎ end``` ⏎ ⏎ @mattrberry [https://gitter.im/crystal-lang/crystal?at=5e011ce8cf771f77081b0437]
<FromGitter> <tenebrousedge> ^ relevant
<FromGitter> <dscottboggs_gitlab> @grkek I'm working on it i haven't uploaded it yet
<FromGitter> <grkek> waiting 4 it
<FromGitter> <mattrberry> @dscottboggs_gitlab Thank you!
<FromGitter> <mattrberry> I feel like I'll be thanking you a lot...
<FromGitter> <mattrberry> And thanks @tenebrousedge
hightower3 has quit [Ping timeout: 265 seconds]
<FromGitter> <dscottboggs_gitlab> this was totally unnecessary of course, @grkek, there are abstractions that take care of this sort of thing, but here you go https://github.com/dscottboggs/radio/blob/b69b346c870cf250267bb6c227581ccb95b0a4ff/src/radio.cr#L17-L48
<FromGitter> <dscottboggs_gitlab> also not super low-level, but I am working with pointers directly there
<FromGitter> <Groogy> I don't understand why this won't work, not sure how it malformats the code so I get one "end" too few in the code
<FromGitter> <Groogy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e011e57260751301cfb01a9]
<FromGitter> <dscottboggs_gitlab> there's no end there?
<FromGitter> <Groogy> well no the end comes later
<FromGitter> <grkek> pretty standard stuff @dscottboggs_gitlab easy to read and process, lovely code but one thing
<FromGitter> <grkek> @dscottboggs_gitlab consider this https://github.com/grkek/grip
<FromGitter> <Groogy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e011e9744e1fb33f617f151]
<FromGitter> <Groogy> there is a bigger context
<FromGitter> <grkek> macro hell
<FromGitter> <Groogy> If I only have it do the variant where it doesn't care about the return type it works perfectly fine
<FromGitter> <Groogy> just the warning there
<FromGitter> <dscottboggs_gitlab> oh wow thanks for the link @grkek I use kemal a lot and that might be a better way to organize my code
<FromGitter> <Groogy> also it is not macro hell, it is beautiful in it's own special little way
<FromGitter> <grkek> I mean macro hell for me to understand
<FromGitter> <grkek> but it is beautiful
<FromGitter> <grkek> since I am new to macros
<Yxhuvud> groogy: I think macro expansions need to be self contained. ie, statements need to be contained in a macro, you can't do, eg part of a case statement inside a macro and part outside. All of it has to be in the macro, or none of it.
<FromGitter> <Groogy> hmmm might be it
<FromGitter> <grkek> also @dscottboggs_gitlab most of the dsl stuff is still there but yeah this will help you a lot
<FromGitter> <grkek> thank you for the feedback
<FromGitter> <Groogy> then I will need to do it with a ? : operator
<FromGitter> <Groogy> somehow
<FromGitter> <Groogy> I.e if Nop I want it to omit the ":" on the definition
<FromGitter> <Blacksmoke16> bk
<FromGitter> <grkek> also keep in mind that there is no performance hit what so ever since this does the same as the dsl used to do but it just keeps the whole package more organized and friendly
<Yxhuvud> groogy: Can you use `Void` as a return type as a workaround?
<FromGitter> <Blacksmoke16> unless you working with C bindings, `Nil` is the same
<FromGitter> <Groogy> Well no it's a framework that's wrapping around your code, so I just want to mimick what you are doing.
<FromGitter> <Groogy> If you wanna ignore the warnings, go ahead
<FromGitter> <dscottboggs_gitlab> @Blacksmoke16 even in that case it's only a difference of convention
<FromGitter> <Groogy> If I can get a stringliteral to be printed without the "" then I can make it work
<FromGitter> <tenebrousedge> I want to ignore all the warnings. Full speed ahead! :D
<FromGitter> <Blacksmoke16> @Groogy you can use `{% verbatim do %}`
<FromGitter> <Blacksmoke16> then your macro code
<FromGitter> <Blacksmoke16> then `{% end %}`
<FromGitter> <Blacksmoke16> save from having to do `\{% ...` all the time
<FromGitter> <dscottboggs_gitlab> oh wow that's convenient
<FromGitter> <Blacksmoke16> call `.id` on the macro var
<FromGitter> <dscottboggs_gitlab> and you could nest that too :O
<FromGitter> <Groogy> eh not exactly sure what you mean Blacksmoke
<FromGitter> <Blacksmoke16> `\{{return_type.id}}`
<FromGitter> <Groogy> meant on the "verbatim do"
<FromGitter> <Groogy> but I'll try that
<FromGitter> <Blacksmoke16> like see how all your macro expressions are escaped with the `\`?
<FromGitter> <Groogy> yeah
<Yxhuvud> How does the full macro look like? Perhaps there is other things that can be done to improve the structure?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e01207bcf771f77081b1faa]
<FromGitter> <Blacksmoke16> could then do that
<FromGitter> <Blacksmoke16> without all the `\`
<FromGitter> <grkek> oh that is so much nicer
<FromGitter> <grkek> gg @Blacksmoke16
<FromGitter> <Groogy> Oh thanks Smoke
<FromGitter> <Groogy> well I can show you the full thing on github
<Yxhuvud> verbatim is default when using the macro keyword to define it, no?
<FromGitter> <Groogy> I'm working on the method_added right now
<FromGitter> <Blacksmoke16> `def {{name}}({{args.splat}}){% unless return_type.is_a?(Nop) %} : {{return_type.id}} {% end %}`
<FromGitter> <Blacksmoke16> no need for if/else when the only thing that changes is the return type
<FromGitter> <Blacksmoke16> good question, i think so?
<FromGitter> <Blacksmoke16> verbatim is mainly helpful when using a macro within nested macro hooks
<FromGitter> <Groogy> So when is types wanted as return type?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <dscottboggs_gitlab> (return) types are always inferred -- adding a restriction just produces a better error message if you make a mistake.
<FromGitter> <Groogy> No I mean the warning I am getting
<FromGitter> <dscottboggs_gitlab> oh
<FromGitter> <Groogy> I want to satisfy it and trying to understand when return type is wanted
<FromGitter> <Groogy> because it says it will become a future error
<FromGitter> <Groogy> but does not say specifically what case
<FromGitter> <Blacksmoke16> if you have a return type on an abstract def, the implementations of it must have the same or stricter return type
<FromGitter> <Groogy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e012206260751301cfb1827]
<FromGitter> <dscottboggs_gitlab> looks like *when overloading*
<FromGitter> <Groogy> alright cool
<FromGitter> <Groogy> I am a bit worried if my libraries will mess with this and always force you to provide a type
<FromGitter> <Groogy> though not sure if that is a bad thing inherently
<FromGitter> <Blacksmoke16> if you dont want to have to do that you can remove the return type restriction on the parent abstract def
<FromGitter> <grkek> Okay, guys I am off to sleep, cya tommorow
<FromGitter> <grkek> good night
<FromGitter> <Blacksmoke16> o/
<FromGitter> <Groogy> Well my macro is overloading and then calling the previous definition
<FromGitter> <Groogy> but if this is only on abstract ones
<FromGitter> <Groogy> it's going to be fine
<FromGitter> <Groogy> Good night @grkek
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Groogy> Alright after cleaning up the code with `verbatim do`
<FromGitter> <Groogy> if you want to have a peak at my madness
<FromGitter> <Blacksmoke16> prob could use some indents too :p
<FromGitter> <Groogy> yeah well I found this was more readable to keep em on same level
* FromGitter * Blacksmoke16 wishes the formatter fixed macro code too
<FromGitter> <Groogy> though probably should indent it properly
<FromGitter> <Groogy> I am also doing all of this from my windows laptop in the WSL and I am surprised it even works
<FromGitter> <Blacksmoke16> :p
<FromGitter> <Groogy> since all development for the graphics framework etc was done on Linux
<FromGitter> <Groogy> now I just got the memory profiler left
<FromGitter> <dscottboggs_gitlab> did you guys see that someone made an OS in crystal?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <dscottboggs_gitlab> well, Crystal-ish
<FromGitter> <dscottboggs_gitlab> his compiler is heavily patched
<FromGitter> <Groogy> Also "how much" of an OS is it?
<Yxhuvud> I love how he (?) included a precise GC for crystal in that OS.
<FromGitter> <dscottboggs_gitlab> > "how much" ⏎ ⏎ single-user, only uses FAT16, but it has a desktop and windowing environment
<Yxhuvud> and multithreading, if I read it right.
<Yxhuvud> *processing
<FromGitter> <dscottboggs_gitlab> I mean it's its obviously not something that's going to replace your linux box but it's still really cool
<FromGitter> <Groogy> Ah no I was just curious
<FromGitter> <Groogy> How far gone
<Yxhuvud> https://news.ycombinator.com/item?id=21860713 for the lengthy HN discussion.
<FromGitter> <tenebrousedge> a kernel in Crystal : https://github.com/lbguilherme/os-crystal
<FromGitter> <Groogy> has anything with Shards and releases been changed?
<FromGitter> <Groogy> or well you wouldn't know how long back this was for me so kind of dumb question
<Yxhuvud> Uh, there was a release where they changed to a SAT based version resolver, but apart from that I havn't heard anything for a long time.
<FromGitter> <Groogy> a SAT based version resolver?
<Yxhuvud> basically upgrading all versions of everything to the globally best choice. Turns out to be NP complete in general. Basically what all modern package managers do, except for the one in Go.
<FromGitter> <Groogy> alright cool
<FromGitter> <Groogy> so then question becomes if it's 1.1.0 or 1.0.1 :D
<FromGitter> <Groogy> in essence it's a patch but it sort of breaks things but is not any new features
<FromGitter> <JohnLegrandRichards> Hey Guys! Looking to start contributing to Crystal. I read through the contribution guide. It told me I should maybe take a look at the newcomer label but those all seem to be handled. Anyone want to point me towards an Issue I could take a look at? Thanks!
<FromGitter> <Blacksmoke16> best bet would be to just paruse the issues and see if there's anything you want to/can do
<Yxhuvud> @JohnLegrandRichards: You could always look through the documentation and see if you can find something that needs improvements. That will teach you about the codebase and the process and perhaps give you an idea of what else might be feasible given what your skills have.
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> api doc improvements are always nice
<Yxhuvud> what is really needed is more people knowing their way around the compiler, but the step to be productive there is pretty high
<FromGitter> <Blacksmoke16> yea...
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/6996 fix this one first and ill buy you a ☕ :p
<FromGitter> <Groogy> Hmm this problem is a bit weird...
<FromGitter> <Groogy> can't see what I am missing
<FromGitter> <Blacksmoke16> ha how ironic
<FromGitter> <Groogy> "Is not defined" I can clearly see it is though D:
<FromGitter> <Groogy> welp maybe it's caused by the error "after" it
<FromGitter> <Blacksmoke16> pretty sure its related to that issue i linked
<FromGitter> <Groogy> Getting a too nested generic type
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/89hc this seems to compile tho?
<FromGitter> <Groogy> yeah so I am starting to suspect it is caused by the error that comes when I comment away that code
<FromGitter> <Groogy> `Error: generic type too nested: Trashman::Record(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(
<FromGitter> ... tter.im/crystal-lang/crystal?at=5e013390cf771f77081bb358]
<FromGitter> ... Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Trashman::Ref(Array(Tra ... [https://gi
<FromGitter> <Groogy> and god damn no idea how that happens
<FromGitter> <Groogy> Ah right my checks to make sure this does not happen is in runtime
<FromGitter> <Groogy> that's why
<FromGitter> <Groogy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e01344784c2167709526c90]
<FromGitter> <Groogy> if I can solve that then yeah it should work just dandy again
<FromGitter> <Groogy> Can I somehow have it not do the included if `@type == Array(Trashman::*)`?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <Groogy> Well problem is I am including Trashman into Array, and the profiler is using Array itself, and would be nice if I could just have it not run the included macro on anything that belogns to the Trashman Module
<FromGitter> <Groogy> including an Array with Trashman objects in it
wmoxam has joined #crystal-lang
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Groogy> Like something `{% Trashman.includes?(@type) || @type.generic_args.includes?(Trashman.types) %}`
<FromGitter> <Groogy> something like that?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Crystal/Macros/TypeNode.html#%3C=(other:TypeNode):BoolLiteral-instance-method ?
<FromGitter> <Groogy> will that also work on modules and the types within it?
<FromGitter> <Blacksmoke16> i dont recall
<FromGitter> <Blacksmoke16> maybe?
<FromGitter> <Groogy> all_subclasses probably better
<FromGitter> <Groogy> or wait no
<FromGitter> <Groogy> can I somehow figure out the template arguments given to a class I am included into?
<FromGitter> <Blacksmoke16> got an example?
<FromGitter> <Blacksmoke16> playground link ideally
<FromGitter> <Groogy> I'm gonna see if I can recreate it
watzon has quit [Quit: WeeChat 2.7]
<FromGitter> <Groogy> so what I want, in the second `arr2`, that it won't actually include the `#biz` method
<FromGitter> <Blacksmoke16> does it have to be gone completely? or what about just return nil or something?
<FromGitter> <Groogy> oooh I got an idea
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/89i3
<FromGitter> <Groogy> damnit didn't work for me
<FromGitter> <Groogy> oooh
<FromGitter> <Groogy> now just need to convert it to check for all constants inside the module
<FromGitter> <dscottboggs_gitlab> woah, cool
<FromGitter> <Groogy> the generic arg you gave to the module is not needed Smoke
<FromGitter> <Blacksmoke16> fair, due to the included hook
<FromGitter> <Groogy> right so I am getting what I want
<FromGitter> <Groogy> I just need to get this TypeNode to become a MacroId
<FromGitter> <Blacksmoke16> call `.id` on it
<FromGitter> <Blacksmoke16> converts it to a macro id
<FromGitter> <dscottboggs_gitlab> > what is really needed is more people knowing their way around the compiler ⏎ ⏎ perhaps documenting the compiler would help with that 😒
<FromGitter> <Groogy> I did try .id on it, didn't help
<FromGitter> <Groogy> tried .name as well
<FromGitter> <dscottboggs_gitlab> what do you want it to look like?
<FromGitter> <Groogy> Well line 9 should evaluate to true
<FromGitter> <Groogy> Once
<FromGitter> <Groogy> i.e on the second call where we have both collections being Foo::Bar, it should return nil
<FromGitter> <Groogy> somehow Foo::Bar != Foo::Bar and I am very confused how the macro id's don't equal each other
<FromGitter> <Groogy> ah so technically they are different, one is Bar while one is Foo::Bar
<FromGitter> <dscottboggs_gitlab> ah
<FromGitter> <dscottboggs_gitlab> that'll do it
<FromGitter> <Blacksmoke16> try calling `resolve` maybe?
<FromGitter> <Groogy> resolve just returns itself on TypeNode, MacroId do not have resolv
<FromGitter> <Groogy> :(
<FromGitter> <Groogy> What I could do is a workaround
<FromGitter> <dscottboggs_gitlab> just do `type.split("::").last`
<FromGitter> <dscottboggs_gitlab> idk macro doesn't have overloads so it might be something else but you get the gist I hope
<FromGitter> <Groogy> Nah think this works better, also makes it more configurable
<FromGitter> <Groogy> i.e "Hey if there's a constant telling you to ignore this type? Then ignore the type"'
<FromGitter> <Blacksmoke16> annotation would be easier
<FromGitter> <Blacksmoke16> `@[TrashMan::Ignore]`
<FromGitter> <Groogy> oh right that's the new thing in the newer versions
<FromGitter> <Groogy> I'll add that
<FromGitter> <Blacksmoke16> makes it super easy to exclude types that have it
DTZUZU has joined #crystal-lang
<FromGitter> <Groogy> how do I check it? Just annotation(t).args.includes?("Trashman::Ignore") ?
<FromGitter> <Blacksmoke16> is `t` a `TypeNode`?
<FromGitter> <Groogy> yeah it would be the typenode from the generic arg
<FromGitter> <Blacksmoke16> `{% if t.annotation(Trashman::Ignore) %}`
<FromGitter> <Groogy> Ah so I'd have to make a type that is Ignore here?
<FromGitter> <Blacksmoke16> `annotation Trashman::Ignore; end` yes
<FromGitter> <Groogy> nice
<FromGitter> <dscottboggs_gitlab> yes that's much nicer 👍
<FromGitter> <Blacksmoke16> can use `unless` versus `if !`
<FromGitter> <Blacksmoke16> i guess annotations are catching on now :S
<FromGitter> <dscottboggs_gitlab> was so stoked the other day when I realized *sh* has `until`
<FromGitter> <dscottboggs_gitlab> > i guess annotations are catching on now :S ⏎ ⏎ annotations have their place, and are useful for some things.
<FromGitter> <Groogy> unless gave me compile errors
<FromGitter> <Groogy> but yeah this looks nicer
<FromGitter> <Groogy> gonna see if I can apply it properly
<FromGitter> <dscottboggs_gitlab> lolwat
<FromGitter> <Blacksmoke16> its a bug
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/89kr
<FromGitter> <Blacksmoke16> cant use `unless` when the macro statement is escaped
<FromGitter> <dscottboggs_gitlab> that's weird.
DTZUZU has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> id file it
DTZUZU has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> oh, I thought you meant it was a *known* bug! Yes, definitely, someone file that!
DTZUZO has quit [Ping timeout: 265 seconds]
<FromGitter> <Blacksmoke16> oh idk if it has, i doubt it tho
<FromGitter> <Blacksmoke16> i would prob have remembered it
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
yukai has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
<FromGitter> <Groogy> Is it a bug that sizeof(T) won't give me the size of the elements inside it?
<FromGitter> <Blacksmoke16> i dont think thats what `sizeof` is for
<FromGitter> <Groogy> Hmm I want the size it actually takes in memory
<FromGitter> <Groogy> after that I am finally done fixing everything
<FromGitter> <Blacksmoke16> iterate over and sum?
<FromGitter> <Groogy> Eh seems like something that should exist already tho