<FromGitter>
<jemc> Within a macro that I am using as a DSL to define methods within a class, is there a way I can tell statically how many times the macro has been invoked so far in that class, and thus associate each defined method to a static "index"? ⏎ ⏎ I imagine that to do so, the macro would need to have access to some mutable state in which to put a counter at compile time during macro expansion, but I'm not sure such a
<FromGitter>
... state exists - is there some way to use class variables that could make this work?
<FromGitter>
<Blacksmoke16> alternative solution tho: sec
<FromGitter>
<jemc> Ah, interesting. I didn't know macros could use mutable constants from the scope like that. That's certainly helpful both for this and for some other things I'm trying to do with this DSL
<FromGitter>
<jemc> (I will wait to see your other suggestion though)
<FromGitter>
<Blacksmoke16> could apply same concept to annotation applied to specific ivars/methods or something
<FromGitter>
<Blacksmoke16> depends on how you want the API to be
<FromGitter>
<jemc> Thanks for the alternative. I haven't dealt much with annotations so I'll have to take a deeper look at the capabilities of annotations and compare
<FromGitter>
<Blacksmoke16> np, as i said, not sure it'll work out as it'll depend on what all you need to do
<FromGitter>
<Blacksmoke16> but worth at least looking into
<FromGitter>
<jwaldrip:matrix.org> Is there anyway to detect a client closing the HTTP connection so that I can stop the server from processing the request
<FromGitter>
<jemc> Yeah, definitely. ⏎ I have been using Crystal for years and this is my first time reaching deeply into either macros or annotations. But I'm wrapping C code that heavily relies on C macros, so it seemed appropriate 😉
<FromGitter>
<jwaldrip:matrix.org> The following will still put "gotcha" after 30 seconds even if the socket was closed.