bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
jhass has quit [Ping timeout: 252 seconds]
snsei has joined #crystal-lang
snsei has quit [Read error: Connection reset by peer]
snsei_ has joined #crystal-lang
asterite has quit [Ping timeout: 250 seconds]
DeBot has quit [Ping timeout: 250 seconds]
Philpax has joined #crystal-lang
Raimondi has quit [Remote host closed the connection]
Raimondi has joined #crystal-lang
matp has joined #crystal-lang
onethirtyfive has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
vikaton has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Client Quit]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
asterite has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
jhass has joined #crystal-lang
<FromGitter>
<citizen428> hi all :)
<FromGitter>
<citizen428> i've hit a roadblock, and i'm sure i'm just overlooking something obvious
<FromGitter>
<citizen428> i know i can use something `klass.is_a?(Reference.class)` to check whether or not a class was implemented with `class` or `struct`
<FromGitter>
<citizen428> but i can't seem to figure out how to do the same in a macro to reopen said class/struct
<FromGitter>
<citizen428> for example if i pass the `Array` class to my macro, i need it to write code starting with `class Array`, whereas for a Tuple it needs to be `struct Tuple`
<FromGitter>
<citizen428> any tips appreciated
<FromGitter>
<iDev0urer> @citizen428 mind posting a code sample?
<FromGitter>
<citizen428> @iDev0urer an isolated example is hard to come up with... this is the project i'm working on, basically the first thing i ever really wrote in crystal: https://github.com/citizen428/protocols
<FromGitter>
<citizen428> the problem is that the macro forms with `for:` arguments right now only work for classes
<FromGitter>
<citizen428> when i do something like `defimpl Blank, for: Array...` it works, cause in the macro body i reopen `Array` with `class Array`
<FromGitter>
<citizen428> but for e.g. `Tuple` it will fail, since i'd need to reopen with `struct Tuple`, not `class Tuple`
<FromGitter>
<iDev0urer> Hmm I'm not sure, macros aren't my strong suit
<FromGitter>
<citizen428> sorry if what i wrote is confusing, i didn't sleep much
<FromGitter>
<iDev0urer> I'll keep looking into it because I do need to get better with macros
<FromGitter>
<citizen428> cheers
<FromGitter>
<citizen428> SO question is here in case anyone is looking for rep ;)
<FromGitter>
<iDev0urer> Really interesting library @citizen428 , I need to look into elixir more
<FromGitter>
<iDev0urer> I almost feel like those macros belong in Crystal's core
onethirtyfive has joined #crystal-lang
<FromGitter>
<iDev0urer> @here So is there not currently a way to figure out if something is a Class or a Struct?
<FromGitter>
<cjgajard> @citizen428 {% if Reference.all_subclasses.includes?(klass.resolve) %}
<FromGitter>
<citizen428> @cjgajard thanks for that, i'll try it out later :)
<FromGitter>
<citizen428> @iDev0urer glad you like it. i'm not sure about core, but even then a fully working PoC would be needed as basis for discussion
<FromGitter>
<iDev0urer> @cjgajard where does the `all_subclasses` method come from? I'm not seeing it in the `Reference` docs