ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
ur5us has joined #crystal-lang
hexology is now known as hexology_
hexology_ is now known as hexology__
hexology__ is now known as hexology`
hexology` is now known as hexology_`
hexology_` is now known as hexology
okcan_ has joined #crystal-lang
okcando has quit [Ping timeout: 265 seconds]
ur5us has quit [Ping timeout: 264 seconds]
hightower2 has joined #crystal-lang
okcan_ has quit [Read error: Connection reset by peer]
okcan_ has joined #crystal-lang
hightower2 has quit [Remote host closed the connection]
hightower2 has joined #crystal-lang
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 264 seconds]
yxhuvud has quit [Remote host closed the connection]
taupiqueur has joined #crystal-lang
yxhuvud has joined #crystal-lang
<spuun> I have a MetaVar (from @type.instance_vars) which i know is a Hash, but i want to get the key and value types. How? I want to go from the MetaVar to a HashLiteral, I think?
<spuun> type.type_vars is enough
hightower2 has quit [Ping timeout: 252 seconds]
hightower2 has joined #crystal-lang
mookie has joined #crystal-lang
Guest70931 has quit [Ping timeout: 252 seconds]
antoszka has joined #crystal-lang
<FromGitter> <Blacksmoke16> 👍
taupiqueur has quit [Remote host closed the connection]
taupiqueur has joined #crystal-lang
Vexatos_ has joined #crystal-lang
adam129 has joined #crystal-lang
SamantazFox has quit [Killed (NickServ (GHOST command used by SamantazFox_))]
SamantazFox_ has joined #crystal-lang
straight- has joined #crystal-lang
xybre has quit [Ping timeout: 256 seconds]
adam12 has quit [Ping timeout: 256 seconds]
Vexatos has quit [Ping timeout: 256 seconds]
raz has quit [Ping timeout: 256 seconds]
straight-shoota has quit [Ping timeout: 256 seconds]
riza has quit [Ping timeout: 256 seconds]
adam12 has joined #crystal-lang
Guest70931 has joined #crystal-lang
adam129 has quit [Read error: Connection reset by peer]
mookie has quit [Ping timeout: 256 seconds]
taupiqueur has quit [Ping timeout: 256 seconds]
raz has joined #crystal-lang
raz has joined #crystal-lang
raz has quit [Changing host]
taupiqueur has joined #crystal-lang
xybre has joined #crystal-lang
riza has joined #crystal-lang
taupiqueur has quit [Quit: taupiqueur]
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 256 seconds]
<FromGitter> <paulocoghi> Is it possible to dynamically call an instance method, passing the instance variable name by string?
<FromGitter> <Blacksmoke16> not built in, but it's technically possible to re-create
<FromGitter> <Blacksmoke16> there is no`#send` like in Ruby, but id consider redesigning it so you dont need to do that?
<FromGitter> <maxfierke> https://github.com/wyhaines/Send.cr is one such approach to dynamic dispatch in Crystal
<FromGitter> <paulocoghi> I am implementing this concept in Crystal:
<FromGitter> <paulocoghi> A library where you can "register" services (that is, class instances) with defined "expected" methods
<FromGitter> <paulocoghi> The main library allow the "registration" of one or more instances
<FromGitter> <paulocoghi> The classes are created by the developer, which must have one or more methods (from the expected ones)
<FromGitter> <paulocoghi> And the library is responsible to (automatically) expose each service on the desired protocol, like a REST API, or Socket, etc
<FromGitter> <maxfierke> one option would be to use the `macro finished` hook to collect all the registered sub-classes and do what you need to there
<FromGitter> <maxfierke> an example of this is in a program where I use the sub-classes of a base class to generate a table/hash of CLI options: https://github.com/maxfierke/mstrap/blob/d5a53cfdd809e35594ec55e58c599edffcd7c2dc/src/mstrap/step.cr#L68-L78
<FromGitter> <paulocoghi> Thank you @Blacksmoke16 and @maxfierke
<FromGitter> <paulocoghi> > but id consider redesigning it so you dont need to do that? ⏎ Agree
<FromGitter> <paulocoghi> From my little knowledge, it seems that using macros is a possible solution, as Max explained with examples
<FromGitter> <Blacksmoke16> https://athenaframework.org/EventDispatcher/ may also be helpful?
<FromGitter> <Blacksmoke16> define listeners on specific events, the the core logic emits those events
<FromGitter> <paulocoghi> Interesting! I will see if I can "automate" this process (or part of it) in order to reduce the syntax for the final developer
<FromGitter> <paulocoghi> In simple terms, I am building a framework with an architecture based on the `continuous passing` style. ⏎ ⏎ The experience I would like to provide is something like this *(the example below is just a draft/idea, not a valid Crystal program)* :
<FromGitter> <paulocoghi> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=61a66a48cdb5c1081a3c9a9e]
<FromGitter> <paulocoghi> After defining the "services", the develop can "hook" functions before and after a method from a service, creating a "chain" of functions *(continuous passing style here)*, in order to express the business rules (or contract) for each method
<FromGitter> <Blacksmoke16> hmm, how would it handles route arguments and such? I'm not familiar with this pattern, but curious to hear the benefits over other existing frameworks
<FromGitter> <paulocoghi> Each hook (which is a function/method) is completely unaware of where it is, or what is the bigger context *(from clean architecture)*
<FromGitter> <paulocoghi> Each one can receive one or two arguments, like `context` and `next`, or just `context` *(which I will do)*, and solve only it's responsibility *(single responsibility from clean code)*
<FromGitter> <Blacksmoke16> so kinda like something built on top of https://crystal-lang.org/api/master/HTTP/Handler.html ?
<FromGitter> <Blacksmoke16> or more so decoupled from HTTP itself
<FromGitter> <paulocoghi> Exactly
<FromGitter> <paulocoghi> The difference is that HTTP is just a protocol implementation, for REST API, for example
<FromGitter> <paulocoghi> The framework itself is protocol agnostic
<FromGitter> <paulocoghi> And each protocol implementation is also one "part" of the whole
<FromGitter> <paulocoghi> Implementing a new protocol, like MQQT, or QUIC, or HTTP/3, or Sockets, is just "one abstraction" away
<FromGitter> <paulocoghi> The developer can use a already-implemented protocol, or easily create one for itself
<FromGitter> <Blacksmoke16> is this a unique idea? or is there an existing framework you're porting that follows a similar pattern?
<FromGitter> <paulocoghi> This is not a unique idea.
<FromGitter> <paulocoghi> I am heavily inspired on FeathersJS "concept"
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <paulocoghi> But, when using it in production, its concepts are lost in the middle of a lot of noise, like body parsing, url encoding, decoding, etc etc
<FromGitter> <paulocoghi> According to what I've done in javascript, here https://github.com/alumna/backend
<FromGitter> <paulocoghi> *(re-implementing the FeathersJS concept, but without this noise to the final developer)*
<FromGitter> <paulocoghi> I am convinced that my language is now Crystal, and I want to re-create this concept again on it
<FromGitter> <paulocoghi> It's the sum of the concepts from Clean Architecture, Clean Code, Continuous Passing style, which *in part* is well followed and done in Feathers, in part not
<FromGitter> <Blacksmoke16> sounds like quite the project. ill be curious to see how it goes
<FromGitter> <paulocoghi> I am working full-time on it right now, and it will be totally open source
<FromGitter> <paulocoghi> No "pro" or "enterprise" versions
<FromGitter> <paulocoghi> The business-model will be to provide support and/or infrastructure for companies that want it. That's all
<FromGitter> <paulocoghi> > hmm, how would it handles route arguments and such? ⏎ ⏎ Each protocol implementation has the responsibility to "translate" in a secure-manner the incoming data
<FromGitter> <paulocoghi> It's an abstraction
<FromGitter> <paulocoghi> The "activated" protocols receive the requests, translate them and, finally, call the correspondent internal service method
<FromGitter> <paulocoghi> If they are "hooks" of functions on the request method, such functions will be called in sequence, in order to validate and process the data, prior to the service method
<FromGitter> <Blacksmoke16> sounds like you got it all figured out, now comes the hard part :P
<FromGitter> <paulocoghi> Exactly 😄
<FromGitter> <Blacksmoke16> might be tricky, as JS isn't a great model for crystal code
<FromGitter> <paulocoghi> I am decided to learn Crystal as my new main language, and follow its way-of-thinking to implement the framework
<FromGitter> <Blacksmoke16> good choice :)
<FromGitter> <paulocoghi> Thanks a lot :)
<FromGitter> <paulocoghi> Crystal is a special language
<FromGitter> <paulocoghi> And I concluded this after revisiting many many ones
<FromGitter> <paulocoghi> I am not an expert. But Crystal is really solid
ur5us has joined #crystal-lang
hightower3 has quit [Ping timeout: 256 seconds]
ur5us has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
hightower2 has joined #crystal-lang
ur5us has quit [Ping timeout: 256 seconds]
ur5us has joined #crystal-lang
hightower2 has quit [Ping timeout: 256 seconds]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Quit: taupiqueur]
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang