jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.6 | 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
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
manveru has joined #crystal-lang
<manveru> just wanna make sure, there's no rational type in crystal yet?
<jhass> manveru: nope, not yet
<manveru> hey man :)
<jhass> already got a gmp binding for BigInt though, shouldn't be too hard to do the same for Rational
<jhass> ah well, that can work too I guess
<jhass> just limits precision to Int64
<manveru> >> [1].zip([2]).map{|a,b| a + b}
<DeBot> manveru: Error in line 4: undefined method '+' for {Int32, Int32} - http://carc.in/#/r/c4v
<manveru> any idea wtf that is about?
<jhass> no, auto destructuring in block args (yet)
<jhass> >> [1].zip([2]).map &.sum
<DeBot> jhass: # => [3] - http://carc.in/#/r/c4w
<jhass> so a is the tuple and b stays nil
<manveru> so you can have only one argument to a block at most?
<jhass> no
<manveru> but map doesn't splat it
<jhass> yes
<manveru> ok
<jhass> >> [1].zip([2])
<DeBot> jhass: # => [{1, 2}] - http://carc.in/#/r/c4x
<jhass> well, it wouldn't be map who does it anyway but the compiler
lukas has joined #crystal-lang
elbow_jason has quit [Quit: Leaving]
k2b6s9j has joined #crystal-lang
waj_ has joined #crystal-lang
kyrylo has quit [Quit: Konversation terminated!]
kyrylo has joined #crystal-lang
ssvb has quit [Ping timeout: 250 seconds]
qard has joined #crystal-lang
qard has quit [Quit: Textual IRC Client: www.textualapp.com]
k2b6s9j has quit [Quit: Textual IRC Client: www.textualapp.com]
kyrylo has quit [Ping timeout: 265 seconds]
bjmllr has joined #crystal-lang
havenwood has quit [Ping timeout: 265 seconds]
waj_ has quit []
havenwood has joined #crystal-lang
czaks has joined #crystal-lang
blue_deref has joined #crystal-lang
elia has joined #crystal-lang
elia has quit [Client Quit]
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
ssvb has joined #crystal-lang
blue_deref has quit [Quit: bbn]
Ven has joined #crystal-lang
Ven has quit [Remote host closed the connection]
sdogruyol has joined #crystal-lang
BlaXpirit has joined #crystal-lang
sdogruyol has quit [Ping timeout: 255 seconds]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Remote host closed the connection]
Ven has joined #crystal-lang
sdogruyol has joined #crystal-lang
sdogruyo_ has joined #crystal-lang
sdogruyol has quit [Read error: Connection reset by peer]
kulelu88 has joined #crystal-lang
zamith has joined #crystal-lang
kyrylo has joined #crystal-lang
sdogruyo_ has quit [Quit: Leaving...]
bawNg has joined #crystal-lang
zamith has quit [Quit: Be back later ...]
<bawNg> Hi everyone. Has anyone created .Net bindings for Crystal yet?
<BlaXpirit> bawNg, that sure is strange
<BlaXpirit> what does that even mean?
<bawNg> I'd like to use Crystal as a scripting language for a .Net framework
<BlaXpirit> bawNg, it's not even a scripting language -_-
<bawNg> Neither is C#, but that doesn't stop people from using it as one
<BlaXpirit> in fact, .NET languages are closer to scripting languages than Crystal
<bawNg> The only .Net implementation of Ruby is old and abandoned, so if there were bindings for Crystal, that would be great, as I am a huge fan of Ruby syntax
<BlaXpirit> it's just inapplicable
<BlaXpirit> another thing you may not have noticed, Crystal does not yet work on Windows
<bawNg> That is a shame, I planned on eventually using mruby, but that is still many years away from being sufficiently optimized and mature, it's currently far too slow as far as I know
<bawNg> Our modular .Net game server modding framework currently supports C#, LuaJIT, V8 JS, Python for sandboxed plugins. Although the majority of supported games are Unity based, we also support other .Net engines. We are also working towards supporting Unreal engine with a native bridge
<bawNg> C# plugins are compiled on the fly, their .Net IL is patched by a lightweight sandbox process before being loaded
zamith has joined #crystal-lang
zamith has quit [Client Quit]
sleeper_ is now known as sleeper
<dzv> bawNg: unless there's CLR output for LLVM or someone writes a CLR substitute for the current LLVM code it's never going to work. there are other issues such as relying on POSIX functions directly from libc but those are minor compared to the first issue
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<bawNg> To be honest, Crystal seems better suited as a replacement for .Net, especially for the native support we are currently moving towards. Unfortunately I'll have a very hard time convincing the rest of our team to scrap years of work in favour of creating a new framework in a language that no one is familiar with
<jhass> tbh it might be a bit early anyway, the language might still break everything with every single release, we still have some road to 1.0
<bawNg> Looks like there are quite a few different LLVM bindings for .Net
<bawNg> I know it's still very early, but it feels like Crystal may be usable before mruby
<bawNg> Keep in mind, we don't have any issues with living on the bleeding edge, you could even say we thrive on it. Our modular modding framework supports a large number of game servers, all support is entirely reverse engineered, including the servers which are heavily obfuscated
<Netfeed> http://pastebin.com/TGpdYzaY <-- im getting this error when i try to run the specs in the crystal main repo, does that mean that i've missed installing something? doesn't look like a "library not found error"
<BlaXpirit> Netfeed, it actually kinda is
<BlaXpirit> looks like old version of libgc or something
<BlaXpirit> i had this errror just the other day
<BlaXpirit> what distro, Netfeed?
<Netfeed> ubuntu 14.04
<bawNg> Although Unity3d uses a mono fork which is many years outdated and forces the game developers to be limited to .Net 3.5 and C# 3 syntax, our framework allows plugins to be written using bleeding edge C# 6 syntax
<BlaXpirit> ah, Netfeed, i have something just for you http://blaxpirit.com/blog/18/compile-crystal-on-ubuntu-14-04.html
<BlaXpirit> if you installed crystal from official repository, then just go right for the last line
<bawNg> We have come across many Mono bugs since introducing support for C# 6 syntax, luckily the mono devs are active and fix them pretty quickly
<Netfeed> BlaXpirit: nice, thanks
<BlaXpirit> Netfeed, try the last line and then if it there is an error you may have to do the llvm step
<Netfeed> that did the trick, thanks!
<BlaXpirit> too bad that google still pretty much ignores my blog
<BlaXpirit> i mean, it doesn't ignore, but rankings are garbage
willl has quit [Quit: Connection closed for inactivity]
Gues_____ has joined #crystal-lang
Gues_____ is now known as tatey
tatey is now known as tatey__
<tatey__> Hey. I'm having a play with Cyrstal and I'm writing a spec where I'm comparing the equality of two static arrays. The test is failing, but the printed values are the same. What should I do differently?
<BlaXpirit> tatey__, well it's too bad that crystal has the same inspect output for two different types
<BlaXpirit> tatey__, i would guess that one of them is Array and the other is StaticArray or Slice
<BlaXpirit> or maybe staticarrays aren't considered to be equal when they have the same contents
<BlaXpirit> tatey__, just do to_a on both parts to be sure
<BlaXpirit> or if you want to dig in, do some debug outputs
<BlaXpirit> p message.target.class
<czaks> a quick question: crystal on emscripten? did anyone try it?
<tatey__> Ah, cool. Thanks for the suggestion. I just printed the class and it's definitely the same type.
<jhass> tatey__: BlaXpirit actually we're missing StaticArray#== https://github.com/manastech/crystal/issues/1205 :/
<BlaXpirit> [:32:14] <BlaXpirit> or maybe staticarrays aren't considered to be equal when they have the same contents
<BlaXpirit> >> StaticArray(UInt8, 8).new(0_u8) == StaticArray(UInt8, 8).new(0_u8)
<DeBot> BlaXpirit: # => false - http://carc.in/#/r/c6h
<tatey__> BlaXpirit: Ah, that's it then. If I call `to_a` then they're considered equal.
<jhass> sounds like a sane workaround for now
Ven has joined #crystal-lang
<jhass> or you write StaticArray#== monkey patch it into your project and open a PR so you can drop the monkeypatch with the next release :P
<czaks> nice, well, i'm impressed with the Crystal, after learning about it yesterday
<tatey__> That'd work.
<czaks> i thought it's nearly impossible to do optimized ruby
<jhass> well, it really isn't Ruby anymore ,)
<tatey__> jhass: I tried to find where `eq` was being defined in the Crystal source code. I'm guessing it's a macro? Does `eq` do a `==` under the hood?
<czaks> sure it isn't, but it's sort of compatible
<tatey__> I showed a bunch of Rubyists Crystal today and they were really impressed.
<BlaXpirit> should i try to implement an alternative way to do specs, without learning that DSL?
<jhass> czaks: to the mind, yeah. To the code really not so much ;)
<tatey__> jhass: Ahh cool. Thanks for the link. Might have an attempt at that monkey patch and a PR ;-)
<BlaXpirit> like that assert macro i was talking about
<jhass> tatey__: great!
<BlaXpirit> jhass, what do you think people would think about it?
<tatey__> You've all been very friendly. Thanks for the help :-)
<czaks> well, in my dreams, i could do webdevelopment in a single language
<jhass> BlaXpirit: check minitest.cr
<czaks> that's why i like opal, but opal has performance problems
<tatey__> BlaXpirit: Not a fan of RSpec-like syntax?
<BlaXpirit> definitely not
<BlaXpirit> tatey__, crystal can do better
<BlaXpirit> just write normal code and introspect the AST in a macro to have the same nice diagnostic output
<tatey__> I thought it was interesting that Crystal has the old, `foo.should bar` syntax when RSpec has moved on to `expect(foo).to bar`.
<BlaXpirit> there are probably many efforts to do this that i dont know about
<jhass> hehe, yeah we had about 3 PRs trying to change that :P
<tatey__> jhass: Cheers
<BlaXpirit> but i made a small example that isn't hard to dig into http://blaxpirit.com/blog/17/detailed-assert-macro-for-crystal.html
<czaks> by the way, nothing like gem yet, right?
<jhass> czaks: there's crystal deps which reads a Projectfile to determine what repos to clone from github and then symlinks into the right paths so you can do require "foo" after that
<dzv> and there's crystal shards
<jhass> but it's going to change heavily and there's also https://github.com/ysbaddaden/shards
<czaks> that's great
<BlaXpirit> jhass, what about minitest.cr?
<jhass> supports more unit test style syntax
<BlaXpirit> that's just more ugly DSLs to learn
<BlaXpirit> i wanna go in the opposite direction
<jhass> it's pretty much just a runner for plain classes, could pluck your assert macro in easily
<BlaXpirit> wooow, power_assert actually already works with spec in mind!!
<BlaXpirit> so awesome
<BlaXpirit> no idea why i didn't look at it in more detail
<Netfeed> there's no way to generate the text "GMT" in a timezone string right now? %z gives +0000 now
<BlaXpirit> Netfeed, well that's the standardized way to do things
<Netfeed> what do you mean?
<Netfeed> can't use an iso-date sadly
<tatey__> Is there a convention for where to put monkey patches in libraries? Like src/extensions/my_patch.cr?
<czaks> another thing that bothers me in Ruby and Crystal may fix it (or it already did): in Ruby there are just Arrays and Maps in standard library. and as we all know, some algorithms work better on other structures
<czaks> for instance like Lists
<czaks> in java there are lots of data structures to use out of the box
<BlaXpirit> czaks, trying to fix that :p https://github.com/manastech/crystal/pull/1246
<BlaXpirit> but generally, why not just use some 3rd party library
<jhass> tatey__: not really yet, I roughly adopted Ruby's, src/my_lib/core_ext/class.cr
<tatey__> jhass: Cool. Works for me.
<jhass> czaks: yeah, my opinion is to just use a third party library if you need an optimized DS, that's not too common to do in Ruby land even though I'm sure there are a couple of gems for it, but given Crystal's focus on performance it might develop to a habit here
<jhass> czaks: I don't like Java's approach of a standard library providing every corner case so much because then you get confused at about what to use as default and also wonder about what to use now where you didn't even identify a bottleneck yet
<Netfeed> jhass: :)
<Netfeed> i can write patches to stuff, but time and timezones is stuff i really don't want to be involved with :P
<jhass> yeah, understandable we also have no tzdata binding whatsoever yet :P
<jhass> *given we
<Netfeed> yup
<Netfeed> and no documentation for the format, i had to read the code for doing what i wanted, i guess that would be more simple to contribute too :)
<jhass> of course, we take everything we can get :P
Ven has quit [Remote host closed the connection]
Ven has joined #crystal-lang
<crystal-gh> [crystal] tatey opened pull request #1250: Add StaticArray#== for equality comparisons (master...static-array-equality) http://git.io/vsRHb
<tatey__> jhass: There's that PR ;-)
<jhass> <3
ssvb has quit [Ping timeout: 244 seconds]
<bawNg> I hope someone can find time to continue working on Windows support soon, there is a lot I would like to use Crystal for in the future, but I'm unfortunately forced to target Windows
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vsRj6
<crystal-gh> crystal/master bf0f6c9 Ary Borenszweig: Simpler spec implementation: no need to redefine main
<tatey__> I've got an enum which I'm using to map an integer to a C struct. I could write out a big switch statement manually, but macros feel like they would be a good fit here. Is it possible to do something like https://gist.github.com/tatey/3c95626750b7a02ffd23?
<BlaXpirit> tatey__, please say what you actually want
<BlaXpirit> do you want to turn a number into enum item?
<BlaXpirit> in that case, use Type.new(number)
<BlaXpirit> no, that's not right
<jhass> tatey__: there are lib-level enums, maybe you want that?
<jhass> oh, I think I see
<jhass> tatey__: when {{value}} too
<tatey__> BlaXpirit: Not quite. I have an instance of `Type` and I want to get an associated C struct based on that.
<jhass> or ^ yeah
<Netfeed> i have to write a few more tests and then i think i have a working cookie impl for the HTTP module
<jhass> Netfeed: nice!
<BlaXpirit> tatey__, "struct"? oh that's different
<jhass> tatey__: oh and I guess you need to wrap the whole thing into {% if true %} so the result of the macro is a valid expression
<tatey__> I basically want Type::Foo to return C::LXFoo.
<BlaXpirit> tatey__, you're moving in the right direction
<tatey__> Type::Foo.c_struct
<tatey__> Err, #
<BlaXpirit> tatey__, have you tried replacing def with macro ?
<BlaXpirit> because it looks totally fine otherwise
<BlaXpirit> but why, jhass? why not just make it a macro?
<jhass> because there's actually no need to generate half a dozen methods when one works just fine
<tatey__> ^
<jhass> I didn't test my idea, does it work? :P
<BlaXpirit> it's just so wrong - this {% if true %}
<BlaXpirit> i have no idea
<jhass> BlaXpirit: never look at Tuple then :P
<tatey__> Thanks jhass. I'll give that a shot.
<tatey__> Just CMD + K my IRC client instead of my terminal :(
<tatey__> jhass: Wrapping the whole thing in that macro syntax worked great.
<BlaXpirit> why is this so?
<BlaXpirit> and how is someone supposed to know about this hack?
<tatey__> Looks like @type.values doesn't work though. I though @type would give me `Type`, but it gives me `TypeNode`.
<jhass> BlaXpirit: because the result of a macro expression must be a valid Crystal expression
ytti has quit [*.net *.split]
ssvb has joined #crystal-lang
<jhass> if you don't wrap it your macro starts at the {% for, not at the start of the method
<BlaXpirit> ok, so the "why" part seems to be clear now
<tatey__> Yeah, it's like the compiler tried the case statement first, then it got the macro half way through. This treats the whole definition as a macro.
<tatey__> (That made more sense in my head)
<BlaXpirit> feels like there should be some syntax for this
<BlaXpirit> to make like a macro but wrapped in a method
<BlaXpirit> + I think replacing `def` with `macro` would work, but the difference would be in force inlining
<jhass> tatey__: http://carc.in/#/r/c72 there we go, sorry for the messy indentation
<tatey__> jhass: Champion. That worked a treat! https://gist.github.com/tatey/b7fe5a95eba5cbf47757
Ven has quit [Read error: No route to host]
<tatey__> Where does `@constants` come from?
<tatey__> Oh.
<tatey__> Thanks :-)
Ven has joined #crystal-lang
<tatey__> Can you check if a type is defined? Sort of like Ruby's const_defined?(:FOO) to check if `FOO` is defined?
ytti has joined #crystal-lang
<jhass> I don't think so
<jhass> why would be unsure about that?
<jhass> I think a lot of the defined? usages in Ruby are abuses
<BlaXpirit> is it possible to try to require a library but in case it can't be imported add some fallback code?
<jhass> I don't think so
<jhass> maybe some load path trickery, but meh
<BlaXpirit> hmm i guess there could even be 2 cases for this
<BlaXpirit> one is there is no such crystal file or it doesn't compile
<BlaXpirit> and the other is some lib (.so) is missing
<BlaXpirit> let's say my code can work better with some .so but it can also work without it
<jhass> well yeah, those are quite distinct cases
<BlaXpirit> jhass, distinct in general
<BlaXpirit> but if you consider that I want to require XML
<BlaXpirit> and it fails because libxml is missing
<jhass> currently there's no active presence check for .so's we just try to link against them and let that fail
<BlaXpirit> then these 2 cases are merged into one
<jhass> the require wouldn't break
<jhass> the linking after the crystal compiler has pretty much done its job would
<jhass> @[Link] is just a note for what to append to the linker command
<tatey__> jhass: Fair enough. Thanks anyway.
<BlaXpirit> jhass, the linking works, but i mean what if the library is missing at runtime
<jhass> uh
<tatey__> jhass: Not all my types map to structs. Some of them have no structs as they have no corresponding payload. Instead of checking to see if the constant is defined, I just alias those ones to Nil. Much cleaner than doing a defined check too :-)
<jhass> can you even recover from that after being linked?
<jhass> isn't that check done by the loader before any of your code runs?
<jhass> and to recover we would need to implement our own loader?
<BlaXpirit> I don't know how it works, but since it's dynamic it's possible to detect
<jhass> (which is what ffi does I guess)
<BlaXpirit> oh well, i'm asking too much
<tatey__> I'll probably switch away from using nil to my own explicit `NoPayload` type or something.
hiroki has joined #crystal-lang
<jhass> tatey__: mmh, I guess the way too go is something like {% C.constants.include? "LX#{value}" %} or so (doubt that works, but the general approach)
<tatey__> I did try that :-)
<jhass> {% if of course
hiroki has quit [Client Quit]
<jhass> undefined macro method 'ArrayLiteral#includes?' meeh
<jhass> really thought we had that
<jhass> tatey__: http://carc.in/#/r/c79
<jhass> not pretty due to missing includes?, but yeah :P
<BlaXpirit> i used `any?` when i had this problem
<tatey__> Oh, neat.
<jhass> if any of you wants to do #includes?, https://github.com/manastech/crystal/blob/master/src/compiler/crystal/macros/methods.cr#L381 here's where it would go
<jhass> the spec would need to be commented out until the next release
<jhass> I think
<jhass> or maybe there's something to test macro methods earlier, I forgot
<manveru> jhass: how does concurrency look like atm?
<manveru> is it just fibers?
<jhass> pretty much, IO is broken in Thread
<manveru> how does that avoid zombies etc?
<jhass> mmh?
<asterite> listen_fork will be removed
<jhass> oh
<manveru> ok :)
<jhass> yeah, fork is fairly broken too :P
<manveru> is anyone working on a doc site that actually links to the documented code?
<jhass> crystal-lang.org/api does?
<manveru> no
<manveru> well, for a couple of methods it does
<jhass> what cases do you miss?
<manveru> but if you try to get docs for ::print or BigInt#new :P
<manveru> it just doesn't do anything when i click those
<manveru> oooh
<jhass> oh, you mean the jump links in the index?
<manveru> yeah
<manveru> that's been confusing me
<jhass> yeah broken for me too, I think asterite claimed they work for him
<asterite> Where?
<jhass> pretty much everywhere
<jhass> few of the method summary jump links are working
<jhass> at least here on FF
<manveru> i think in theory they should work...
<asterite> Hm, it works in chrome, I never tried in FF
<asterite> In any case that page shouldn't use frames
<jhass> I think it's some URL encoding issue
<manveru> well, things like "new%28num%20%3A%20UnsignedInt%29-class-method" are bound to be problematic...
<manveru> how's that even a valid id
<jhass> we should just write a generator for devdocs.io :P
<manveru> i'd just change the anchor method
<manveru> seems simple enough :)
<jhass> should be relevant code
<BlaXpirit> yeah, anchors are broken for sure
<BlaXpirit> works rarely
<manveru> yeah, found that already... will see if i can get docs built locally
<jhass> make doc iirc
<tatey__> I'm headed off. jhass thanks again for your help.
<jhass> though iirc you need to recompile the compiler to pick up changes
tatey__ has quit []
<jhass> so more make clean crystal doc
<manveru> looks like 2GB isn't enough to build this :(
<jhass> ah yeah, it's a bit memory hungry
<jhass> would be interesting to see where it's spent actually, I think most is codegen
<jhass> llvm's that is
willl has joined #crystal-lang
blue_deref has joined #crystal-lang
strcmp1 has quit [Ping timeout: 255 seconds]
trapped has quit [Ping timeout: 260 seconds]
<manveru> so... i'm trying to build with some more ram now
<manveru> after getting `llvm libreadline-dev libedit-dev libevent-dev libpcl1-dev libgc-dev libunwind-dev`... i'm still getting errors :(
<manveru> Fiber:(.text+0x193): undefined reference to `co_set_data'
<BlaXpirit> manveru, another one with this error!
<BlaXpirit> which distro?
<manveru> ubuntu
<BlaXpirit> which
<manveru> 15.4
havenwood has joined #crystal-lang
<manveru> it's a DO box i setup yesterday, but ran update/upgrade already
<BlaXpirit> well that one's on Crystal, why does it require such a new lib?
<BlaXpirit> manveru, do you have Crystal installed from repository?
<manveru> yeah
strcmp1 has joined #crystal-lang
<BlaXpirit> env LD_LIBRARY_PATH=/opt/crystal/embedded/lib/ LIBRARY_PATH=/opt/crystal/embedded/lib/ make
<manveru> fun stuff
<jhass> BlaXpirit: https://github.com/manastech/crystal/tree/new-fibers will drop that dependency ;)
<jhass> actually you don't even need the LD_LIBRARY_PATH
<jhass> LIBRARY_PATH is enough
<manveru> that worked either way
<manveru> thanks man
sleeper is now known as sleeper_
havenwood has quit [Ping timeout: 255 seconds]
Ven has quit [Read error: Connection reset by peer]
RX14 has joined #crystal-lang
trapped has joined #crystal-lang
Ven has joined #crystal-lang
elbow_jason has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kulelu88 is now known as kulelu88_afk
leafybasil has quit [Read error: Connection reset by peer]
shama has joined #crystal-lang
leafybasil has joined #crystal-lang
NeverDie has joined #crystal-lang
qard has joined #crystal-lang
<Netfeed> "make spec" takes a while
<BlaXpirit> Netfeed, yup
<jhass> yeah
<BlaXpirit> why is mac so fast there?
<jhass> happened to be a slow build and it's legacy infra
luislavena has joined #crystal-lang
<BlaXpirit> i thought it happens all the time, because in builds for my pull requests linux also was slower
luislavena has left #crystal-lang [#crystal-lang]
ssvb has quit [Ping timeout: 246 seconds]
<jhass> yeah as said, using legacy infra
<RX14> using http/server and returning a reponse with a null body seems to hang the webserver
<jhass> the PR I linked changes that
<jhass> RX14: code?
<RX14> ehh let me isolate it
<crystal-gh> [crystal] netfeed opened pull request #1252: HTTP Cookie handling (master...http_cookie) http://git.io/vsEbW
luislavena has joined #crystal-lang
<RX14> jhass, https://gist.github.com/RX14/5d185df9b2165a00d4ce seems to reproduce
<Netfeed> BlaXpirit: ran in 3 minutes on my machine
<Netfeed> maybe closer to four
<BlaXpirit> Netfeed, that's probably close to average
<Netfeed> readline-dev seems to missing from required libraries though
<jhass> yeah, the travis build should have about 40sec to a minute setup and I guess 20 to 30 sec for compiling the samples
luislavena has left #crystal-lang [#crystal-lang]
<jhass> Netfeed: it's a wiki ;)
<RX14> it seems that null causes curl and browsers to hang, but an empty string does not
<jhass> RX14: indeed, please open an issue with that code
<RX14> it means in my aplication I need to set the body to a blank string before returning a HTTP error code :(
<Netfeed> jhass: :)
<Netfeed> RX14: i've noticed that too, but i thought it was as it should be
<RX14> artanis examples said you coudl do it, and it seemed like a bug
<RX14> and hanging the client is the wrong behaviour always
<RX14> so bug report time
Ven has joined #crystal-lang
<Netfeed> jhass: should each fix be it's own commit? one for the timeformat error and one for removing return in return nil for example? what's best practice here?
<jhass> Netfeed: I amend code review corrections into the commits that introduced them
<Netfeed> ok, this is something completly new for me, how do i do that?
<jhass> I keep individual changes (introduce date parsing helpers, add cookie classes, use new classes to handle cookies) in their own commits, compared to the target branch
<jhass> given you have a single commit, you can just git commit --amend -p and force push
<Netfeed> ooh, yeah, you mean that way, sure
ssvb has joined #crystal-lang
<Netfeed> jhass: $~ exists, but not Regex.last_match, is the latter something that should be added later?
<jhass> weird, I thought we had that
<jhass> $~ it is then
grindhold_ has quit [Quit: No Ping reply in 180 seconds.]
<Netfeed> made it more "perly" :)
<jhass> eh yeah, but critical enough code to save the extra call to pcre ;)
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Netfeed> hmm, i think i screwed that up, i did a bunch of stuff instead of the git commit --amend -p, because i didn't think it through properly and now i have one commit with the changes i made in it instead and i can't really rebase up anymore, is there a way to fix this?
<jhass> "can't really rebase up anymore"?
<jhass> if you have two commits you want to combine, git rebase -i master, change pick to squash or fix for the second one
* Netfeed has no git-fu at all
<jhass> it comes with time
<Netfeed> is it really safe to force push?
<jhass> to a feature branch? sure
<Netfeed> scary :)
<Netfeed> alright, some changes is in now
<Netfeed> thanks for the help
<jhass> thanks for the contribution!
elbow_jason has quit [Quit: Leaving]
<Netfeed> hmm, i can use the Warning header more than once
<crystal-gh> [crystal] will opened pull request #1254: StringScanner (master...stringscanner) http://git.io/vsuGa
<Netfeed> alright, two comments left, and i don't really know about them, not sure what's idiomatic here
<jhass> it's not so much about being idiomatic as much more that I feel like the current approach is making the methods do too much
<jhass> or know too much
<Netfeed> yeah, maybe
<jhass> having to introduce two new params because you need to pass down info you have only elsewhere is a pretty clear sign for that tbh
<jhass> I remember right that request is always Cookie and Response is always Set-Cookie, right?
<Netfeed> there's one missing use case too with multible name=value pairs in one cookie, "n1=v1, n2=v2; Path=/", but i'm not really sure how that should be handled as that there, might be a problem with expires then
<Netfeed> jhass: that's correct
<jhass> so having Request just add Cookie headers it its @headers when passing them down for serialization and Response doing the same for Set-Cookie headers feels a lot cleaner for me
<jhass> as I wrote something like @cookies.add_request_headers(@headers) and @cookies.add_response_headers(@headers)
<Netfeed> but there's one @cookies per request/response and the server doesn't need to respond with the cookies you send
<jhass> those two could then delegate to add_headers "Cookie", headers and add_headers "Set-Cookie", headers respectively
<jhass> just return headers if empty?
Codefriar has quit [Read error: Connection reset by peer]
<jhass> Netfeed: mmh, what do you think, is there actually a good reason to hide the cookie headers while parsing? Why not include them and have cookies merely as a convenience access to them?
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<RX14> damn I want a crystal repl :P
<jhass> RX14: very hard to do unfortunately
<RX14> yeah I'm sure
<RX14> crystal eval is okay though
<Netfeed> jhass: i think the should be split honestly, but i'm considering adding something like Headers#add_cookie(String, Cookies) or something and just show them in there before the write
<Netfeed> jhass: and then remove the cookie handling from HTTP#serialize...
<jhass> Netfeed: to clarify my thinking goes like this http://paste.mrzyx.de/p49ps3d6j
strcmp1 has quit [Quit: Leaving]
<Netfeed> yeah, sure, i'm fine with that
<Netfeed> want me to add it or do you want to do it yourself?
<jhass> btw I don't have commit rights or anything ;)
<Netfeed> that's true
<jhass> it's my suggestion and opinion, take it or leave it ;)
<jhass> (if you want to apply the diff, just paste/pipe it to git apply, I think there's a spec or two that needs fixing then)
<Netfeed> yeah, done that
<Netfeed> i'm thinking about what happens if you parse a request/response and then want to add/remove headers, but i don't think that's actually a use case
<jhass> well yeah, the cookies/headers won't stay in sync, mmh, that's actually a fairly good argument for hiding them
<RX14> how can I send a type to a method then invoke a static method on that type?
<Netfeed> def func(type); type.method; end; func(SomeClass)
<Netfeed> jhass: adding "headers.delete key", to from_headers would solve that
<jhass> Netfeed: yeah
<RX14> Netfeed, and what is the type of "type"? I want only subclasses of one type
<RX14> can I do : X.class
<jhass> RX14: iirc yes
<jhass> >> abstract class Foo; abstract def self.foo; end; class A < Foo; def self.foo; :a; end; end; class B < Foo; def self.foo; :b; end; def test(t : Foo.class); t.foo; end; {test(A), test(B)}
<DeBot> jhass: Syntax error in eval:11: expecting identifier 'end', not 'EOF' - http://carc.in/#/r/c7z
<jhass> derp
<jhass> >> abstract class Foo; abstract def self.foo; end; class A < Foo; def self.foo; :a; end; end; class B < Foo; def self.foo; :b; end; end; def test(t : Foo.class); t.foo; end; {test(A), test(B)}
<DeBot> jhass: # => {:a, :b} - http://carc.in/#/r/c80
<jhass> \o/
<jhass> >> abstract class Foo; abstract def self.foo; end; class A < Foo; def self.foo; :a; end; end; class B < Foo; def self.foo; :b; end; end; def test(t : Foo.class); t.foo; end; {test(A), test(String)}
<DeBot> jhass: Error in line 4: no overload matches 'test' with types String:Class - http://carc.in/#/r/c81
<RX14> well, i guess that works
<RX14> as ugly as it is
<RX14> i mean the ; everywhere because of all in one line
<Netfeed> you can do something like def func(cls : Int32.class | Int64.class)
<RX14> i guessed
strcmp1 has joined #crystal-lang
<BlaXpirit> i want to define == != < > <= >= for my class
<BlaXpirit> do i have to define all 6, or is there a way to do less
<BlaXpirit> i am only interested in a solution with 0 overhead
<jhass> BlaXpirit: check Comparable
<BlaXpirit> doesn't look like that's 0 overhead
<jhass> in practice the call to <=> will be inlined
<Netfeed> == and != is kinda easy isn't they? != would just be ! self == other ?
<BlaXpirit> the implementations are all trivial in my particular case
<jhass> != should actually be a syntax level rewrite to that
<BlaXpirit> why isn't != in comparable?
<jhass> >> class Foo; def ==(o); true; end; def !=(o); true; end; end; Foo.new != 1
<DeBot> jhass: # => true - http://carc.in/#/r/c82
<jhass> mmh
<jhass> >> class Foo; def ==(o); true; end; end; Foo.new != 1
<DeBot> jhass: # => false - http://carc.in/#/r/c83
<jhass> er
<jhass> >> class Foo; def ==(o); false; end; end; Foo.new != 1
<DeBot> jhass: # => true - http://carc.in/#/r/c84
<jhass> there, it at least falls back to it
<BlaXpirit> so is != defined?
<BlaXpirit> for everything?
<jhass> yeah, prolly Object
<BlaXpirit> sure is
<jhass> uses ==
<BlaXpirit> that's as good as on a syntax level
<BlaXpirit> cuz LLVM optimizes everything, right?
<jhass> yeah
<Netfeed> you just need to impelemtn <=> for compareable?
<BlaXpirit> oh, to hell with 0 overhead
<jhass> Netfeed: yeah
<BlaXpirit> def <=>(other: Time); microseconds <=> other.microseconds; end
<BlaXpirit> perfect
<Netfeed> that's kinda nice, alot of features with just one method and an include :)
<BlaXpirit> python had something similar but dropped it D:
<jhass> one spaceship to rule them all
<BlaXpirit> but they have autoimplementation based on == and < instead of this <=>
<jhass> mmh, doesn't make that two calls for <=, >= and > though?
<BlaXpirit> no
<BlaXpirit> a <= b : not(a > b) a >= b : not(a < b)
<BlaXpirit> a > b : b < a
<jhass> ah, right
<jhass> though swapping receivers is kinda meh
Codefriar has joined #crystal-lang
Codefriar has quit [Ping timeout: 255 seconds]
Codefriar has joined #crystal-lang
<crystal-gh> [crystal] PragTob opened pull request #1257: Remove the Enumerable#first(n) alias for Enumerable#take(n) (master...remove-first-alias) http://git.io/vszZK
etrepat has joined #crystal-lang
Codefriar has quit [Read error: Connection reset by peer]
elbow_jason has joined #crystal-lang
Codefriar has joined #crystal-lang
etrepat has quit [Client Quit]
etrepat has joined #crystal-lang
etrepat has quit [Client Quit]
<crystal-gh> [crystal] asterite pushed 3 new commits to master: http://git.io/vsz5q
<crystal-gh> crystal/master 03a1de9 Ary Borenszweig: Put back MD5 in libcrypto
<crystal-gh> crystal/master 7509c5d Ary Borenszweig: Error if yielding outside a method (instead of a compiler crash)
<crystal-gh> crystal/master 4570084 Ary Borenszweig: Unbind block args from yields on call recalculation. Related to #1242
BlaXpirit has quit [Quit: Konversation]
<travis-ci> manastech/crystal#4570084 (master - Unbind block args from yields on call recalculation. Related to #1242): The build passed. https://travis-ci.org/manastech/crystal/builds/76712874
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
zamith has joined #crystal-lang
Sadin has joined #crystal-lang