jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.7 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
elbow_jason has quit [Ping timeout: 240 seconds]
elbow_jason has joined #crystal-lang
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
elbow_jason has quit [Client Quit]
qard has quit [Client Quit]
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 246 seconds]
havenwood has joined #crystal-lang
qard has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
nakilon has joined #crystal-lang
nakilon has quit [Ping timeout: 240 seconds]
Neverdie has joined #crystal-lang
blue_deref has joined #crystal-lang
<dzv> jhass: can you reopen #1276
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
havenwood has joined #crystal-lang
blue_deref has quit [Quit: Taking myself out of hear.]
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 252 seconds]
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
nakilon has joined #crystal-lang
havenwood has joined #crystal-lang
nakilon has quit [Ping timeout: 244 seconds]
fowlduck has joined #crystal-lang
lokulin has quit [Ping timeout: 246 seconds]
fowlduck has quit [Ping timeout: 250 seconds]
kulelu88 has quit [Quit: Leaving]
lokulin has joined #crystal-lang
fowlduck has joined #crystal-lang
lokulin has quit [Ping timeout: 246 seconds]
fowlduck has quit [Remote host closed the connection]
Neverdie has quit [Quit: http://radiux.io/]
fowlduck has joined #crystal-lang
lokulin has joined #crystal-lang
trapped has joined #crystal-lang
nakilon has joined #crystal-lang
nakilon has quit [Ping timeout: 244 seconds]
fowlduck has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Renich has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
havenwood has joined #crystal-lang
Renich has quit [Quit: leaving]
sadin has quit [Remote host closed the connection]
BlaXpirit has quit [Quit: Konversation]
asbradbu1y has quit [Ping timeout: 255 seconds]
asbradbury has joined #crystal-lang
buggs has quit [Ping timeout: 264 seconds]
buggs has joined #crystal-lang
nakilon has joined #crystal-lang
leafybasil has quit [Read error: Connection reset by peer]
leafybas_ has joined #crystal-lang
nakilon has quit [Ping timeout: 264 seconds]
havenwood has quit [Read error: Connection reset by peer]
havenwood has joined #crystal-lang
<jhass> dzv: it's still open?1
<dzv> oops. i was looking at the closed message on a referenced PR
elia has joined #crystal-lang
fowlduck has joined #crystal-lang
fowlduck has quit [Remote host closed the connection]
leafybas_ has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 255 seconds]
leafybasil has joined #crystal-lang
leafybasil has quit [Read error: Connection reset by peer]
leafybasil has joined #crystal-lang
ponga has quit [Quit: Connection closed for inactivity]
fowlduck has joined #crystal-lang
<crystal-gh> [crystal] andywenk opened pull request #1475: change wording of 'var' to tulip in docs local_variables (gh-pages...change_wording_section_variables) http://git.io/vZHD5
fowlduck has quit [Ping timeout: 250 seconds]
<crystal-gh> [crystal] jhass pushed 1 new commit to master: http://git.io/vZHSK
<crystal-gh> crystal/master a398742 Jonne Haß: Contributing.md: fix typo and point out that docs/ is generated
<travis-ci> manastech/crystal#a398742 (master - Contributing.md: fix typo and point out that docs/ is generated): The build passed. https://travis-ci.org/manastech/crystal/builds/80393883
nakilon has joined #crystal-lang
havenwood has quit [Ping timeout: 252 seconds]
<jokke> is it possible to make a type restriction for "any class type"
<jokke> or "any type"
<jokke> rather
<jhass> sounds like no restriction at all?
<jokke> yeah i just realized...
<jhass> or you mean like Int32, String, in other words the descendants of Class?
<jokke> yes
<jokke> jhass: i want to write a validator for hashes
fowlduck has joined #crystal-lang
<[spoiler]> "I restrict entrance to everyone except anyone!"
<jhass> just : Class then?
<jokke> afair Class wasn't allowed
fowlduck has quit [Ping timeout: 250 seconds]
<nakilon> there is a Ukrainian box champion Klitchko that went to politics -- in one of interviews he said: "Today not everyone can look into tomorrow -- I mean not only everyone can look but also few of them who can"
<nakilon> *very few
<jokke> hmm
<jokke> why can't i do this:
<jokke> >> foo = Int32; 3.is_a?(foo)
<DeBot> jokke: Syntax error in eval:4: expecting token 'CONST', not 'foo' - http://carc.in/#/r/fgv
<jhass> because the compiler needs to understand it at compile time, is_a? actually just pretends to be a method
<jokke> ah
<jokke> ok
<jokke> it's a macro
<jokke> ok so how would i check on runtime?
<jhass> sort of, it' syntax
<jhass> do you need the subclass property?
<jhass> else
<jhass> >> foo = Int32; 3.class == foo
<DeBot> jhass: # => true - http://carc.in/#/r/fgw
<jokke> subclass property?
<jokke> ah
<jokke> ok
<jhass> >> foo = Int; 3.class == foo
<DeBot> jhass: # => false - http://carc.in/#/r/fgx
<jokke> hmm
<jhass> >> 3.is_a? Int
<DeBot> jhass: # => true - http://carc.in/#/r/fgy
<jokke> any way to get the subclass property?
<jokke> on runtime
<jokke> at
<jokke> >> foo = (Int | Int32); 3.class == foo
<DeBot> jokke: Error in line 4: undefined method '|' for Int:Class - http://carc.in/#/r/fgz
<jokke> meh
<jokke> dafuq?
<jokke> >> puts({Int32, Int}.map(&.name).join(" | "))
<DeBot> jokke: Int32 | Int32 - more at http://carc.in/#/r/fh0
<jokke> why??
<jokke> or is it possible to assign union types to variables?
<jokke> >> {Int32, Int}.map { |type| puts type.name }
<DeBot> jokke: Int32 - more at http://carc.in/#/r/fh1
<jokke> i really don't understand
<jhass> >> (Int32|Int) == Int32
<DeBot> jhass: Error in line 4: undefined method '|' for Int32:Class - http://carc.in/#/r/fh2
<jhass> heh
<jhass> but yeah a union type is pretty much a distinct type
<jokke> from the docs:
<jokke> >> tuple = {1, "hello", 'x'}; tuple.each { |value| puts value }
<jhass> >> foo = Int; foo === 3.class
<DeBot> jokke: 1 - more at http://carc.in/#/r/fh3
<DeBot> jhass: # => false - http://carc.in/#/r/fh4
<jhass> mmh
<jhass> >> foo = Int; foo === 3
<DeBot> jhass: # => false - http://carc.in/#/r/fh5
<jokke> that works
<jhass> guess case when is special cased too
<jokke> >> tuple = {Int32, Int, String}; tuple.each { |value| puts value.name }
<DeBot> jokke: Failed to run your code, sorry! - http://carc.in/#/r/fh6
<jokke> wtf
<jhass> mmh
<jhass> that's a bug
<jhass> >> puts Int.name
<DeBot> jhass: Int - more at http://carc.in/#/r/fh7
<jokke> i'll write an issue
<jhass> yeah
<jhass> I get In32 twice locally
<jokke> me too
<jhass> >> tuple = {Int32, Int, String}; tuple.each { |value| puts typeof(value) }
<DeBot> jhass: Failed to run your code, sorry! - http://carc.in/#/r/fh8
<jhass> oh right, I put the bot back to .6
<jokke> >> [Int32, Int, String].each { |value| puts value.name }
<DeBot> jokke: Int32 - more at http://carc.in/#/r/fh9
<jokke> wut
<jokke> sorry
<jokke> it never seems to finish
Neverdie has joined #crystal-lang
trapped has joined #crystal-lang
<crystal-gh> [crystal] jhass pushed 2 new commits to master: http://git.io/vZQ4Z
<crystal-gh> crystal/master 01c9131 TSUYUSATO Kitsune: Added method_added hooks
<crystal-gh> crystal/master 67f4a5f Jonne Haß: Merge pull request #1090 from MakeNowJust/feature/method_added...
<travis-ci> manastech/crystal#67f4a5f (master - Merge pull request #1090 from MakeNowJust/feature/method_added): The build passed. https://travis-ci.org/manastech/crystal/builds/80412951
<jeromegn> So, this is decently fast: https://github.com/jeromegn/bson.cr/tree/master/perf
<jeromegn> It'll be fun to figure out what's slow.
<jeromegn> Also, I can't test exactly like the ruby implementation because of that bug I filed.
<jeromegn> Would be more interesting to compare with the C lib too
<jokke> what's the type grammar for a Proc where i don't care about the return type?
<jhass> just leave it off
<jhass> (Whatever ->)
<jokke> ok
jeromegn_ has joined #crystal-lang
jeromegn has quit [Ping timeout: 252 seconds]
jeromegn_ is now known as jeromegn
ylluminate has quit [Ping timeout: 246 seconds]
<crystal-gh> [crystal] jhass opened pull request #1477: Rename Channel related classes (master...rename_channel) http://git.io/vZQMv
ylluminate has joined #crystal-lang
ylluminate has quit [Ping timeout: 250 seconds]
pawnbox has joined #crystal-lang
<crystal-gh> [crystal] jhass opened pull request #1478: Rename time related types (master...rename_time) http://git.io/vZQFn
<crystal-gh> [crystal] asterite closed pull request #966: Change it to use postfix '_spec.cr' for spec files (master...spec-file-postfix) http://git.io/vqbcu
sadin has joined #crystal-lang
sadin has quit [Remote host closed the connection]
kostya has joined #crystal-lang
<crystal-gh> [crystal] jhass opened pull request #1480: Rename a couple exceptions (master...rename_exceptions) http://git.io/vZQjo
sadin has joined #crystal-lang
BlaXpirit has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 3 new commits to master: http://git.io/vZ7v4
<crystal-gh> crystal/master c0de252 Will Leinweber: add TypeCastError for runtime casting exceptions
<crystal-gh> crystal/master c0de784 Will Leinweber: Add TypeCastError specs
<crystal-gh> crystal/master d15f5df Ary Borenszweig: Merge pull request #1444 from will/casting-exception...
<crystal-gh> [crystal] jhass opened pull request #1481: Rename MatchData to Regex::MatchData (master...rename_match_data) http://git.io/vZ7UW
<travis-ci> manastech/crystal#d15f5df (master - Merge pull request #1444 from will/casting-exception): The build passed. https://travis-ci.org/manastech/crystal/builds/80432002
sadin has quit [Read error: Connection reset by peer]
sadin has joined #crystal-lang
elia has quit [Read error: Connection reset by peer]
elia has joined #crystal-lang
<jokke> jhass: i have an issue with the following code: https://p.jreinert.com/qXjUVt/ruby
<jokke> in ./src/autopass/config.cr:25: type must be YAML::Type, not (Nil | String | Array(YAML::Type) | Hash(YAML::Type, YAML::Type))
<jokke> validator.call(value)
<jokke> Something seems to be broken with resolving recursive types
<jokke> or aliases
<jokke> i remember having a similar problem with JSON::Type
<jokke> and afair it was fixed
<crystal-gh> [crystal] jhass opened pull request #1482: Rename (Un)SignedInt to Int::(Un)Signed (master...rename_int) http://git.io/vZ7OC
<jhass> jokke: yeah probably another instance of https://github.com/manastech/crystal/issues/1473
<jokke> jhass: ok
<jokke> is there a workaround?
Neverdie has quit [Quit: http://radiux.io/]
<jhass> dunno, does .call(value as YAML::Type) help?
<jhass> probably not
<jokke> it does actually
elia has quit [Read error: Connection reset by peer]
elia has joined #crystal-lang
<jokke> jhass: hmm. now i have the problem that my Proc(YAML::Type, YAML::Type) won't accept a proc that returns a string
<jokke> as a matter of fact it doesn't accept anything as return value...
<jokke> after alias Sanitizer = (YAML::Type -> Object)
<jokke> in ./src/autopass/config.cr:46: expected new to return Object+, not YAML::Type
<jokke> return Definition.new(Sanitizer.new { |value| value }) if permit_unknown?
<jhass> ah yeah Object is broken, I thought it's disallowed as type restriction everywhere by now?
<jokke> yeah
<jokke> not there it seems
<jhass> but there too an explicit cast should help
<jokke> yeah but that's annoying
<jhass> it is
<jhass> I think we have 2-3 issues open around that
<jokke> is there no possibility to define a Proc that returns _something_
<jokke> rather define a type of such a Proc
<jokke> (Foo ->) also allows Void
<jhass> nope, type inference around procs is rather dumb
<jokke> hmm
<jhass> not saying it'll stay that way, but for now it is
<jokke> ok
<jokke> is there something like not_nil! for void?
<jhass> there shouldn't need to be, Anything|Void should resolve to Anything iirc
<jhass> >> a = [] of String|Void; typeof(a)
<DeBot> jhass: # => Array(String | Void) - http://carc.in/#/r/fie
<jhass> mmh
<jhass> where do you get Void from?
Neverdie has joined #crystal-lang
<jokke> from the proc output apparently
<jhass> ah, NoReturn was the thing that vanishes
tomchapin has joined #crystal-lang
<jhass> so you have a Proc in there that has no return type specified?
<jokke> yes
<jokke> i raise now if the value is void
<jokke> so thats worked around kinda
<jhass> I don't quite follow your code, value is the thing that may be void if you don't raise somewhere?
<jokke> yeah it's fine. i've changed it since i pasted it so it's hard to follow i believe
<jokke> i'll post an update when i think i got thinks running
elia has quit [Read error: Connection reset by peer]
elia_ has joined #crystal-lang
<jokke> hmm
<jokke> ok so (Foo ->) means that the proc _always_ returns Void?
<jhass> kinda and Void ignores any return value
<jhass> asterite: mmh, BufferedIO -> IO::Buffered, FileDescriptorIO -> IO::FileDescriptor ?
<asterite> Yes, could be. I think FileDescriptorIO and Buffered won't be used (often) in public APIs so it's ok to put them in the IO namespace
<asterite> File will obviously remain File, and so does Socket, etc.
<jhass> yeah sure
<jhass> the last thing I see would be PointerIO -> Pointer::IO and PointerAppender -> Pointer::Appender but I'm even less sure about these compared to FileDescriptorIO / BufferedIO
<jhass> mmh, I guess if we'd do Pointer::IO we would need to do String::IO
<jokke> jhass: is it possible to store block arguments and call them later from some other method?
<jhass> yes, but likewise finicky as dealing with Proc's (since they turn into Proc's)
<jhass> but much like Ruby, &block in a method definition, you just have to add the type restriction or else (->) is assumed
havenwood has joined #crystal-lang
<jokke> aaah
<jokke> ok
<jokke> hmm
<jokke> damn
<crystal-gh> [crystal] waj pushed 2 new commits to master: http://git.io/vZ72w
<crystal-gh> crystal/master 92cbeaa Jonne Haß: Correctly handle signal exits in crystal run and add convenience methods...
<crystal-gh> crystal/master 845f6d2 Juan Wajnerman: Merge pull request #1469 from jhass/fix_run_signal_handling...
<jokke> jhass: so something like @block = block as Proc(Foo, Bar) ?
<jhass> huh, no
<jhass> def foo(&block : Foo -> Bar)
<crystal-gh> [crystal] jhass opened pull request #1483: Rename IO related classes (master...rename_io) http://git.io/vZ7oh
<travis-ci> manastech/crystal#845f6d2 (master - Merge pull request #1469 from jhass/fix_run_signal_handling): The build passed. https://travis-ci.org/manastech/crystal/builds/80446169
sadin has quit [Remote host closed the connection]
nakilon_ has joined #crystal-lang
<jokke> jhass: yeah
<jokke> ok
<jokke> hmm i'm left with this: https://p.jreinert.com/DWJQL/ruby
<jokke> and this spec: https://p.jreinert.com/iddDV/ruby
<jokke> but if i run the spec i get no output
<jokke> at all
<jokke> no error, no nothing
nakilon has quit [Ping timeout: 246 seconds]
Neverdie has quit [Quit: http://radiux.io/]
<jhass> mmh, I get a red E but no output for it
<jokke> ok
<jokke> that's a bug then
<jokke> *sigh*
<jhass> because it dies in the next one (run with -v)
<jokke> mmh
<jokke> well, i'm trying something else for now
<jokke> it's overkill anyway
<jhass> I'll bet on a stackoverflow or something, let's see
Neverdie has joined #crystal-lang
<crystal-gh> [crystal] waj pushed 2 new commits to master: http://git.io/vZ71q
<crystal-gh> crystal/master 57645e7 Jonne Haß: Rename MatchData to Regex::MatchData
<crystal-gh> crystal/master 4b6bd45 Juan Wajnerman: Merge pull request #1481 from jhass/rename_match_data...
fowlduck has joined #crystal-lang
<jhass> wth is register_tm_clones anyway
<jhass> gosh this smells like a codegen bug :(
<wmoxam> a registry for clones™
<jhass> thanks captain!
<wmoxam> ;)
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vZ7ym
<crystal-gh> crystal/master 4276175 Ary Borenszweig: Merge pull request #1482 from jhass/rename_int...
<crystal-gh> crystal/master 14fb4dd Jonne Haß: Rename (Un)SignedInt to Int::(Un)Signed
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vZ7yj
<crystal-gh> crystal/master 8b7db74 Jonne Haß: Rename a couple exceptions...
<crystal-gh> crystal/master 1cec8e4 Ary Borenszweig: Merge pull request #1480 from jhass/rename_exceptions...
<wmoxam> - (de)register tm clones: transaction memory - a concurrency
<wmoxam> control mechanism for controlling access to shared memory i
<wmoxam> n
<wmoxam> concurrent computing
Neverdie has quit [Quit: http://radiux.io/]
<crystal-gh> [crystal] tebakane opened pull request #1484: Add `Array#flatten!` (master...expand_flatten) http://git.io/vZ79S
Neverdie has joined #crystal-lang
jmg_ has joined #crystal-lang
<travis-ci> manastech/crystal#4276175 (master - Merge pull request #1482 from jhass/rename_int): The build passed. https://travis-ci.org/manastech/crystal/builds/80451671
sadin has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vZ7d7
<crystal-gh> crystal/master 4eaddf0 Ary Borenszweig: Fixed comment location for Regex::MatchData. Related to #1481
<jhass> asterite: am I missing something or is there indeed no example for https://github.com/manastech/crystal/issues/1453 left in stdlib?
<jokke> jhass: alright.. this is interesting: https://p.jreinert.com/9wRW/ruby
<jokke> try compiling that :)
pawnbox has quit [Ping timeout: 244 seconds]
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vZ7A9
<crystal-gh> crystal/master 443f1fe Jonne Haß: Rename time related types...
<crystal-gh> crystal/master 4d19c7e Ary Borenszweig: Merge pull request #1478 from jhass/rename_time...
<jhass> jokke: 0.7.7 hangs, HEAD runs into a stackoverflow somewhere (let me compile one with debug symbols)
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vZ7pz
<crystal-gh> crystal/master 5e0c9c2 Jonne Haß: Rename Channel related classes...
<crystal-gh> crystal/master 34f551e Ary Borenszweig: Merge pull request #1477 from jhass/rename_channel...
<jokke> jhass: i think it has something to do with the aliases
<jhass> yeah
<jhass> /home/jhass/projects/crystal/code/src/compiler/crystal/semantic/type_merge.cr:89
<jhass> I think I commented this one somewhere before
<jokke> whoa
<jokke> that's an old bug
<jokke> any workaround?
<crystal-gh> [crystal] jhass closed pull request #1483: Rename IO related classes (master...rename_io) http://git.io/vZ7oh
<travis-ci> manastech/crystal#4eaddf0 (master - Fixed comment location for Regex::MatchData. Related to #1481): The build passed. https://travis-ci.org/manastech/crystal/builds/80455834
dfockler has joined #crystal-lang
shama has joined #crystal-lang
<jhass> I don't see how you could achieve the same in a different way I'm afraid
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
<travis-ci> manastech/crystal#4d19c7e (master - Merge pull request #1478 from jhass/rename_time): The build passed. https://travis-ci.org/manastech/crystal/builds/80457607
dleedev has joined #crystal-lang
<crystal-gh> [crystal] asterite closed pull request #1484: Add `Array#flatten!` (master...expand_flatten) http://git.io/vZ79S
jmg_ has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
fowlduck has quit [Remote host closed the connection]
<travis-ci> manastech/crystal#34f551e (master - Merge pull request #1477 from jhass/rename_channel): The build passed. https://travis-ci.org/manastech/crystal/builds/80458238
<travis-ci> manastech/crystal#bfa21ce (master - Merge pull request #1483 from jhass/rename_io): The build passed. https://travis-ci.org/manastech/crystal/builds/80459404
sadin has quit [Remote host closed the connection]
<dleedev> where can we file bug reports for http://crystal-lang.org/docs ?
<dleedev> search doesn’t work very well (you’ll get 0 results when you try searching for “Array”)
<crystal-gh> [crystal] jhass closed pull request #1475: change wording of 'var' to tulip in docs local_variables (gh-pages...change_wording_section_variables) http://git.io/vZHD5
<jhass> dleedev: mmh, gitbook? :D
<jhass> dleedev: it's hosted in the gh-pages branch of the main repo
<jhass> dleedev: but do we even have docs for Array there? I think only at http://crystal-lang.org/api/
<BlaXpirit> dleedev, hm indeed
<BlaXpirit> search_index.json was rebuilt 3 minutes ago
<dleedev> BlaXpirit: I reloaded the webpage, but it’s still returning 0 results for me
<BlaXpirit> yeah, same
<BlaXpirit> "arra" works tho
<BlaXpirit> and indeed finds all mentions of array
<dleedev> BlaXpirit: you’re right, that’s strange
<BlaXpirit> dleedev, well it's just gitbook
<BlaXpirit> i can just try building it on my computer, then it's surely just a Gitbook bug
<BlaXpirit> yup, dleedev, getting the same problem
leafybasil has quit [Remote host closed the connection]
<BlaXpirit> wait no, i checked wrong
leafybasil has joined #crystal-lang
<jhass> mmh, 2.4.0 was released a couple hours ago
<BlaXpirit> let me check it then
<jhass> gh-pages branch uses 2.3.2 atm
<jhass> you can edit it in the Rakefile
<BlaXpirit> still broken
<BlaXpirit> with 2.4.0
<jhass> okay, if anybody of you wants to open an issue about it go ahead
leafybasil has quit [Ping timeout: 240 seconds]
<BlaXpirit> hah, in a gitbook-book of my own there is exactly the same problem
<jhass> bet it's a silly off by one
ssvb has joined #crystal-lang
<jhass> JS is too finicky :P
<BlaXpirit> right
qard has joined #crystal-lang
<dzv> how often are docs/api pages updated on crystal-lang.org?
<jhass> docs on every commit to them, api on every release
<BlaXpirit> maan gitbook rebuilds are probably at least 90% of the repo by now
<crystal-gh> [crystal] pgkos opened pull request #1487: Reimplementation of glob in Crystal (master...recursive-glob) http://git.io/vZ52Q
<jhass> mmh, I guess for the gh-pages branch running a filter-branch at some point is not out of question
elia_ has quit [Quit: Computer has gone to sleep.]
<jeromegn> ah, I was able to make it exactly like Ruby's BSON parser's benchmarks and getting some great results... https://github.com/jeromegn/bson.cr/tree/master/perf
<jeromegn> that's for 1 000 000 operations
sadin has joined #crystal-lang
<jhass> jeromegn: try release mode?
* jeromegn crystal --help
dfockler has quit [Remote host closed the connection]
<jeromegn> jhass: !!!
<jeromegn> almost twice as fast
<jeromegn> heh
<jeromegn> updated the readme
<jeromegn> I bet I can do so many optimizations
<jhass> probably
<jeromegn> in every iteration of the benchmark, I'm flushing the IO
<jeromegn> clearing
<jhass> well yeah, that's slow :P
dfockler has joined #crystal-lang
<jeromegn> I don't have much choice
<jeromegn> unless I create a new IO every time?
<jeromegn> I mean, I was thinking of creating a method to_bson that don't require a IO instance, one that'll just produce an Array of bytes
<jhass> some in memory IO would be good, yeah
<jeromegn> and then call that from the to_bson(bson : IO) to append it
<jhass> we really should do SliceIO
<jeromegn> I had that for a while
<jeromegn> but I changed strategy
<jeromegn> he never PRed it in crystal though
oleh has joined #crystal-lang
<oleh> hi everyone. What is analogue of lisp-like macroexpand in Crystal?
* jhass doesn't know lisp
dleedev has quit [Quit: dleedev]
fowlduck has joined #crystal-lang
<jeromegn> apparently StringIO.new is more expensive than string_io.clear
<oleh> okey, how can I see what the code is generated by macro, that is how I can expand macro?
<jhass> oleh: adding {{debug()}} to a macro prints the expansion to stdout up to the point of the call
<jhass> besides that there's crystal browser which shows some of the expansions (those that are included inside methods or generate them)
<oleh> jhass: thanks a lot
jeromegn_ has joined #crystal-lang
jeromegn has quit [Ping timeout: 268 seconds]
jeromegn_ is now known as jeromegn
<oleh> actually, I need to see the code generated by macro call, and I can do it by `puts` method
<jhass> no you can't do it "by puts"
<jhass> putting {{debug()}} at the end is the only way for now
<oleh> but I did it right now, example: puts record SomeRec, a, b. It gives error, but prints the code generated by macro call, and that is what I need.
<jhass> ah well I guess so
<jhass> but foo instead of puts would work too ;)
havenwood has joined #crystal-lang
<oleh> yep, it's true ;)
<oleh> but, for now I can't see another way to do that.
bougyman has quit [Ping timeout: 250 seconds]
Neverdie has quit [Quit: http://radiux.io/]
kostya has quit [Remote host closed the connection]
bougyman has joined #crystal-lang
kulelu88 has joined #crystal-lang
<jokke> hi
<jokke> never mind
<jokke> or
<jokke> is there something like block_given? for macros?
<jhass> mmh, it doesn't overload?
<jhass> indeed not
<jhass> jokke: http://carc.in/#/r/fj7
havenn has joined #crystal-lang
havenwood has quit [Ping timeout: 244 seconds]
elia has joined #crystal-lang
havenn is now known as havenwood
dyulax93 has quit [Quit: Saindo]
dyulax has joined #crystal-lang
<jokke> jhass: at which point are macro arguments evaluated?
<jhass> evaluated?
<jokke> hm i think i need {{yield}}
<Netfeed> trying to run the specs for for http, but it can't link with crypto and ssl, and i've installed the libevent-openssl-2.0-5 package, not sure which is needed for crypto, but all in the list in the wiki should be installed
<jokke> yeah
<jokke> field(cache_file, File.join("/tmp", "autopass-#{ENV["USER"]}")
<Netfeed> any idea what i might need?
<jokke> i'd need the latter argument to be evaluated at runtime
<jokke> but that's what yield is for i guess
Neverdie has joined #crystal-lang
<jhass> Netfeed: libcrypto is part of openssl on my system
<BlaXpirit> jhass, so there is a C lib that uses callbacks and doesn't let you pass userdata
<jhass> then no closures I'm afraid
<Netfeed> jhass: installing libssh-dev helped, thanks
<BlaXpirit> what's the approach to this? i thought about Hash(AssociatedObject, <closure data>)
<jhass> BlaXpirit: well if you can identify a registered callback from the callback that could work, store the Proc and have a global callback that dispatches to the registered procs
<jhass> Netfeed: libssl-dev you mean I hope
<BlaXpirit> i think the callback is uniquely tied to an object, and that object is passed to the callback
<jhass> yeah then you could store the actual object inside it I think
<jhass> and actual callback
<BlaXpirit> so Hash(AssociatedObject, <closure data>) like i said, or do you mean something else, because i don't udnerstand what you're sayin
<Netfeed> jhass: libssl-dev was a part of it, probably only needed that package :)
<BlaXpirit> closure data would be Box like you showed
<jhass> BlaXpirit: more like have ->(container : CallbackContainer) { container.call }
elia has quit [Quit: Computer has gone to sleep.]
<jhass> and have CallbackContainer store the user Proc and any data you need
<BlaXpirit> hmm I don't understand :( this is the thing in question, by the way https://github.com/BlaXpirit/crystal-raw-chipmunk/blob/c74af96c3/src/chipmunk.cr#L332
<BlaXpirit> so I was thinking Hash(Body, Box(Proc))
<BlaXpirit> and that hash would have to be global
<jhass> so you can't store some void pointer or something in Body?
<BlaXpirit> I don't think so
<jhass> well yeah then that way
<BlaXpirit> oh look body_set_user_data
<jhass> that looks better
<BlaXpirit> but then what if i need to store something else in it?
<BlaXpirit> if I want to associate some other custom data with that Body
<Netfeed> a git question, i tried to rebase up my cookie branch to master so i can continue working on it, but there where some changes that diverged when i did the pull afterwards and a i got a merge in too, is there a way to remove that one? amend it in to my original commit?
<BlaXpirit> ...implement a struct that contains the procs and then whatever else i mean
<BlaXpirit> i need*
<jhass> yup
<BlaXpirit> thanks
<jhass> record CallbackData, callback, foo, bar, baz
<jhass> Netfeed: a rebase usually throws out merge commits automatically
<jhass> Netfeed: so what's your state now? In a rebase and conflicting?
<Netfeed> my state now is that i have my first commit and then i have the merge commit commited
<Netfeed> i'm not sure what would happen if i push this now
<jhass> Netfeed: what's your remotes? origin your fork and upstream manastech/crystal ?
<Netfeed> yes
<jhass> git fetch upstream; git rebase upstream/master
<Netfeed> alright, i've done that already once, and now i got to thinks the same stuff a third time it seems
<Netfeed> maybe it sticks this time then
<jhass> be less vague maybe?
<jhass> if you get conflicts run git mergetool and if everything is resolved and marked as such git rebase --continue
<Netfeed> alright, so i did the rebase first, fixed the problems i got. then it said that i was 400-something commits behind so i did the pull, then i got the to do some fixes and got the merge commit, and now i'm rebasing against master again
<Netfeed> and now the merge commit is gone, nice, thanks
<jhass> okay your mistake was to not git fetch upstream before the first rebase
<jhass> I guess
<Netfeed> maybe
<jhass> the rule of thumb is to never rebase and always pull in integration branches (like master) and never pull, just fetch and rebase in feature/topic branches
<Netfeed> okey, so now it says "Your branch and 'origin/http_cookie' have diverged, and have 423 and 1 different commit each, respectively. (use "git pull" to merge the remote branch into yours)"
<Netfeed> sigh
<jhass> Netfeed: don't pull, force push
<jhass> rebase creates new commits, having to force push is expected
<jhass> and that's also why you should never use it in integration branchs
<Netfeed> i shouldn't have rebased?
<jhass> no, yours is a topic/feature branch
<jhass> that's perfectly fine to rebase (and I actually prefer that workflow)
<jhass> Netfeed: looking good
<Netfeed> alright, that seems better
<Netfeed> now i just have to fix the stuff i need to fix :)
<jhass> Netfeed: btw you can edit your last commit with git commit --amend, as that edits it it effectively creates a new one and you have to force push too if you pushed it before
apt-get has joined #crystal-lang
<Netfeed> yeah, you thought me that last time i did this :)
<jhass> sorry such things don't even go into my short term memory, it's flushed next day :P
<Netfeed> nothing to be sorry for at all
Neverdie has quit [Quit: http://radiux.io/]
elia has joined #crystal-lang
Neverdie has joined #crystal-lang
<Netfeed> and the tests works now too, TimeFormat had changed name to Time::Format
<jhass> yeah, I renamed a bunch of things
<slash_nick> better update the crystal word list for hangman
<jhass> right, I only did that yesterday of course
<jhass> well, I still have CharReader -> Char::Reader PointerIO -> Pointer::IO PointerAppender -> Pointer::Appender StringIO -> String::IO on my list
<jhass> but I don't stand fully behind them, so I'd like to get some opinions first (specifically asterite's & waj's of course :P)
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tomchapin has joined #crystal-lang
tomchapin has quit [Client Quit]
tomchapin has joined #crystal-lang
<Netfeed> what's the best way to check against nil?
<jhass> if foo
<jhass> well, depends on context really
<BlaXpirit> (checks for false as well)
<jhass> gotta steal another factoid from #ruby
<BlaXpirit> :>
<jhass> ?best="Best" and "better" are subjective. Try to use a different term.
<DeBot> jhass: Set best.
<jhass> ?better="Best" and "better" are subjective. Try to use a different term.
<DeBot> jhass: Set better.
Neverdie has quit [Quit: http://radiux.io/]
<Netfeed> and if you are in an "elsif"?
<Netfeed> nothing like pythons "foo is None"?
<jhass> elsif foo? idk what you're asking really
<jhass> foo.nil?
<jhass> but that doesn't resolve the union
<jhass> .is_a? Nil would I guess
<jhass> this is just too context dependent
<Netfeed> no, it didn't resolve the union
<jhass> of course the "best" way is to not have a union in the first place :P
<jhass> Netfeed: when will you add context to your question?
<Netfeed> never!
<Netfeed> :)
<Netfeed> https://gist.github.com/netfeed/78389deddaae8d35313d <-- i'm trying to do that again, i think it worked fine the last time, but now i get an error that @cookies isn't set in an initializer so it can be nil
<jhass> well, it's true
<Netfeed> yes, i'm not disputing that
<jhass> I think this should be @cookies ||= Cookies.from_headers(headers) now
<jhass> and from_headers should return an empty Cookies for when there's none
<Netfeed> i think it does that as it does a new.tap inside from_headers
<jhass> yeah probably
oleh has quit [Quit: leaving]
<Netfeed> it works if i add @cookies = Cookies.new to the initializers, but i'm not sure if that's actually what they want
<Netfeed> "they", asterite and waj
<jhass> it isn't
<jhass> def cookies; @cookies ||= Cookies.from_headers(headers); end; should work
<Netfeed> huh, nice, it did
<Netfeed> is that something that's new since the last month back?
<jhass> nope
<Netfeed> strange, because i think the patch i had in the gist actually worked when i created it
<Netfeed> maybe that case has stopped working
<jhass> doubt it did tbh
<Netfeed> alright, amended
Neverdie has joined #crystal-lang
dfockler has quit [Remote host closed the connection]
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
dyulax has quit [Quit: Saindo]
leafybasil has joined #crystal-lang
dyulax has joined #crystal-lang
Neverdie has quit [Quit: http://radiux.io/]
<Netfeed> travis isn't the fastest
<jhass> nuke all your .crystal directories, download the docker container and build the compiler, all the specs and run all the specs
<jhass> then reevaluate that statement :P
<jhass> oh and I forgot do it 3 times
<Netfeed> it's a nice service though
<jhass> the new container infra is quite fast ;)
fowlduck has quit [Remote host closed the connection]
fowlduck has joined #crystal-lang
dfockler has joined #crystal-lang
apt-get has quit [Remote host closed the connection]
sadin has quit [Remote host closed the connection]
zz_Cidan has joined #crystal-lang
dyulax has quit [Quit: Saindo]
nakilon_ has quit [Ping timeout: 246 seconds]
ylluminate has joined #crystal-lang
<jeromegn> what's the advantages of a Slice over a StaticArray
<BlaXpirit> jeromegn, staticarray size is known at compiletime
dyulax has joined #crystal-lang
dyulax93 has joined #crystal-lang
<jeromegn> so, better? :)
<BlaXpirit> and it's just an array, while a slice can also just point to a location in memory
<jeromegn> every way of instantiating a Slice requires the length
<BlaXpirit> >> a = 5; StaticArray(Int32, a)
<DeBot> BlaXpirit: Syntax error in eval:4: expecting token ')', not ',' - http://carc.in/#/r/fjj
<BlaXpirit> >> a = 5; StaticArray(Int32, a).new
<DeBot> BlaXpirit: Syntax error in eval:4: expecting token ')', not ',' - http://carc.in/#/r/fjk
<BlaXpirit> see what i mean
<jeromegn> if I wanted to represent my instances as bytes, the best way would be with a StaticArray of with a Slice?
<BlaXpirit> staticarray has very very limited and specific use
<jeromegn> >> StaticArray(Int32).new(5)
<DeBot> jeromegn: Error in line 4: wrong number of type vars for StaticArray(T, N) (1 for 2) - http://carc.in/#/r/fjl
<jeromegn> oh
<jeromegn> interesting
<BlaXpirit> >> StaticArray(Int32, 5).new(8)
<DeBot> BlaXpirit: # => [8, 8, 8, 8, 8] - http://carc.in/#/r/fjm
<jeromegn> there we go
<jeromegn> I'm having trouble create a StaticArray or Slice and then adding stuff to it
<jeromegn> like, one by one
<BlaXpirit> so make an array
<jeromegn> I mean, I know the length
<jeromegn> beforehand
<BlaXpirit> so make an array with capacity
<BlaXpirit> or make a slice of size, then use a[0]=, a[1]= etc
<jeromegn> right
<jeromegn> I guess I'm lazy
fowlduck has quit [Remote host closed the connection]
<jhass> jeromegn: StaticArray is a struct
<jhass> Slice points to heap memory
fowlduck has joined #crystal-lang
ylluminate has quit [Ping timeout: 256 seconds]
ylluminate has joined #crystal-lang
BlaXpirit has quit [Quit: Konversation]
ylluminate has quit [Ping timeout: 255 seconds]
<jeromegn> should sizeof(something.class) work? I tried it and I get expecting token 'CONST', not 'something'
<jeromegn> "expecting token 'CONST', not 'something'"
<jhass> sizeof(typeof(something))
<jeromegn> right
<jeromegn> but
<jeromegn> it's a Union
<jeromegn> and I want the size of the actual specific type the something is
<jhass> that's basically a C union in memory
<jhass> mmh
<jhass> >> class Class; macro def bytesize : Int32; sizeof(typeof(self)); end; end; ["foo", 1].sample.class.bytesize
<DeBot> jhass: # => 4 - http://carc.in/#/r/fjo
<jeromegn> oh
<jhass> well, it's always 4 then I guess :P
<jhass> gotta do the same for struct I think
<jhass> mmh, idk
<jeromegn> hmm
<jhass> >> class Class; macro def bytesize : Int32; sizeof(typeof(self)); end; end; [String, Int32, LibC::TimeVal].map(&.bytesize)
<DeBot> jhass: # => [4, 4, 4] - http://carc.in/#/r/fjr
<jhass> yeah that's not correct
<jhass> >> class Class; macro def bytesize : Int32; sizeof(self); end; end; [String, Int32, LibC::TimeVal].map(&.bytesize)
<DeBot> jhass: # => [4, 4, 8] - http://carc.in/#/r/fjs
trapped has quit [Ping timeout: 264 seconds]
<jhass> >> sizeof(LibC::TimeVal))
<DeBot> jhass: Syntax error in eval:4: unexpected token: ) - http://carc.in/#/r/fjt
<jhass> >> sizeof(LibC::TimeVal)
<DeBot> jhass: # => 8 - http://carc.in/#/r/fjv
<jhass> mmh, thought it was bigger
<jeromegn> any string can be represented in 4 bytes?
qard has quit [Quit: Textual IRC Client: www.textualapp.com]
<jhass> >> "".is_a? Reference
<DeBot> jhass: # => true - http://carc.in/#/r/fjx
<jhass> it's heap allocated (or in the data section of the binary), so a pointer
<jhass> all references are pointers
<jhass> all classes are references
<jeromegn> interesting
<jeromegn> maybe I shouldn't be DRYing all of this hehe.
<jhass> >> "foö".bytesize
<DeBot> jhass: # => 4 - http://carc.in/#/r/fk3
<jhass> meh, bad example :D
<jhass> >> "foöß".bytesize
<DeBot> jhass: # => 6 - http://carc.in/#/r/fk4
jokke has quit [Ping timeout: 240 seconds]
jokke1 has joined #crystal-lang
ylluminate has joined #crystal-lang
<jeromegn> nice
<jeromegn> feel bad to add a macro like that to a lib
<jeromegn> that's going to be included elsewhere
<jhass> true
<jhass> it was more for fun anyway :P
<jhass> you never detailed your usecase but it sure sounds fishy ;)
<jeromegn> haha
<jeromegn> all my work is fishy!
<jeromegn> hmm
<jeromegn> I wanted to write a generic BSON::Value module which would be included in the various classes that are supported by BSON
<jhass> afraid I'm not making the connection
<jeromegn> that module would have a generic to_bson. all the classes have to define is a bson_parts method which return an array of all the parts that should be appended as bytes to the BSON
<jeromegn> hehe sorry, still writing
<jeromegn> getting an example ready
<jeromegn> it might have extraneous stuff, but that's a quick copy paste of the working pieces
dleedev has joined #crystal-lang
<jeromegn> right now I've manually defined to_bson and bson_size, etc. in all my classes and structs extensions.
<jeromegn> I figured I'd refactor and also serialize to bytes (via a Slice(UInt8)) by default
<jeromegn> I'd love your input
<jhass> they have strings with a size header and null terminated?
<jhass> kinda silly
<jeromegn> haha
<jeromegn> yea
<jeromegn> the strings are like that
<jeromegn> everything else isn't
<jeromegn> well
<jeromegn> that's not true
<jeromegn> but yea, null terminated + size is probably overkill, but that's what the spec describes.
<jeromegn> any idea how I can make all of that nice?
<jhass> I'm thinking
<jeromegn> basically I want to produce "bson bytes" that I can just push onto an IO
<jeromegn> probably easier to just use a regular Array instead of a Slice for stuff
<jhass> btw I see many arrays in your (at least current) code that want to be tuples
<jeromegn> what's the advantage? :)
<jhass> arrays are heap allocated
<jhass> tuples are for most cases basically gone after compile time
<jeromegn> that's nice
<jeromegn> remember me from a few months ago? I know near to nothing about the compiled world, but I love to learn :) your help is invaluable as always
<jhass> tbh I think I'd mostly keep your current way
<jhass> I don't see a lot of repetition
<jhass> you'd just move the logic from to_bson to bson_parts
<jeromegn> so, what arrays should I switch to tuples?
<jeromegn> a few examples would help :)
<jeromegn> also, using Slice == good idea?
<jhass> yeah
<jhass> hrm, looks like we need to add Tuple#reverse, but then the Int ones for example
<jhass> >> {1, 2, 3}.reverse
<DeBot> jhass: Error in line 4: undefined method 'reverse' for {Int32, Int32, Int32} - http://carc.in/#/r/fka
<jhass> yeah
<jhass> that should be fun, gimme 5 minutes
<jeromegn> :)
<jeromegn> well
<jeromegn> technically, it should always be little_endian
<jeromegn> at least that's what mongo wants
<jeromegn> somthing like {self, self >> 8, self >> 16, self >> 24}.map(&.to_u8).to_a ?
dfockler has quit []
<jeromegn> >> {self, self >> 8, self >> 16, self >> 24}.map(&.to_u8).to_a
<DeBot> jeromegn: Error in line 4: there's no self in this scope - http://carc.in/#/r/fkb
<jeromegn> oops
<jeromegn> >> {6, 6 >> 8, 6 >> 16, 6 >> 24}.map(&.to_u8).to_a
<DeBot> jeromegn: # => [6, 0, 0, 0] - http://carc.in/#/r/fkc
<jeromegn> nice
<jeromegn> >> typeof({6, 6 >> 8, 6 >> 16, 6 >> 24}.map(&.to_u8).to_a)
<DeBot> jeromegn: # => Array(UInt8) - http://carc.in/#/r/fkd
<jeromegn> cool
<crystal-gh> [crystal] jhass pushed 1 new commit to master: http://git.io/vZbvK
<crystal-gh> crystal/master 314f28a Jonne Haß: Add Tuple#reverse
<jhass> don't think you'll need the to_a
nakilon_ has joined #crystal-lang
<jeromegn> I can't write a tuple to an IO though
fowlduck has quit [Remote host closed the connection]
<jhass> meh
<jhass> well, you could .each it for now and use IO#write_byte while I'll PR IO#write(Tuple(UInt8))
nakilon_ has quit [Ping timeout: 260 seconds]
elia has quit [Quit: Computer has gone to sleep.]
<jeromegn> hehe
<travis-ci> manastech/crystal#314f28a (master - Add Tuple#reverse): The build passed. https://travis-ci.org/manastech/crystal/builds/80537787
<jhass> >> [8u8, 6u8].each.is_a? Enumerable(UInt8)
<DeBot> jhass: Error in line 4: Enumerable(T) is not a generic class, it's a generic module - http://carc.in/#/r/fke
<jhass> sigh
<crystal-gh> [crystal] jhass opened pull request #1489: Add IO#write(Enumerable(UInt8)) (master...io_write_enum) http://git.io/vZbU7
<jeromegn> thanks
<jeromegn> jhass: do you know if there's any around that? https://github.com/jeromegn/bson.cr/blob/master/src/core_ext/float_64.cr#L13-L16
<jeromegn> seems like it's not perfect
<jeromegn> I get different results
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
<jeromegn> depending on **from where** I'm transforming the Float to a Slice, I get different results. basically, the first byte is different