ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.23.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
fenicks has left #crystal-lang [#crystal-lang]
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 246 seconds]
Renich has joined #crystal-lang
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
Dreamer3_ has joined #crystal-lang
Dreamer3_ has quit [Remote host closed the connection]
Dreamer3_ has joined #crystal-lang
_whitelogger_ has joined #crystal-lang
w-p has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <oprypin> Ed
<FromGitter> <oprypin> so
<FromGitter> <oprypin> what the hell this is broken xD
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 258 seconds]
<FromGitter> <codenoid> hi , how to stop each process when if requirement is true ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5976e2ae76a757f808438e09]
<FromGitter> <codenoid> hi , how to stop each process when if requirement is true ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5976e2d1f5b3458e307d0c23]
snsei_ has quit [Remote host closed the connection]
<FromGitter> <codenoid> my new app name :p @bararchy https://s11.postimg.org/t6sqa0soj/Selection_023.png
<FromGitter> <codenoid> ?
<FromGitter> <codenoid> break
<FromGitter> <codenoid> haha nice
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> lol
Groogy has quit [Disconnected by services]
Groogy_ is now known as Groogy
<Groogy> Hiya!
Groogy2 has joined #crystal-lang
<FromGitter> <codenoid> sup
<Groogy> hmm you can't provide the class as an argument to a type that it inherits from?
<Groogy> anyway around this?
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<Groogy> think I got the last piece of the pussle to solve my problems anyway ^^ https://play.crystal-lang.org/#/r/2exc
<Groogy> but hmm kind of limiting that the constant isn't defined so it's not available for the inheritence :/ there's tons of cool stuff you can do with that
mark_66 has joined #crystal-lang
<FromGitter> <codenoid> hahahaha https://github.com/codenoid/barachy
<Groogy> haha
g3funk has quit [Ping timeout: 268 seconds]
rohitpaulk has quit [Ping timeout: 260 seconds]
miketheman has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
g3funk has joined #crystal-lang
miketheman has joined #crystal-lang
<FromGitter> <crisward> Anyone know how you define a proc type, when you don't care what it returns ? Proc(String, ?)
<FromGitter> <crisward> Ok, looks like void may work Proc(String, Void)
<Groogy> eh isn't it Nil?
<Groogy> Void is for C libs I think
<FromGitter> <crisward> Nil complains if your method returns something other than nil.
<Groogy> eh u sure? because I think sa literal proc that takes no argument and returns nothing is defined as Proc(Nil)
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <crisward> I got a compile when I setup my proc as `Proc(String,Nil)` as my method happend to return a string, which I don't care about.
<FromGitter> <bew> you can use `Proc(String, _)` iirc
<FromGitter> <bew> @crisward
<Groogy> also I am so happy ^^ https://play.crystal-lang.org/#/r/2ey5
<Groogy> It's pretty close to how I would have solved similar thing in C++ but a lot less code
<Groogy> i.e I can store an arbitrary Proc signature, and build an argument list for it
<FromGitter> <bew> could you explain in one line what it's supposed to do/solve?
<Groogy> Bind an input to be transformed to data that can be parsed as argument to any method
<Groogy> i.e you write the code once and two different input can generate the same call in a way the code can understand
<Groogy> even if the underlying data to do that call is fundamentally different
<FromGitter> <bew> sounds really powerful!
<FromGitter> <bew> oh I see, really nice stuff
<Groogy> I am trying to replicate what the Steam Controller API accomplishes which let's you ad-hoc switch between any controller/joystick/keyboard seamlessly
<Groogy> and you write the code only once
<FromGitter> <bew> so the Bar & Baz translators would be translators for a keyboard or controller, and the callbacks are actions?
<FromGitter> <bew> Note: you can use `def initialize(&@block : T)` (note the `@`) to init an instance var with the passed block directly
sz0 has joined #crystal-lang
<Groogy> ah yeah I'll be cleaning it up when I get home
<Groogy> this was just "see what makes what tick" in the language
<Groogy> and yeah this is a smaller version of what I have at home, I was just trying to solve one last thing which this does. But yeah there would be action that maps "what input goes to where and how to interpret that input"
<Groogy> and then you have a callback it invokes which with this should mean I can just do ->player.jump
<Groogy> and it should magically work
<FromGitter> <bew> I don't see why you need the `Callback` and `CallbackImp` though
<Groogy> because otherwise it will generate a #execute_on variant for every type of callback/argument pair
<Groogy> that was what I found at home and after sleeping on it, I was trying out things at work while my code base compiled
<Groogy> (and problem with having several variants of #execute_on is that some callback/argument pairs won't copile)
<FromGitter> <bew> maybe not usefull, but this uses directly the Proc type for the callback: https://play.crystal-lang.org/#/r/2ey6
<Groogy> huh
<Groogy> how does it manage to deduce the Proc type there?
<Groogy> I was told I always should define the Proc type?
<FromGitter> <bew> well, here you pass it as a value, not as a block argument, so it acts the same way as other generic type like array or hash, and you can restrict arguments to the generic type, like `def bla(arg : Array)` without specifying `Array(String)`.. is this helping you? or are you stuck somewhere else?
<Groogy> no I am done now
<Groogy> but that will clean up the code way more
<FromGitter> <bew> cool ;)
<Groogy> the problem I had before was that #translate would be deduce to be #translate( input : InputEvent ) : (Union of every single translate return tuple)
<Groogy> which is what I was trying to work around
<FromGitter> <bew> also, I removed the `struct` for `Glue` and used directly a module, maybe its not what you want if you need to store state somewhere in the glue code executor
<Groogy> nah it was a struct just because of C++ habbit
<Groogy> because of how the template language works there
<FromGitter> <bew> ahah I see, I had fun with C++ meta programmation once, to rewrite a custom `std::bind` without the variadic templates from c++11, that was my hardest time with C++ templates and his type system ^^ Crystal is so much cleaner and concise!
<Groogy> yeah part of this is to learn how to do things in Crystal instead
<FromGitter> <bew> true, thats a good training! (and we all want the first crystal game before 1.0 as you promised :D )
<Groogy> but this is really nice, thx bew
<FromGitter> <bew> yw!
<Groogy> ;D
<FromGitter> <bew> and now that I think about it, the GlueExecutor module is useless: https://play.crystal-lang.org/#/r/2eye
<Groogy> hmm there's a proc method to define a proc with predefined variables, there isn't something similar with the literal version?
<FromGitter> <bew> what do you mean? example?
<Groogy> ->Glue.execute(arg1, arg2)
<Groogy> where arg1 and arg2 are variables, i.e I want a proc where it just automatically generate that these values will be passed
<FromGitter> <bew> maybe you could find something with `Proc#partial`
<crystal-gh> [crystal] straight-shoota opened pull request #4746: JSON output for docs (master...jm-json-docs) https://git.io/v7msM
<Groogy> actually I think it needs to remain an immediary callback object actually
<Groogy> unless I am missing something
<FromGitter> <bew> even with callback objects, I think you'll have issues with the translators and the splating like the issue here..
<Groogy> yeah trying to delay it "resolving the type" as late as possible which should help
<FromGitter> <bew> I was thinking about making the translators a generic type, where T would be the Result type of Bar#translate for example, this way you'll be able to store the return type and be able to match it with the glueexecutor when needed.. not sure if it help in any way though, its just a blurred idea from my mind^^
<Groogy> there we go
<Groogy> not 100% how I want it yet but it shows it can be done
<Groogy> just have to resolve the types using the virtual talbe
<Groogy> table*
<Groogy> though hmm might be false positive since I am only testing with one type, nvm
tzekid has joined #crystal-lang
<FromGitter> <bew> Groogy, it seems that I'm missing something: what is the role of the translator exactly?
<FromGitter> <bew> is there a translator per callbacks?
<Groogy> Nah the action will say "Oi this input interests me" and translate it to an expected format which thne callbacks receives attached to the same symbol (like let's say :jump)
<FromGitter> <bew> so, a given action has a specific signature, and it has a translator for this specific action, that can translate any input kinds to the correct data for the action?
<Groogy> yeah
<FromGitter> <bew> is there a finite number of action at compile time? or can the syste get new actions at runtime?
<Papierkorb> Erm, does someone know why `shards` sticks to version 0.2, and doesn't use 0.2.1, when installing it as a dependency without a explicit version? https://github.com/Papierkorb/cannon
<Papierkorb> The shard.yml is (now) up to date, the version tag is too.
<Papierkorb> Is it because the tag `v0.2` is shorter in length or something arcane like that?
bjz has joined #crystal-lang
<Groogy> @bew yeah plan is to have it scriptable, but the literal types of actions will be finite
w-p has joined #crystal-lang
<FromGitter> <bew> cool, I may have an idea then.. Anyone remember what is the name of the macro hook to be executed at the en of all macros?
<Groogy> finished
<FromGitter> <bew> that's it, thanks!
<Papierkorb> Eeyup, renaming `v0.2` to `v0.2.0` fixed it.
<FromGitter> <konovod> 😄
<FromGitter> <konovod> btw i'm still editing your shard manually - finalizer in remote_service causes GC warning about initialization loop
<Papierkorb> Huh? Nothing should produce a GC warning. do you have a test code?
<FromGitter> <konovod> so i just comment it out because i don't add services dynamically, but i don't know solution for general case
<FromGitter> <konovod> i've failed to identify minimal example - i think it has something to do with service holding pointers to outside data, or maybe not
<FromGitter> <bew> Groogy, is there only one translator per action?
<FromGitter> <konovod> @oprypin disabled finalizers in chipmunk bindings - i think he could have hit the same problem.
<Groogy> the action itself is the translator
<Groogy> but it can potentially be translating for several different callbacks
<Groogy> or actually should probably pair it, might make things easier. One action per callback
<Groogy> yeah doesn
<Groogy> doesn't it become much simpler bew if one action is just directly tied to one callback?
<Groogy> can just have the actions stored inside with a symbol attached to them and it creates a glue object with the correct action/translator (so you don't need to keep a reference to them externally)
<RX14> Papierkorb, v0.2 isn't really semver but it's still a bug
<RX14> you should report it
<FromGitter> <bew> Groogy I got a really small version of your example: https://play.crystal-lang.org/#/r/2ezz
<Groogy> ah that's really good :P though translate will also be getting an input object later on so can't make a partial out of it
<FromGitter> <bew> arf, true
<Groogy> but it does show I can probably make this even smaller
<Groogy> think the key is though to have the GlueImp resolve the actual types so each #execute method becomes unique for resolving everything
<Groogy> With some input and logic for if we should process this input at all: https://play.crystal-lang.org/#/r/2f07
<FromGitter> <bew> it's nice!
<Groogy> and you don't need to allocate Bar and Biz either, you can just pass the types to it I believe
<Groogy> which looks a bit neater
<Groogy> @bew thx for the help and being a sounding board for me ^^
<Groogy> also if you see anything where stuff can be "taken away" to make it smaller/simpler let me know
<FromGitter> <bew> you're welcome, it's always interesting for me to help like this :) i'll try
<Groogy> will integrate it as soon as I come home ^^
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <maran> Trying out some Crystal today and had a question. I was playing around with the moviedb api. All their search results look the same in JSON. A key for page/total_pages/total_results and then an array with 'results' however the results can be movie objects, people objects etc. Now I can create a MovieResult object and a PeopleResult etc object that would look like this: ⏎ ⏎ ```code paste, see link``` ⏎
<FromGitter> ... ⏎ But there must be a DRYer way of doing this in Crystal right? [https://gitter.im/crystal-lang/crystal?at=5977443abc464729742367c9]
<Papierkorb> maran, you could use a generic for this: rename the class to `Result`, but add `(T)`: `class Result(T)`. Then, instead of results being a Array(Movie), make it a `Array(T)`
<Papierkorb> maran, to use, do something like `Result(Movie).from_json response.body`
<FromGitter> <maran> That sounds like a solution; I will look into generics
<FromGitter> <maran> Thanks for the suggestion :)
<FromGitter> <maran> Wow that was easy; worked perfectly @papierkorb
<Papierkorb> Cheers
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
baweaver has quit [Ping timeout: 260 seconds]
salvor has quit [Ping timeout: 260 seconds]
baweaver has joined #crystal-lang
baweaver is now known as Guest2003
salvor has joined #crystal-lang
Philpax_ has quit [Ping timeout: 255 seconds]
<crystal-gh> [crystal] akzhan closed pull request #4712: Regex - Optional Unicode properties support, and prefer brewed libpcre on MacOS (master...libpcre-ucp) https://git.io/vQdcd
greengriminal has joined #crystal-lang
mark_66 has quit [Read error: Connection reset by peer]
greengriminal has quit [Quit: This computer has gone to sleep]
mark_66 has joined #crystal-lang
xiljin has quit [Quit: ...]
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
greengriminal has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
Renich has quit [Quit: Renich]
<FromGitter> <renich> Good day, Crystal Ian's! o/
<FromGitter> <renich> Damn phone...
<adam12> @renich o/
<FromGitter> <98016071> I am trying to make a construction similar to python wrapping: suppose I have function and want to surrond its body with begin...rescue...end (And do the same thing with a lot of functions). Is there any way to do this in Crystal? I found one, but it looks bad, i want to pass multi-line code inside braces, not as string. ⏎ ⏎ ```code paste, see link``` [https://git
<FromGitter> ... ter.im/crystal-lang/crystal?at=597768f289aea4761dd249af]
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
<Papierkorb> ... the gitter bridge bot broke the link.
txdv has quit [Ping timeout: 260 seconds]
<FromGitter> <romain1189> Hi, I started to list some shards that would be interesting for scientific applications here (https://gist.github.com/rumenzu/36d2c0c7ab948d0af63f6de544ddc00e). Thought someone might be interested
rohitpaulk has quit [Ping timeout: 248 seconds]
A124 has quit [Ping timeout: 260 seconds]
A124 has joined #crystal-lang
pwned has joined #crystal-lang
Guest2003 is now known as baweaver
baweaver has quit [Changing host]
baweaver has joined #crystal-lang
baweaver is now known as DioBrando
DioBrando is now known as baweaver
saadq has quit [Ping timeout: 260 seconds]
txdv has joined #crystal-lang
saadq has joined #crystal-lang
<FromGitter> <bew> nice @romain1189, are all of theses in https://github.com/veelenga/awesome-crystal ?
rohitpaulk has joined #crystal-lang
<FromGitter> <rumenzu> @bew not all of them. I don't think they all meet awesome-crystal contribution guidelines.
scanhex has joined #crystal-lang
scanhex has quit [Client Quit]
<crystal-gh> [crystal] RX14 opened pull request #4747: Display type when inspecting numbers (master...feature/show-int-type) https://git.io/v7Ytz
tzekid has quit [Quit: Leaving]
kaleido has joined #crystal-lang
tzekid has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
pwned has quit [Ping timeout: 268 seconds]
sz0 has joined #crystal-lang
pwned has joined #crystal-lang
Groogy3 has joined #crystal-lang
Groogy2 has quit [Ping timeout: 260 seconds]
Dreamer3_ has quit [Quit: Computer has gone to sleep.]
bjz has joined #crystal-lang
pwned has quit [Ping timeout: 240 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <watzon> @98016071 it looks a lot better if you do this: ⏎ ⏎ ```surround mymethod, <<-CODE ⏎ puts "Hello" ⏎ puts "Goodbye" ⏎ CODE``` [https://gitter.im/crystal-lang/crystal?at=5977c6011c8697534a5d3765]
<FromGitter> <watzon> Still not perfect, but I don't know of a way to do it better
<FromGitter> <faustinoaq> Maybe this: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ https://carc.in/#/r/2f4e [https://gitter.im/crystal-lang/crystal?at=5977c748c101bc4e3abe32c4]
Philpax_ has joined #crystal-lang
greengriminal has joined #crystal-lang
<oprypin> 98016071, see an older example https://carc.in/#/r/2bjx https://carc.in/#/r/2bk7
<oprypin> instead of making two functions one can use one, with f.body i think
<oprypin> no pc to try
hightower has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
deep-book-gk_ has joined #crystal-lang
deep-book-gk_ has left #crystal-lang [#crystal-lang]