ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.19.4 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
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
<FromGitter> <iDev0urer> Ahh ok, thanks1
<FromGitter> <citizen428> @cjgajard you're my hero!
<FromGitter> <citizen428> thanks a lot!
<FromGitter> <citizen428> now all i need to do is write some actual specs, then i can figure out a way to remove code duplication
idev0urer has joined #crystal-lang
<idev0urer> Finally logging in from IRC. Oh how I missed you
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
onethirtyfive has quit [Ping timeout: 250 seconds]
idev0urer has quit [Quit: Konversation terminated!]
idev0urer has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
onethirtyfive has joined #crystal-lang
snsei_ has quit [Remote host closed the connection]
CompanionCube has quit [Ping timeout: 258 seconds]
CompanionCube has joined #crystal-lang
bjz has quit [Ping timeout: 250 seconds]
bjz has joined #crystal-lang
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
Philpax_ has quit [Ping timeout: 260 seconds]
Philpax_ has joined #crystal-lang
vikaton has quit [Quit: Connection closed for inactivity]
idev0urer has quit [Ping timeout: 244 seconds]
bazaar has quit [Quit: leaving]
bazaar has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Remote host closed the connection]
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
Nilq has joined #crystal-lang
<Nilq> Good day, everyone
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
<FromGitter> <sdogruyol> hey
<Nilq> Anyone know how one would approach 'url-matching' with sockets using Kemal?
<FromGitter> <sdogruyol> can you be more specific
<Nilq> I'm trying to do womething like this: http://hastebin.com/izonemuyel.cr
<FromGitter> <sdogruyol> ah that's not possible
<FromGitter> <sdogruyol> use query params instead
<FromGitter> <sdogruyol> /rooms?id=252
<Nilq> Ah, yes
<Nilq> How would that look? - can't find the API nor an example of the function structure ... :)
soveran has quit [Remote host closed the connection]
<FromGitter> <sdogruyol> ws "/rooms" do |socket, env| ⏎ room_id = env.params.query["id"]?.as(Int32) ⏎ socket.on_message do |m| ⏎ puts "Yo" ⏎ end ... [https://gitter.im/crystal-lang/crystal?at=581473ce7b15d16e55bf4162]
<Nilq> Right; thanks a lot - thanks for making Kemal ^^
soveran has joined #crystal-lang
Nilq has quit [Quit: Page closed]
soveran has quit [Remote host closed the connection]
pawnbox_ has quit [Read error: Connection reset by peer]
soveran has joined #crystal-lang
pawnbox has joined #crystal-lang
<FromGitter> <sdogruyol> @nilq thanks :)
soveran has quit [Remote host closed the connection]
ponga has joined #crystal-lang
rafadc has joined #crystal-lang
dhk has joined #crystal-lang
rafadc_ has joined #crystal-lang
rafadc_ has quit [Remote host closed the connection]
rafadc has quit [Ping timeout: 244 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
zotherstupidguy has joined #crystal-lang
<crystal-gh> [crystal] igneus opened pull request #3482: reference HTML parsing features elsewhere (master...html_parsing_doc) https://git.io/vXLO1
<FromGitter> <zatherz> ```icr(0.19.4) > {"abc" => 3}.key?("abc") ⏎ => nil``` [https://gitter.im/crystal-lang/crystal?at=5814b4bf8ed1c0ff5c3ffc5f]
<FromGitter> <zatherz> wat
pawnbox has joined #crystal-lang
<FromGitter> <zatherz> oooooh
<FromGitter> <zatherz> apparently Crystal's `key?` is completely different from Ruby's `key?` on hashes
<FromGitter> <zatherz> in Ruby, it returns if the key exists
<FromGitter> <zatherz> in Crystal, it returns the key of the value in the argument or `nil` if none
<Papierkorb> zatherz, see Hash#has_key?
<FromGitter> <zatherz> has_key? is the proper way, yeah
Philpax_ has quit [Ping timeout: 260 seconds]
dhk has quit [Quit: Leaving]
<crystal-gh> [crystal] RX14 opened pull request #3483: Feature/ips iteration time (master...feature/ips-iteration-time) https://git.io/vXLck
idev0urer has joined #crystal-lang
snsei has joined #crystal-lang
mhib has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
idev0urer has quit [Quit: Konversation terminated!]
idev0urer has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<RX14> there's no way to go from an array of chars to a string...
mhib has quit [Quit: Leaving]
mhib has joined #crystal-lang
<FromGitter> <sdogruyol> what' the use case for that?
<FromGitter> <sdogruyol> if you want to convert into String anyway why just make it String from the start
<RX14> because it's much easier to parse as an array(char)
<RX14> because you don't have the indexing penalty if you get multibyte characters
<FromGitter> <sdogruyol> hmm
bjz has joined #crystal-lang
<BlaXpirit> >> ['a', 'b', 'c'].join
<BlaXpirit> RX14, ?
<FromGitter> <iDev0urer> @BlaXpirit beat me to it
<RX14> oh wow that must be really slow
<BlaXpirit> probably
<pabs> there's a faster way, but it's more verbose:
<pabs> CHARS = ['a', 's', 'd', 'f']
<pabs> s = String.build { |b| CHARS.each { |c| c.to_s(b } }
<pabs> err
<pabs> s = String.build { |b| CHARS.each { |c| c.to_s(b) } }
<BlaXpirit> good job, was gonna say that
<RX14> actually, looking at the join code
A124 has quit [Quit: '']
<RX14> it probablky compiles down to that
<BlaXpirit> :)
<RX14> would be interesting if io << "" gets optimized out
<RX14> but i doubt it
A124 has joined #crystal-lang
idev0urer has quit [Ping timeout: 250 seconds]
<pabs> RX14: join(nil) should do nothing, io << nil will get converted to nil.to_s(io), which does nothing: https://github.com/crystal-lang/crystal/blob/7f82f79bd1e3a7a1a73607e35c0662906736f1f8/src/nil.cr#L81
<RX14> good call
ponga has quit [Quit: Connection closed for inactivity]
Raimondi has quit [Write error: Broken pipe]
matp has quit [Excess Flood]
mhib has quit [Quit: Leaving]
Raimondi has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vXLwm
<crystal-gh> crystal/master 53ff340 Ary Borenszweig: Compiler: fixed incorrect binding for Require node. Fixes #3481
daekano has quit [Ping timeout: 245 seconds]
daekano has joined #crystal-lang
<travis-ci> crystal-lang/crystal#53ff340 (master - Compiler: fixed incorrect binding for Require node. Fixes #3481): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/171684880
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
<FromGitter> <askn> hello
<FromGitter> <askn> https://carc.in/#/r/1czo
idev0urer has joined #crystal-lang
<FromGitter> <askn> how i can define the records variable
<FromGitter> <iDev0urer> @askn you are attempting to use a class variable in a module
<FromGitter> <askn> if the instance variable is used, i get an error message
<FromGitter> <askn> @instance_vars are not yet allowed in metaclasses: use @@class_vars instead