<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
<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)
<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 )
<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>
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
<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``` ⏎
<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
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