jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.12.0 | 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
mondok has quit [Ping timeout: 240 seconds]
Philpax has joined #crystal-lang
pawnbox has joined #crystal-lang
JX7P has joined #crystal-lang
<JX7P> is it not true that Crystal uses message despatch?
pawnbox has quit [Ping timeout: 248 seconds]
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 268 seconds]
fka has joined #crystal-lang
A124 has quit [Quit: '']
fka has quit [Ping timeout: 244 seconds]
A124 has joined #crystal-lang
sp4rrow has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
bcardiff has quit [Ping timeout: 248 seconds]
pawnbox has joined #crystal-lang
Philpax has quit [Ping timeout: 244 seconds]
pawnbox has quit [Ping timeout: 244 seconds]
Philpax has joined #crystal-lang
fka has joined #crystal-lang
fka has quit [Ping timeout: 240 seconds]
Philpax has quit [Ping timeout: 260 seconds]
A124 has quit [Read error: Connection reset by peer]
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
A124 has joined #crystal-lang
pawnbox has joined #crystal-lang
fka has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
fka has quit [Ping timeout: 244 seconds]
bcardiff has joined #crystal-lang
Guest121 is now known as cyrus
cyrus is now known as Cyrus
Cyrus has joined #crystal-lang
Cyrus has quit [Changing host]
pawnbox has joined #crystal-lang
Philpax has joined #crystal-lang
zeno_ has joined #crystal-lang
<zeno_> Hey guys, how to use nest recursion in Crystal?
<zeno_> In Ruby, I can do this: def foo(x)
<zeno_> if x > 0
<zeno_> y = 5
<zeno_> def bar(y)
<zeno_> if y > 0
<zeno_> puts y
<zeno_> return bar(y-1)
<zeno_> end
<zeno_> end
<zeno_> bar(y)
<zeno_> return foo x-1
<zeno_> end
<zeno_> end
<zeno_> But seems Crystal does not allow a function run in another, must use proc, but proc is a lambda, it can not recursion
pawnbox has quit [Ping timeout: 264 seconds]
pawnbox has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
umurgdk has quit [Remote host closed the connection]
fka has joined #crystal-lang
fka has quit [Ping timeout: 244 seconds]
pawnbox has quit [Remote host closed the connection]
Philpax has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
Philpax has joined #crystal-lang
<Davy_CC> zeno_: this is a little bit tricky but works https://carc.in/#/r/tt1
<Davy_CC> but why you need to create an another function inside a function?
<Davy_CC> if you are inside a Class, you can define a private method for the recursive method `bar`, like this https://carc.in/#/r/tt2
umurgdk has joined #crystal-lang
<zeno_> I want to transform nested loop to tail recursion.
zeno_ has quit [Quit: 离开]
zeno_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
umurgdk has quit [Ping timeout: 244 seconds]
pawnbox has joined #crystal-lang
bjz has joined #crystal-lang
fka has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
fka has quit [Ping timeout: 260 seconds]
zeno_ has quit [Ping timeout: 248 seconds]
bjz has joined #crystal-lang
zeno_ has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 240 seconds]
zeno_ has quit [Ping timeout: 276 seconds]
zeno_ has joined #crystal-lang
zeno_ has quit [Read error: Connection reset by peer]
ponga has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
Philpax has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
fka_ has joined #crystal-lang
zeno_ has joined #crystal-lang
trapped has joined #crystal-lang
bjz has joined #crystal-lang
fka_ has quit [Read error: Connection reset by peer]
fka_ has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
bjz_ has quit [Ping timeout: 248 seconds]
trapped has joined #crystal-lang
umurgdk has joined #crystal-lang
<yxhuvvd> zeno: that ruby snippet probably doesn't do what you think it does.
<yxhuvvd> as foo and bar end up defined in the same scope. Meaning that you can do something.foo, followed by something.bar
umurgdk has quit [Ping timeout: 240 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<jhass> JX7P: it tries to solve as much as possible of the method dispatch at compile time, but there's a small runtime dispatch in case it's not possible
<jhass> zeno_: while Ruby allows you to nest method definitions, I'm quite certain it doesn't do what you think it does and is bad style there too
<jhass> oh, yxhuvvd already pointed out
trapped has quit [Read error: Connection reset by peer]
mondok has joined #crystal-lang
umurgdk has joined #crystal-lang
mondok has quit [Ping timeout: 268 seconds]
zeno__ has joined #crystal-lang
zeno__ has quit [Client Quit]
zeno_ has quit [Remote host closed the connection]
zeno_ has joined #crystal-lang
alsm has joined #crystal-lang
ready has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<zeno_> Ehhhhhhh, I wrote Python before, define a function in another means to create a closure in Python, maybe I have to change my thought.
<jhass> yes, does not happen in ruby and is just not valid in crystal
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<JX7P> is it not true that Crystal uses message despatch?
Philpax has joined #crystal-lang
<jhass> JX7P: see above?
nulpunkt has left #crystal-lang [#crystal-lang]
<JX7P> jhass, i cannot see anything above
<JX7P> luckily i found that IRC log thing and thank you, i have now the answers i sought
zeno_ has quit [Ping timeout: 264 seconds]
petercommand has joined #crystal-lang
Gasher has joined #crystal-lang
fka__ has joined #crystal-lang
fka_ has quit [Read error: Connection reset by peer]
Tophe has joined #crystal-lang
<Tophe> hi all, I need help to install chrystal. I am having trouble fetching the ppa key on ubuntu.
<Tophe> keyserver keys.gnupg.net --recv-keys 09617FD37CC06B54
<Tophe> gpg: requesting key 7CC06B54 from hkp server keys.gnupg.net
<Tophe> gpgkeys: HTTP fetch error 7: couldn't connect: eof
<Tophe> gpg: no valid OpenPGP data found.
buggs has joined #crystal-lang
<Tophe> and so I can't use the ppa
<jhass> Tophe: key.gnupg.net is a round-robin DNS based pool, maybe you got a bad server
<jhass> *keys
<jhass> either way for the TTL so you get another server or try another keyserver like pgp.mit.edu for example
<jhass> eh, wait
<Tophe> ho, I have found the problem
<JX7P> jhass, this dynamic dispatch
<Tophe> there is a compatibility issue with gpg v < 2.0
<JX7P> is it based on "lookup message some:message: in class of object X" or is it C++-like vTables
<Tophe> I have installed gnupg2 and then it work with
<Tophe> gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 09617FD37CC06B54
<Tophe> more on this here https://github.com/rvm/rvm/issues/3544
<jhass> JX7P: I'm not certain but I think it's neither but rather the compiler determines all candidates at compile time and generates a small if/else like dispatch among them
<jhass> Tophe: huh, don't you need to call apt-key?
<JX7P> how does this affect the ability to have objects respond to arbitrary messages?
Gasher has quit [Ping timeout: 276 seconds]
<JX7P> or even to change their responses at runtime, add new messages they may respond to, and so on
<jhass> there's no runtime reflection at all
<JX7P> oh no
<jhass> crystal rather focuses on a powerful macro system that's evaluated at compile time
<JX7P> that is a tragedy in the same league as MRI's parser.y
<jhass> just your opinion ;)
<JX7P> it is a tragedy
<JX7P> i will have to investigate techniques that might enable its re-addition
<JX7P> granted, it does somewhat interfere with full static safety (how much knowledge must the compiler have short of executing the programme to determine type errors with a highly reflective programme?)
<jhass> I actually quite like to have to design stuff without it
<jhass> often leads to faster and cleaner systems
<jhass> not only somewhat
<JX7P> it was what caused me to become ill of C++
<jhass> it heavily influences global type inference and physical object representation
<jhass> do have a look at the macro system
<JX7P> so much typing and tomfoolery, i just wanted to jump off a bridge, it was a tragedy. yes, i think the macro system will be interesting, thank you for your kind answers
brunto has joined #crystal-lang
<Tophe> so, it work on my computer (ubuntu 14.01) I have to do some manipulation to load the key, because of incompatibility issues.
<Tophe> apt-get install gnupg2
<Tophe> gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 09617FD37CC06B54
<Tophe> gpg2 --export -a 09617FD37CC06B54 > chystal.asc
<Tophe> apt-key add chystal.asc
Gasher has joined #crystal-lang
<jhass> pretty sure apt-key adv --keyserver keys.gnupg.net --recv-keys 09617FD37CC06B54 works on 14.01, I think you rather happened to hit a better server the second time
<BlaXpirit> what is 14.01
<BlaXpirit> Tophe, please clarify ubuntu version, this is not a valid one
<Tophe> sorry 14.04 (last lts)
trapped has joined #crystal-lang
<asterite> jhass: you are correct, method dispatch is just a chain of if/elsif. Later LLVM might optimize that into a jump table :-)
<crystal-gh> [crystal] asterite pushed 2 new commits to master: https://git.io/v2hTH
<crystal-gh> crystal/master 876aaab Ary Borenszweig: Hierarchy tool: show in bold instance variables that have a fixed type
<crystal-gh> crystal/master 7cb4b3a Ary Borenszweig: Formatter: fixed issue with heredoc. Fixes #2282
<umurgdk> is it possible to define a funtion type as takes anything and returns specific type?
<umurgdk> i mean block type
<jhass> not yet, as Object is disallowed for the moment
<jhass> why take an argument at all?
<umurgdk> def select_map(&block : _ -> U)
<umurgdk> ThenParser.new(self) do |items|
<umurgdk> mapped = items.map &block
<umurgdk> ReturnParser(Array(U)).new mapped
<umurgdk> end
<umurgdk> end
<umurgdk> trying to do something like that
pawnbox has quit [Remote host closed the connection]
bcardiff has joined #crystal-lang
<jhass> the type of items should be known, no?
<umurgdk> actually this method defined in a generic class Parser(T) in this case T is Array(X)
pawnbox has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
<jhass> umurgdk: https://carc.in/#/r/tty ?
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
<umurgdk> jhass: https://carc.in/#/r/tu0
<jhass> well then you simply hit a current limitation of the language now
<umurgdk> ehehe :)
<jhass> I guess given you require whatever T is to implement map, you could try toying with requiring Enumerable(T) or something
<asterite> umurgdk: what's the type of item in select_map?
<umurgdk> It depends on the given parser type
<umurgdk> if Parser(Array(Int32)) then it should be Int32
<asterite> A Parser always deals with Array?
<umurgdk> nope
<Tophe> is there a way to do binary marshalling, like ruby marshall ?
<asterite> Tophe: not yet
<BlaXpirit> Tophe, at least you can get a json-like data structure and pass it through msgpack
<Tophe> ok, that's a good way to start, but json/msgpack have some drawback, harder to use, and support a small type subset (no date for example)
bcardiff has joined #crystal-lang
<BlaXpirit> Tophe, sure
<Tophe> asterite: what's you have started is incredible ! perhaps ruby can survive to the go effect afterall.
<asterite> I don't think Ruby will die, even with Crystal around. You can do many things with Ruby that you can't do with Go or Crystal
<Tophe> sure, ruby is so cool (but it is also so slow) and also so magic, that some time it is incredibly hard to read. (I love it)
<JX7P> Tophe, what do you mean by 'go effect'
<JX7P> restrictive, limited languages that misunderstand what semicolons are for, and whose propagandists urge the use of M4 Macro Maker for generics?
<fka__> hey all!
fka__ is now known as fka
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/v2hBz
<crystal-gh> crystal/master 7545084 Ary Borenszweig: Formatter: correctly reindent heredocs. Related to #2282
<Tophe> JX7P : I mean that if you use ruby and need to scale and have webpages running in less than 500ms, you need to find a new language to do that. Because the concurency model of ruby can't scale well. so you can try different language (elixir but need a good functional programming level, node + js, Go ...) and Go is perhaps the most simple to learn for rubyist, and have good performances, low memory usage ! (excluding crystal which must be the obvious
<Tophe> choice, but I discover it 4 days ago)
knoopx has joined #crystal-lang
plukevdh has joined #crystal-lang
<travis-ci> crystal-lang/crystal#7545084 (master - Formatter: correctly reindent heredocs. Related to #2282): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/114262203
ponga has quit []
<fka> @bcardiff hey! you had a great update on kamber.
<fka> thanks!
knoopx has quit [Remote host closed the connection]
<fka> i'm waiting for your PR!
<bcardiff> It wasn't me :-). I am just linking a post that deals with the diff between latest crystal and kamber and kamber's author. May be the post's author will do it.
<bcardiff> it would be great to have someway to trigger travis over each crystal shards now that crystal releases might be evolving faster than some projects.
<plukevdh> asterite: given your suggested changes from Friday, I get the following when casting to a recursive type: https://play.crystal-lang.org/#/r/tui
<bcardiff> Until the crystal reaches 1.0 it is hard to keep all projects up to date. All shards suffer from that right now.
<plukevdh> {"add" => {"headers" => }
<plukevdh> which isn't even a valid object
<plukevdh> walking the object down to the "headers" key ends up yielding a segfault
<fka> @bcardiff aha! thanks for linking then :) i loved it.
<bcardiff> @fka welcome :-)
<umurgdk> jhass: ok maybe the map function is not necessary at all
<umurgdk> one_of("><+-.,").many.select &.map(&->BrainfuckToken.from_string(String))
<umurgdk> &. and &-> does the trick :)
<jhass> uhm, okay....
<umurgdk> at least for now :/
<asterite> plukevdh: yes, seems like the `as Type` is causing trouble. I'll try to reduce it and fix it, but later
<asterite> plukevdh: you can use this for now: https://gist.github.com/asterite/5ae43755df6b75322a27
fka has quit [Remote host closed the connection]
<plukevdh> asterite: wild
<plukevdh> that does fix... so is it wrapped up somewhere in the cast logic?
<asterite> I don't know why it crashes, but `Array#compact` doesn't remove `Nil` from the type... I also think the bug is somewhere in `as T`
<plukevdh> i thought I was seeing the Nil type removed... at least from `[]=` type error from earlier
LastWhisper____ has joined #crystal-lang
tomchapin has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/v2hHg
<crystal-gh> crystal/master 60777f3 Ary Borenszweig: Updated changelog
shama has joined #crystal-lang
fka has joined #crystal-lang
rok has joined #crystal-lang
brunto has quit [Ping timeout: 246 seconds]
rok has quit [Quit: rok]
<travis-ci> crystal-lang/crystal#60777f3 (master - Updated changelog): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/114283494
alsm has quit [Ping timeout: 276 seconds]
LastWhisper____ has quit [Ping timeout: 260 seconds]
LastWhisper____ has joined #crystal-lang
<LastWhisper____> hey guys is there any straightforward way to import a text file and iterate over it?
<LastWhisper____> I was doing this in ruby
<LastWhisper____> File.foreach( "test.txt" ) do |line|
<LastWhisper____> puts line
<LastWhisper____> end
bcardiff_ has joined #crystal-lang
bcardiff has quit [Ping timeout: 250 seconds]
bcardiff_ is now known as bcardiff
<jhass> LastWhisper____: http://crystal-lang.org/api/File.html#each_line%28filename%2Cencoding%3D%3Cspanclass%3D%22n%22%3Enil%3C%2Fspan%3E%2Cinvalid%3D%3Cspanclass%3D%22n%22%3Enil%3C%2Fspan%3E%2C%26block%29-class-method ;)
<LastWhisper____> jhass you're the man
trapped has quit [Read error: Connection reset by peer]
trapped has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #crystal-lang
LW___ has joined #crystal-lang
LastWhisper____ has quit [Ping timeout: 246 seconds]
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<umurgdk> is there any way to see macro expansion
<jhass> umurgdk: add {{debug()}} to it
<umurgdk> jhass: inside the macro?
<jhass> yes
<jhass> it'll print it to stdout then, up to the point where you put {{debug()}}
<umurgdk> does print even compilation fails? like type mismatches etc.
<jhass> I think so
<umurgdk> thanks!!!! many lives saved :D
trapped has joined #crystal-lang
trapped has quit [Client Quit]
<umurgdk> yeah {{debug()}} works even compilation fails woho!
trapped has joined #crystal-lang
<fka> wow
<fka> made my day @jhass @umurgdk
sp4rrow has joined #crystal-lang
jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.13.0 | 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
kulelu88 has joined #crystal-lang
bcardiff_ has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 2 new commits to master: https://git.io/v2jKQ
<crystal-gh> crystal/master 74fbe56 Ary Borenszweig: Run `crystal tool format` to upgrade to new syntax
<crystal-gh> crystal/master fc76020 Ary Borenszweig: Removed the syntax `def foo(x = V : T)`, and updated code to emit the new syntax: `def foo(x : T = V)`
bcardiff has quit [Ping timeout: 264 seconds]
bcardiff_ is now known as bcardiff
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
alsm has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
sp4rrow has joined #crystal-lang
<travis-ci> crystal-lang/crystal#fc76020 (master - Removed the syntax `def foo(x = V : T)`, and updated code to emit the new syntax: `def foo(x : T = V)`): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/114335373
pawnbox has quit [Ping timeout: 250 seconds]
bcardiff has quit [Quit: bcardiff]
<trapped> jhass: thanks for the support
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
<jhass> trapped: purely egoistic ;P
sp4rrow has joined #crystal-lang
pawnbox has joined #crystal-lang
<trapped> jhass: you're using artanis in carc.in, right?
<jhass> yep
alsm has quit [Ping timeout: 276 seconds]
pawnbox has quit [Ping timeout: 240 seconds]
Philpax has quit [Ping timeout: 276 seconds]
alsm has joined #crystal-lang
slash_nick is now known as slash_quit
mondok has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
trapped has quit [Ping timeout: 240 seconds]
LW___ has quit [Ping timeout: 260 seconds]
pawnbox has quit [Ping timeout: 240 seconds]
alsm has quit [Ping timeout: 260 seconds]
LastWhisper____ has joined #crystal-lang
trapped has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
mondok has quit [Ping timeout: 240 seconds]
pawnbox has quit [Ping timeout: 240 seconds]
LastWhisper____ has quit [Remote host closed the connection]
LastWhisper____ has joined #crystal-lang
<sp4rrow> is there any news on the compiler rewrite?
fka has quit [Remote host closed the connection]
<jhass> it's put aside for now
<jhass> they want to focus to bring the features achieved by it to the language first and then look at it again
<sp4rrow> awesome that sounds good
<sp4rrow> is there any profiling data on the compiler?
<jhass> what do you mean?
<sp4rrow> well part of the reason is because the compiler was slow
<sp4rrow> I was curious what is slow
<jhass> it's not that slow
<jhass> fast enough for the size of projects currently in existence
<sp4rrow> ah
<sp4rrow> yeah but in the new years article wasnt there something about it being too slow for large sized projects moving forward
<jhass> well, that's extrapolations ;)
<sp4rrow> cool
<sp4rrow> that is awesome to know
<sp4rrow> curious
<sp4rrow> is there any performance libs for crystal
<sp4rrow> even in the program I build
slash_quit is now known as slash_join
<jhass> I don't follow
<sp4rrow> something like rubyprof
<jhass> oh you mean profiler
<sp4rrow> yeah :)
<jhass> you can try the usual profilers you'd use for C too
<jhass> perhaps try if compiling with -d makes the output any more useful for you
<sp4rrow> interesting I have not used a c compiler
bcardiff has joined #crystal-lang
<sp4rrow> I have used dtrace a long time ago
<sp4rrow> can you use the xcode profiling tools
<sp4rrow> they are build around llvm right?
<jhass> I don't use OS X, don't ask me ;)
<jhass> but I guess so
<jhass> you can use them I mean, I doubt they have to integrate with LLVM in any way, at least I don't follow how that'd make any sense
pawnbox has joined #crystal-lang
A124 has quit [Quit: '']
<sp4rrow> I was reading something about swift a while back about how the profiling and dev tools work because of llvm
<sp4rrow> at least what I gleaned is that things that run with llvm integrate into OSX dev tooling
A124 has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
<JX7P> oh, yes, the apple people take LLVM very seriously so they do
<sp4rrow> well I am super curious I am going to try and get a profiler working in general
bcardiff has quit [Ping timeout: 260 seconds]
plukevdh has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
luislavena has joined #crystal-lang
pawnbox has joined #crystal-lang
Philpax has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
shadeslayer has quit [Ping timeout: 260 seconds]
shadeslayer has joined #crystal-lang
LastWhisper____ has quit [Ping timeout: 276 seconds]
pawnbox has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
pawnbox has quit [Ping timeout: 246 seconds]
brunto has joined #crystal-lang
brunto has joined #crystal-lang
brunto has quit [Changing host]
luislavena has quit [Ping timeout: 248 seconds]
brunto has quit [Quit: Lost terminal]