jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.14.1 | 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
marcosdsanchez has quit [Quit: leaving]
marcosdsanchez has joined #crystal-lang
marcosdsanchez has quit [Client Quit]
marcosdsanchez has joined #crystal-lang
marcosdsanchez has quit [Client Quit]
Philpax has quit [Ping timeout: 246 seconds]
bcardiff has quit [Quit: bcardiff]
tony_ has quit [Ping timeout: 260 seconds]
krtv` has joined #crystal-lang
elia has quit [Quit: Computer has gone to sleep.]
umurgdk has quit []
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
pawnbox has quit [Ping timeout: 248 seconds]
ragmaanir_ has joined #crystal-lang
ragmaanir has quit [Ping timeout: 244 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
krtv` has quit [Ping timeout: 244 seconds]
triangles has joined #crystal-lang
bjz has joined #crystal-lang
ragmaanir__ has joined #crystal-lang
A124 has quit [Read error: Connection reset by peer]
ragmaanir_ has quit [Ping timeout: 260 seconds]
A124 has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
greengriminal has joined #crystal-lang
zeno_ has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
zeno_ has quit [Quit: 离开]
pawnbox has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 246 seconds]
pawnbox has quit [Ping timeout: 276 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Client Quit]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Client Quit]
greengriminal has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
kfpratt has joined #crystal-lang
bjz_ has quit [Ping timeout: 268 seconds]
zeno_ has joined #crystal-lang
bjz has joined #crystal-lang
<crystal-gh> [crystal] bcardiff pushed 2 new commits to master: https://git.io/vVJ9M
<crystal-gh> crystal/master 5aacda1 Brian J. Cardiff: add playground to the etc/completion files
<crystal-gh> crystal/master c3513cd Brian J. Cardiff: Merge pull request #2372 from bcardiff/feature/play-completion...
<travis-ci> crystal-lang/crystal#c3513cd (master - Merge pull request #2372 from bcardiff/feature/play-completion): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/118914158
<travis-ci> bcardiff/crystal#c3513cd (master - Merge pull request #2372 from bcardiff/feature/play-completion): The build passed. https://travis-ci.org/bcardiff/crystal/builds/118914258
kfpratt has quit [Remote host closed the connection]
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 244 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
zeno_ has quit [Remote host closed the connection]
zeno_ has joined #crystal-lang
rok has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
rok has quit [Quit: rok]
Philpax has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
jhass has quit [Ping timeout: 260 seconds]
jhass has joined #crystal-lang
trapped has joined #crystal-lang
zeno_ has quit [Quit: 离开]
<BlaXpirit> Can I have library-wide protected utility macros?
<RX14> just put the macros under a namespace?
<RX14> i mean
<RX14> modulwe
<RX14> s/w//
<BlaXpirit> RX14, I don't want them to be accessible from outside
<RX14> well
<RX14> there's not much you can do apart from hide them well
<RX14> or use file private macros
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
umurgdk has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
mgarciaisaia has joined #crystal-lang
ponga has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
pawnbox has joined #crystal-lang
marcosdsanchez has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Rinkana has joined #crystal-lang
kfpratt has joined #crystal-lang
<Rinkana> I can't seem to find a function that removes empty values from an array. Do i need to map it myself?
<RX14> by emty values you mean nil?
<Rinkana> No, also empty strings
x0f has quit [Ping timeout: 244 seconds]
<RX14> you wat Array#reject
<RX14> >>["test", "", "bar"].reject { |it| it == "" }
<DeBot> RX14: Syntax error in expanded macro: __wrap_last_expression:13: expecting any of these tokens: IDENT, +, -, *, /, %, |, &, ^, **, <<, <, <=, ==, !=, =~, !~, >>, >, >=, <=>, ||, &&, ===, [], []=, []?, [, ! (not '=') - https://carc.in/#/r/ven
<RX14> >> ["test", "", "bar"].reject { |it| it == "" }
<DeBot> RX14: Syntax error in expanded macro: __wrap_last_expression:13: expecting any of these tokens: IDENT, +, -, *, /, %, |, &, ^, **, <<, <, <=, ==, !=, =~, !~, >>, >, >=, <=>, ||, &&, ===, [], []=, []?, [, ! (not '=') - https://carc.in/#/r/veo
<RX14> bollocks
<RX14> Rinkana, https://carc.in/#/r/vep
<RX14> >> true == true
<DeBot> RX14: Failed to run your code, sorry! - https://carc.in/#/r/veq
<Rinkana> Great, it works! Thanks.
<RX14> >> 1.times { true == true }
<DeBot> RX14: # => 1 - https://carc.in/#/r/ver
<RX14> huh
<RX14> why didn't that work
zeno_ has joined #crystal-lang
zeno_ has quit [Client Quit]
<BlaXpirit> RX14, it just failed momentarily
<RX14> no
<RX14> it's the same error twice
<RX14> look at the error
<BlaXpirit> well the true==true one
<RX14> it's something to do with that ==
<BlaXpirit> macros are weird
<BlaXpirit> today I had Module.macro(asdf) replaced with Module macro asdf in nested macros
<BlaXpirit> impossible to reproduce, of course..
<RX14> hmn
<RX14> i think there's something wrong with |it| it == something else being parsed
<RX14> Syntax error in expanded macro: __wrap_last_expression:13: expecting any of these tokens: IDENT, +, -, *, /, %, |, &, ^, **, <<, <, <=, ==, !=, =~, !~, >>, >, >=, <=>, ||, &&, ===, [], []=, []?, [, ! (not '=')
<RX14> ["test", "", "bar"].reject(&.= = "")
<RX14> see how it does &.= = ""
<BlaXpirit> yes
<RX14> >> ["aaa"].map { |it| it == "" }
<DeBot> RX14: Syntax error in expanded macro: __wrap_last_expression:13: expecting any of these tokens: IDENT, +, -, *, /, %, |, &, ^, **, <<, <, <=, ==, !=, =~, !~, >>, >, >=, <=>, ||, &&, ===, [], []=, []?, [, ! (not '=') - https://carc.in/#/r/vey
<RX14> yep
<RX14> only on the debot macro tho
<BlaXpirit> RX14, https://carc.in/#/r/vf0
<RX14> uhu
<RX14> bug report it
<BlaXpirit> no u
<BlaXpirit> this is NOT a regression btw
<RX14> ?
<RX14> you mean it always does that?
<BlaXpirit> RX14, tried to run it in a few different versions of crystal, this always happened
<RX14> no u report it
<RX14> i'm lazy
<BlaXpirit> as u wish
<BlaXpirit> but you should know that i'm even lazier
rolha has joined #crystal-lang
<Rinkana> New bug report: See IRC chat
<rolha> hi everyone
<rolha> I'm trying to set a virtual attribute in a class class Foo ; def row=(r : Int32, v : Vector)
<rolha> so that I can do f = Foo.new ; f.row(1) = aVector
<rolha> but I keep getting 'unexpected token: ='
<rolha> is something wrong with this syntax?
<RX14> I don't think you can do that... can you do that in ruby?
<rolha> I think so, but I'm not sure!
<BlaXpirit> rolha, no way...
<rolha> is there anyway to do something similar in Crystal?
<BlaXpirit> rolha, make a proxy class Rows
<BlaXpirit> f.rows[1] = aVector
<BlaXpirit> def rows; RowsProxy.new(self); end
<rolha> BlaXpirit: thanks! I'll try it
<BlaXpirit> class RowsProxy; def []=(r : Int32, v : Vector) eh u get the idea
<rolha> BlaXpirit: yeah, thanks!
tony_ has joined #crystal-lang
rolha_ has joined #crystal-lang
rolha has quit [Ping timeout: 244 seconds]
<rolha_> ok, that works fine. Thanks for the help
rolha_ has quit [Remote host closed the connection]
rolha has joined #crystal-lang
splattael has joined #crystal-lang
tony_ has quit [Ping timeout: 248 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
<BlaXpirit> how can I get a TypeNode for a type?
<BlaXpirit> I'm trying to use TypeNode#union_types https://github.com/crystal-lang/crystal/blob/5bcf6d5/docs/macros.cr#L1127
ragmaanir__ has quit [Quit: Leaving]
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tony_ has joined #crystal-lang
rolha has joined #crystal-lang
Ven has joined #crystal-lang
Philpax has quit [Ping timeout: 248 seconds]
ponga has quit []
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
ozra has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
splattael has quit [Quit: Connection closed for inactivity]
mgarciaisaia1 has joined #crystal-lang
mgarciaisaia1 has left #crystal-lang [#crystal-lang]
DylanJ has quit [Ping timeout: 276 seconds]
<crystal-gh> [crystal] arktisklada opened pull request #2380: Improving Deque#delete (master...improving-deque-delete) https://git.io/vVT8Z
rolha has quit [Remote host closed the connection]
rolha has joined #crystal-lang
dome22xl has joined #crystal-lang
Ven has joined #crystal-lang
<BlaXpirit> >> case Bool; when Bool; p ":)"; end
<DeBot> BlaXpirit: # => nil - https://carc.in/#/r/vg9
<BlaXpirit> :(
<BlaXpirit> this sucks so bad
<yxhuvud> >> case true; when Bool; p ":)"; end
<DeBot> yxhuvud: ":)" - more at https://carc.in/#/r/vga
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh> [crystal] arktisklada opened pull request #2381: Improving Enumerable#in_groups_of (master...reducing-enumerable-in-groups-of) https://git.io/vVTaG
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<BlaXpirit> brace yourself, i'm about to drop the funniest joke
<BlaXpirit> >> class Class; end; class S < Class; end
<DeBot> BlaXpirit: Class is not a class, it's a class - https://carc.in/#/r/vgb
<pawnbox> BlaXpirit: wtf.
rolha has joined #crystal-lang
marcosdsanchez has quit [Quit: leaving]
marcosdsanchez has joined #crystal-lang
luislavena has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
<BlaXpirit> jhass, check out my suggestion for the bot. Instead of wrapping code in a macro, parse the code right away and wrap the last expression properly. Also the code is expanded from one line to be more readable (though it's not always perfect) https://gist.github.com/8b1c593b3782f10d6a71
dsounded has joined #crystal-lang
tomchapin has joined #crystal-lang
<BlaXpirit> I'd make a pull request right away but there are multiple problems to be considered. this makes the transforming program itself require crystal, and if syntax changes the old versions of crystal wouldn't match it. and not sure if it's best put into carc.in or debot
<dsounded> hi everyone, could you check this https://github.com/crystal-lang/crystal/issues/2379 out, please ?
<luislavena> dsounded: left you another comment, seems your /opt/crystal is old?
<dsounded> yeah
<dsounded> Still doesn't work :(
<dsounded> it works perfect on my Mac, but doesn't work on Ubuntu :(
<luislavena> dsounded: can you please show the entire output of your build command? also include the code you're trying to compile?
<luislavena> and run the build with --verbose, so we see the commands being executed.
dtakahas has joined #crystal-lang
<luislavena> use a Gist and share the output :)
<BlaXpirit> dsounded, to make sure, please remove llvm-3.6 and install llvm-3.5
tomchapin has quit [Client Quit]
<BlaXpirit> I know that crystal for ubuntu is built with 3.5
<luislavena> BlaXpirit: works without issue on my installation, llvm-3.6, so that doesn't seems the problem
<luislavena> dsounded: what `dpkg -l crystal` shows on your end?
<dsounded> command: crystal build --verbose src/project_name.cr
<dsounded> it shows: crystal 0.14.2-1 amd64 The full stack of crystal
<dsounded> Also it shows this: Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
<BlaXpirit> >> case Bool.class; when Bool; p ":)"; end
<DeBot> BlaXpirit: # => nil - https://carc.in/#/r/vgv
<BlaXpirit> >> case Bool; when Bool.class; p ":)"; end
<DeBot> BlaXpirit: ":)" - more at https://carc.in/#/r/vgy
dtakahas has quit [Ping timeout: 250 seconds]
dsounded_ has joined #crystal-lang
dsounded has quit [Ping timeout: 250 seconds]
mgarciaisaia has joined #crystal-lang
dsounded_ has quit [Client Quit]
dome22xl has quit [Read error: Connection reset by peer]
dtakahas has joined #crystal-lang
emancu has quit []
<dtakahas> Hi all - I'm writing my first crystal script here and I'm running into some kind of DNS error (?). Maybe I'm missing a lib. Here's the gist if anyone is able to take a look: https://gist.github.com/dtakahas/78f1cbd8cdc7714d9c62
<BlaXpirit> dtakahas, works here. have u tried without https?
<dtakahas> trying
<dtakahas> Huh even without ssl it's still saying 'getaddrinfo: nodename nor servname provided, or not known (Socket::Error)'. Something with my network maybe? Thanks for trying!
<RX14> dtakahas, what SO?
<RX14> OS*
<RX14> can you install dig and try and use it to lookup the same hostname
ragmaanir has joined #crystal-lang
<BlaXpirit> >> LibC.getaddrinfo("google.com", nil, nil, out result); p result.value.addr.value
<DeBot> BlaXpirit: Failed to run your code, sorry! - https://carc.in/#/r/vhu
pawnbox has joined #crystal-lang
<dtakahas> OSX
pawnbox has quit [Ping timeout: 260 seconds]
<dtakahas> dig is successful
<dtakahas> commented on gist with dig trace
mgarciaisaia has left #crystal-lang [#crystal-lang]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> huh
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
rolha has joined #crystal-lang
Rinkana has quit [Ping timeout: 250 seconds]
pawnbox has quit [Ping timeout: 246 seconds]
rolha has quit [Remote host closed the connection]
rolha has joined #crystal-lang
tony_ has quit [Ping timeout: 248 seconds]
Philpax has joined #crystal-lang
pawnbox has joined #crystal-lang
dtakahas has quit [Ping timeout: 250 seconds]
pawnbox has quit [Ping timeout: 276 seconds]
dtakahas has joined #crystal-lang
<luislavena> dtakahas: behind a proxy?
trapped has quit [Read error: Connection reset by peer]
<luislavena> dtakahas: actually, the problem is "https://www.google.com", HTTP::Client.new is expecting host, port, ssl option, not an URI, port
<RX14> luislavena, i think he said he tried it without the htpps
<luislavena> dtakahas: if you remove the protocol from the host, it should work: http://crystal-lang.org/api/HTTP/Client.html#new%28host%2Cport%3D%3Cspanclass%3D%22n%22%3Enil%3C%2Fspan%3E%2Cssl%3D%3Cspanclass%3D%22n%22%3Efalse%3C%2Fspan%3E%2C%26block%29-class-method
<luislavena> RX14: I tried his code and it failed the same way, looked at the docs, removed the https:// part of the host, and it worked.
<RX14> huh
<BlaXpirit> https://carc.in/#/r/viq so I'm using macro included as a hack to get access to a TypeNode. is there any way to do it without the hack? commented out code doesn't work
Philpax has quit [Ping timeout: 248 seconds]
dome22xl has joined #crystal-lang
<RX14> huh
<RX14> maybe it's carc.in
<RX14> actually
<RX14> it might stub http
<RX14> ahh
sp4rrow has joined #crystal-lang
<BlaXpirit> no but seriously.. I'm going crazy here
<BlaXpirit> is macro included really the only way to simulate a macro argument that is a type?
<RX14> well
<RX14> it might happen before the phase where types are determined like that
<ragmaanir> "If the constant denotes a type, you get back a TypeNode"
<ragmaanir> not tested it
<BlaXpirit> ragmaanir, ok but see my code
<BlaXpirit> I want to reuse the macro for different types (known at compile time), and this requires you to have an exact type hardcoded in a macro
<BlaXpirit> i mean "include Constants(E)" sounds even cooler than a macro but mhm
<ragmaanir> hm, i have to think this through .. macros are a little weired IMO
<BlaXpirit> they sure are
<ragmaanir> i am also thinking about how to redesign macros, because at the moment they are more like code templates, so when you write macros with logic, it gets really ugly
<BlaXpirit> well sure... best would be to just interpret crystal code at compile time
<BlaXpirit> "just"
<ragmaanir> yeah
<BlaXpirit> but for now i got an idea brewing
<ragmaanir> thats kinda what i want to propose, but im pretty sure there are some caveats, especially with typing etc
pawnbox has joined #crystal-lang
<BlaXpirit> (idea totally stolen from Nim)
<BlaXpirit> have 2 kinds of macro arguments: expression (which is currently the only one) and a constant
<ragmaanir> btw you can pass code via the run call from a macro to a crystal file which runs arbitraty crystal code, but then you loose the AST information :-/
<ragmaanir> yeah, i also though of 2 types of parameters for macros. you probably even could put type restrictions on the expression parameters, so e.g. you macro is only applicable to tuple literals or so.
<BlaXpirit> RX14, it's the AST of the expression "E"
<BlaXpirit> and I want TypeNode E
<RX14> well
<RX14> i don't think thats really possible
<RX14> because of the stange where macros run at
umurgdk has quit []
pawnbox has quit [Ping timeout: 240 seconds]
<ragmaanir> it would be ideal if macros had full access to type information. not sure though if that is possible in general.
<BlaXpirit> ragmaanir, uh sure, TypeNode is a thing
<BlaXpirit> but can get only the type of the class/module that you're inside
<ragmaanir> but i think you cant do {% x = typeof(y) %}
<BlaXpirit> can't execute TypeOf in a macro
<ragmaanir> yeah
dome22xl has quit [Read error: Connection reset by peer]
<ragmaanir> maybe one can get around that by generating hidden constants and then refer to the constant in another macro? TYPEOF_X = typeof(x)
<BlaXpirit> well one thing is for the first time in my life I had a thought for a moment that I finally understand these macros
<BlaXpirit> ragmaanir, problem is you still have just one constant and it can't be parametrized
<BlaXpirit> you can, however, have a mapping inside a macro
<ragmaanir> "TYPEOF_#{name} = typeof(#{whatever})"
<BlaXpirit> lol
<BlaXpirit> macro(1) if n==1 - Type1 if n==2 - Type2
<ragmaanir> here is a funny gist btw: https://gist.github.com/Ragmaanir/e58c4092486bc15e81f7
<BlaXpirit> can't be funnier than
<BlaXpirit> >> class S < Class
<DeBot> BlaXpirit: Syntax error in eval:22: expecting identifier 'end', not 'EOF' - https://carc.in/#/r/vix
<BlaXpirit> >> class S < Class; end
<DeBot> BlaXpirit: Class is not a class, it's a class - https://carc.in/#/r/viy
<ragmaanir> what it does is: it converts the macro input parameters to strings and the block to a method. then it passes these to the run-call. the eval macro then executes the passed method on the passed parametes. the output that is generated via puts is then the output of the macro.
<ragmaanir> so basically in the block you can write what to do with the macro parameters, and you can write regular crystal code.
<ragmaanir> sadly all the AST information gets lost.
<ragmaanir> and here is another macro for flattening a tuple: https://gist.github.com/Ragmaanir/2a8f292bf3d76b2f0ee2
luislavena has quit [Quit: Leaving]
<ragmaanir> IMO: macros should be regular crystal code, and when you want to generate stuff you can either generate a string which the macro returns, or you can build AST nodes, which are returned.
<BlaXpirit> flattening tuple? now that's something I can get behind
<BlaXpirit> ragmaanir, are you coming from Nim?
<ragmaanir> no, from ruby and scala.
<BlaXpirit> the thing is, Nim's macros are what we're describing here
<ragmaanir> oh, k. then i gonna have a look at those, thanks.
<BlaXpirit> but don't get too excited, cuz I left Nim for Crystal
<ragmaanir> ^^
<ragmaanir> i only wanna steal the macros ;-)
zodiak has joined #crystal-lang
<ragmaanir> i left ruby and scala for crystal
<ragmaanir> and did not look deeply into rust, d and go, because crytal is all i need.
<BlaXpirit> ragmaanir, https://carc.in/#/r/vj6
<ragmaanir> good point
<BlaXpirit> I don't know anything about LLVM but seriously it already allows to interpret the code
<BlaXpirit> replace macros with compile code execution and make a special literal to make literals
<dtakahas> Ah so it works with just the host - thanks for posting that gist. This unblocks me =)
pawnbox has joined #crystal-lang
<BlaXpirit> beats me why visibility modifiers are limited to methods
<BlaXpirit> protected module, macro would be so useful
<BlaXpirit> like why would I want a macro either limited to 1 file or visible absolutely everywhere
dtakahas has quit [Quit: Page closed]
pawnbox has quit [Ping timeout: 248 seconds]
Philpax has joined #crystal-lang
Philpax has quit [Ping timeout: 276 seconds]
tony_ has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
elia has joined #crystal-lang
tony_ has quit [Ping timeout: 244 seconds]
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
rolha has quit [Quit: Textual IRC Client: www.textualapp.com]
Philpax has joined #crystal-lang
ozra_ has joined #crystal-lang
marcosdsanchez has quit [Read error: Connection reset by peer]
marcosdsanchez has joined #crystal-lang
ozra has quit [Ping timeout: 246 seconds]
sp4rrow has joined #crystal-lang