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
taupiqueur has joined #crystal-lang
Chillfox has joined #crystal-lang
deavmi has joined #crystal-lang
ur5us has quit [Ping timeout: 245 seconds]
<postmodern> is there a way to use keyword arguments with macro methods?
<FromGitter> <Blacksmoke16> just like you would with a method
taupiqueur has quit [Ping timeout: 252 seconds]
<postmodern> ah i see, you can pass in a **kwargs and then pluck things out of it as needed
Volk has quit [Quit: See you next time!]
Peter0x44 has joined #crystal-lang
ur5us has joined #crystal-lang
postmodern has quit [Read error: Connection reset by peer]
Guest70931 has joined #crystal-lang
mookie has quit [Ping timeout: 260 seconds]
oz has quit [Remote host closed the connection]
ox has joined #crystal-lang
deavmi has quit [Ping timeout: 252 seconds]
deavmi has joined #crystal-lang
ur5us has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
deavmi_ has joined #crystal-lang
deavmi has quit [Ping timeout: 252 seconds]
hightower2 has joined #crystal-lang
deavmi_ has quit [Ping timeout: 245 seconds]
deavmi has joined #crystal-lang
deavmi_ has joined #crystal-lang
deavmi has quit [Ping timeout: 245 seconds]
Peter0x44 has quit [*.net *.split]
Liothen has quit [*.net *.split]
pixel has quit [*.net *.split]
xybre has quit [*.net *.split]
xybre has joined #crystal-lang
Peter0x44 has joined #crystal-lang
pixel has joined #crystal-lang
Liothen has joined #crystal-lang
deavmi_ has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
Chillfox has quit [Quit: Leaving]
deavmi has quit [Ping timeout: 245 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
notzmv has quit [Ping timeout: 245 seconds]
ur5us has joined #crystal-lang
notzmv has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 268 seconds]
deavmi has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
taupiqueur has joined #crystal-lang
Elouin has quit [Ping timeout: 246 seconds]
Elouin has joined #crystal-lang
Volk has joined #crystal-lang
Volk has joined #crystal-lang
Volk has quit [Changing host]
<FromGitter> <Blacksmoke16> postmodern: Yea dealing with arguments is a pita ha.
<FromGitter> <Blacksmoke16> Revisited how i handle it last night and trying to figure out a good balance between type safety and the implementation
taupiqueur has quit [Quit: taupiqueur]
taupiqueur has joined #crystal-lang
hightower2 has quit [Ping timeout: 265 seconds]
Elouin has quit [Quit: Ping timeout (120 seconds)]
Elouin has joined #crystal-lang
ox is now known as oz
Volk has quit [Quit: See you next time!]
taupiqueur has quit [Ping timeout: 252 seconds]
hightower2 has joined #crystal-lang
notzmv has quit [Ping timeout: 260 seconds]
hightower2 has quit [Ping timeout: 252 seconds]
<FromGitter> <DRVTiny> Hello4All! ⏎ How to initialize some instance variables inside class macro? ⏎ For example: https://play.crystal-lang.org/#/r/c143 ⏎ It does not work :( [https://gitter.im/crystal-lang/crystal?at=6165b7af29ddcd02931b4bb4]
<FromGitter> <DRVTiny> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=6165b7cefb3dcd4e8821d8c8]
<FromGitter> <Blacksmoke16> why use the macro in the first place tho?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/c149 would do what you want tho
<FromGitter> <DRVTiny> @Blacksmoke16 , thank you!!
wmoxam has quit [Ping timeout: 265 seconds]
wmoxam has joined #crystal-lang
hightower2 has joined #crystal-lang
hightower2 has quit [Ping timeout: 265 seconds]
taupiqueur has joined #crystal-lang
notzmv has joined #crystal-lang
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 245 seconds]
ur5us has joined #crystal-lang
<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> <jemc> Here's a minimal example illustrating what I'm trying to do: https://play.crystal-lang.org/#/r/c173
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/c178 bit of a hack but it works
<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> https://play.crystal-lang.org/#/r/c17e
<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.
<FromGitter> <jwaldrip:matrix.org> ``````
<FromGitter> <jwaldrip:matrix.org> ```context.response.puts "gotcha!"``````
<FromGitter> <jwaldrip:matrix.org> How do I prevent "gotcha" being printed to the console if the client disconnects?
<FromGitter> <Blacksmoke16> im coming up blank
<FromGitter> <Blacksmoke16> actually sec
<FromGitter> <Blacksmoke16> does `context.response.closed?` work?
<FromGitter> <Blacksmoke16> i would assume no because it wouldn't actually be closed yet
<FromGitter> <Blacksmoke16> is there a reason you dont want the request to finish?
<FromGitter> <jwaldrip:matrix.org> its expensive
<FromGitter> <jwaldrip:matrix.org> from a resource standpoint
<FromGitter> <Blacksmoke16> from what googling i did this isn't something you can do on Symfony or Rails either
<FromGitter> <Blacksmoke16> as the server has know way of knowing
<FromGitter> <oprypin:matrix.org> yea i think that's how sockets work... you try to write to it, wait 10 seconds, then realize oh it's closed
<yxhuvud> should be fast if it was actually closed. But if dropped without closing, then it would time out
<FromGitter> <jwaldrip:matrix.org> bummer
<FromGitter> <Blacksmoke16> something related to the gc upgrade?
<FromGitter> <Blacksmoke16> can't reproduce it via docker locally tho
taupiqueur has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> nvm, had cached older nightly image. it deff reproduces
<FromGitter> <Blacksmoke16> ill create an issue