ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.1 | Fund Crystal's 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
<FromGitter> <Zhomart> Cool!
onionhammer has quit [Read error: Connection reset by peer]
onionhammer has joined #crystal-lang
bmcginty has quit [Ping timeout: 240 seconds]
bmcginty has joined #crystal-lang
sz0 has joined #crystal-lang
bmcginty has quit [Ping timeout: 260 seconds]
bmcginty has joined #crystal-lang
phase_ has joined #crystal-lang
<FromGitter> <jwoertink> I saw that `HTTP::Client` doesn't support proxy yet
<FromGitter> <jwoertink> Anyone know if this is planned soon? https://github.com/crystal-lang/crystal/issues/2963
<FromGitter> <jwoertink> I saw this as well https://github.com/bbtfr/proxy.cr Anyone try this out yet?
<FromGitter> <jwoertink> ^ this looks like it's only for HTTP::Server for now. I don't see anything client related
phase_ has quit [Quit: cya l8r alig8r]
bungoman has quit [Read error: Connection reset by peer]
sz0 has quit [Quit: Connection closed for inactivity]
akwiatkowski has joined #crystal-lang
<FromGitter> <Zhomart> Hi, how to remove element from `HashLiteral`?
<FromGitter> <KCreate> are you inside a macro?
<FromGitter> <Zhomart> yes
<FromGitter> <KCreate> I don't think you can remove elements directly but you can map over keys and values of the HashLiteral
<FromGitter> <sdogruyol> @bew how was the meetup
<FromGitter> <Zhomart> I decided to use following. How can I improve it? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58d22d81b809ca5f4a6d311c]
<FromGitter> <KCreate> The macro looks okay, but are you sure you need a macro here?
mark_66 has joined #crystal-lang
ssvb has quit [Remote host closed the connection]
akwiatkowski has quit [Ping timeout: 240 seconds]
bjz has joined #crystal-lang
<FromGitter> <Zhomart> @KCreate yes, I was thinking adding int64 to id in https://github.com/topaz-crystal/topaz
<FromGitter> <KCreate> I'm not familiar with topaz, what do you mean by adding int64 to id?
akwiatkowski has joined #crystal-lang
<FromGitter> <Zhomart> I meant that I cannot get rid macro. https://github.com/topaz-crystal/topaz/blob/master/src/topaz/model.cr#L13
<FromGitter> <faustinoaq> Hi, Is posible to do dinamic library loading in Crystal? I saw dlopen in LibC but I don't know how it works
<FromGitter> <faustinoaq> I was inspired by http://nullprogram.com/blog/2014/12/23/
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
<FromGitter> <KCreate> There is this: https://crystal-lang.org/api/master/DL.html
<FromGitter> <KCreate> I haven't used it and I'm also not sure how well it works
<FromGitter> <KCreate> Or how to use it at all :laughing:
<FromGitter> <faustinoaq> :sweat_smile:
gloscombe has joined #crystal-lang
bjz_ has quit [Ping timeout: 260 seconds]
bjz has joined #crystal-lang
Qchmqs has joined #crystal-lang
gloscombe has quit [Remote host closed the connection]
<FromGitter> <exts> Can anyone help me with this compile error? http://pastebin.com/raw/6nh32B3T basically was trying to use this cURL shard and it's giving me an undefined reference to symbol '_end' error ⏎ ⏎ The cURL shard I'm 'testing' https://github.com/blocknotes/curl-crystal and I've gotten the error using the 2 line print curl version snippet on that page.
<FromGitter> <exts> and i'm on linux mint if that helps anything
<FromGitter> <KCreate> Excuse the silly question but, is libcurl installed?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> @exts why are you using the cURL shard?
<RX14> I would really not recommend it if at all possible
<Papierkorb> huh Object#clone isn't defined by default
<jokke> Papierkorb: how could it?
<jokke> ruby's clone almost never behaves as you'd expect it to
<jokke> so i think a sane default is to leave it to the programmer
<Papierkorb> jokke: "how"? By a macro
<Papierkorb> And it's just not useful to not being able to clone stuff, as stuff using that stuff can't be cloned either
<Papierkorb> There's `def_clone` for this, but having to patch every class isn't fun nor clean
<Papierkorb> jokke: We can learn from rubys mistakes
<Papierkorb> not to mention that not being able to clone stuff advocates to not-clone-stuff which isn't great in a parallel execution environment
<jokke> Papierkorb: is it not implemented in the stdlib's classes?
<Papierkorb> some seem to
<Papierkorb> I'd rather have it opt-out than opt-in
<jokke> hm
<jokke> well i guess it's a matter of preference. I think it's most robust the way it is.
sz0 has joined #crystal-lang
<jokke> i guess clone _could_ be implemented so that it will clone all instance vars and set them to a new object. But think of the side effects: what if you have two an object A which has object B in an instance variable, and object B has object A in an instance variable...
<jokke> clone would be an infinite loop
<jokke> so you'd have to just copy references
<jokke> which is almost _never_ what you want
<jokke> think of ruby's clone on hashes
<Papierkorb> It's a solvable problem, and it's a problem that already exists
<jokke> foo = { foo: 'bar', baz: { foo: 'bar' } }; bar = foo.clone; bar[:baz][:foo] = 'wtf'; puts foo[:baz][:foo]
<jokke> Papierkorb: it's not a universally solvable problem imho
<Papierkorb> `pp` does it
<jokke> pretty print??
<Papierkorb> Yes?
<Papierkorb> The algorithm for cycle detection is no different?
<jokke> alright let's assume you detect a cycle. how will you handle it?
<Papierkorb> Simple? Just add the already cloned reference
<Papierkorb> Like pp displays a `...`
<jokke> mmh. you're right. but i doubt it's that trivial. i bet there are different corner cases we haven't thought of
<jokke> stuff that holds file descriptors for instance
<jokke> or sockets
<Papierkorb> dup()
<jokke> what about it?
<Papierkorb> file descriptors can be duplicated
<FromGitter> <bcardiff> Reference#dup has a default implementation https://github.com/crystal-lang/crystal/blob/master/src/reference.cr#L41
<Papierkorb> if that's useful for sockets? Probably not, but you'd most likely not clone a server or something
<FromGitter> <bcardiff> that does a shallow copy.
<Papierkorb> dup is useless
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vyjZA
<crystal-gh> crystal/master ce3492f Ary Borenszweig: Fixed #4166: Inlinable function call in a function with debug info must have a !dbg location
<RX14> is ary finally back?
<jokke> where was he?
<RX14> i don't know
<jokke> :)
<RX14> but he hasn't been active much the last 2 weeks
<FromGitter> <KCreate> vacation probably
<jokke> vacation maybe?
<Papierkorb> In reality, I want to clone a Crystal::Program, and ASTNode probably too. Both shouldn't hold fd's or something like that, so cloning them should be fine
<crystal-gh> [crystal] Sija opened pull request #4174: Implement Time#clone (master...add-time-clone) https://git.io/vyj8B
<travis-ci> crystal-lang/crystal#ce3492f (master - Fixed #4166: Inlinable function call in a function with debug info must have a !dbg location): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/213870062
<DeBot> https://github.com/crystal-lang/crystal/issues/4166 (Inlinable function call in a function with debug info must have a !dbg location)
Qchmqs has quit [Read error: Connection reset by peer]
<FromGitter> <Zhomart> Hi, how can I call different method by return type? ⏎ Is it possible to do something like this? Btw, is there method match like in elixir? ⏎ ⏎ ```def load(raw : String, Int64) : Int64 ⏎ .... ⏎ end ⏎ ⏎ load("123", Int64) == 123i64``` [https://gitter.im/crystal-lang/crystal?at=58d29a03a84f611959d0d5aa]
<FromGitter> <exts> @RX14 wanted to check if external file existed, then I just gave up and found out that HTTP::Client has a head method which does what I needed.
<FromGitter> <KCreate> @Zhomart what are you trying to do?
<RX14> yeah, always use HTTP::Client please, the cURL bindings don't go through crystal's IO system so they suck
<crystal-gh> [crystal] asterite pushed 2 new commits to master: https://git.io/vyj0E
<crystal-gh> crystal/master 6697f17 Ary Borenszweig: Missing debug wanted check (part of #4166)
<crystal-gh> crystal/master c069957 Ary Borenszweig: Travis: don't run in verbose mode
<RX14> @Zhomart you can't call methods by return type, mathods are matched by argument type
<FromGitter> <exts> got my little phpstorm updater working though, going to rewrite it so i can update any of jetbrains ide's on the fly
<FromGitter> <exts> sometime later after a brief session of mass effect ;)
<FromGitter> <Zhomart> @KCreate I want to write a method that accepts String, but might return Int32, Int64, Time, String depending on given type. ⏎ I don't want to write multiple methods, because calling those methods would be too verbose.
<RX14> you want the return type to depend on the parameter types?
<FromGitter> <KCreate> you can have the method return a union type
<FromGitter> <KCreate> `Int32 | Int64 | Time | String`
<RX14> @Zhomart can you please give an example or be more specific in what you mean.
<FromGitter> <KCreate> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58d29c7b58ad4eb0283f455e]
<FromGitter> <Zhomart> Sure. e.g. I want to create a method `load(raw : String)` that returns String, Time or Int32. ⏎ I can give this method what I want to receive. So I want to use the method like this: `load("123", Int32) == 123i32` or `load("12/12/2018", Time) == Time.new(2018, 12, 12)`.
<RX14> aha
<RX14> you can do this
<RX14> def load(raw : String, type : T.class) : T forall T
<RX14> the forall T syntax defines a type variable for a single method
<FromGitter> <KCreate> wouldn't that only work in a generic class?
<RX14> much like generics for classes
<FromGitter> <KCreate> oh
<FromGitter> <Zhomart> I think @KCreate method works for me too `foo("123").as(my_type)`. Thank you! ⏎ And `T for all T` looks really good.
<FromGitter> <Zhomart> Thank you!
<RX14> i'd recommend the generic method
<RX14> .as() with the union will probably be longer and more fragile
<FromGitter> <KCreate> @RX14 What are the differences between using the generic method and `def foo(klass : Class)`?
<FromGitter> <KCreate> https://carc.in/#/r/1qot
<RX14> that method doesn't have a different return type for each class passes
<FromGitter> <Sija> it’d return `Union`
<RX14> well that one doesn't return anything
<FromGitter> <Sija> considering exemplary code given by @Zhomart
<RX14> oh, that code got longer
<RX14> damn gitter...
<FromGitter> <KCreate> When using the generic method, `T` has to be a union of all types the method can return
<FromGitter> <Sija> isn’t it the other way around?
<RX14> no, it doesn't
<RX14> there will be a seperate return type for each T
<RX14> if you pass String, it will return a String instance
<FromGitter> <Sija> that’s what i meant
<RX14> thats what the type restriction says and what it enforces
<RX14> @Sija you're right
<FromGitter> <Sija> so that *wouldn’t* be an `Union`
<RX14> exactly
<FromGitter> <Sija> ok, we’re on the same page then :)
<FromGitter> <Sija> so `T` takes the type from the passed argument
<FromGitter> <Sija> otherwise it’ll return an `Union` of all possible types (by restriction or detected by the compiler)
<FromGitter> <Sija> otherwise: meaning not using generic method
<FromGitter> <Sija> aight?
mark_66 has quit [Remote host closed the connection]
<RX14> yes
<FromGitter> <Sija> @RX14 props for crane!
<FromGitter> <Sija> /away
<FromGitter> <Sija> damn gitter
<RX14> use irc!
<FromGitter> <Zhomart> Hey, thank you for all this info.
<travis-ci> crystal-lang/crystal#6697f17 (master - Missing debug wanted check (part of #4166)): The build was fixed. https://travis-ci.org/crystal-lang/crystal/builds/213884477
<DeBot> https://github.com/crystal-lang/crystal/issues/4166 (Inlinable function call in a function with debug info must have a !dbg location)
akwiatkowski has quit [Ping timeout: 260 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <asterite> def foo(arg : String, dummy : Int32.class) ...
<FromGitter> <asterite> def foo(arg : String, dummy : Time.class) ...
akwiatkowski has joined #crystal-lang
<RX14> you could do that, might be easier depending on the method impl
<FromGitter> <Zhomart> Oh, that looks interesting..
ssvb has joined #crystal-lang
ssvb has quit [Quit: Leaving]
bjz has joined #crystal-lang
sz0 has joined #crystal-lang
<FromGitter> <Sija> does anyone gets empty repo name and source links when using `crystal doc` from `master`?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <Sija> looks to me like it stems from `return false` in `src/compiler/crystal/tools/doc/generator.cr#295`
<FromGitter> <KCreate> Don't know if it's related but the "defined in" links are also gone on the official docs
<FromGitter> <KCreate> when using the master version
<FromGitter> <Zhomart> Hi, how to check if module or class defined? Ruby's alternative to `defined? PG`
leonardschuetz has joined #crystal-lang
<RX14> we don't really have an equivalent, what do you need it for
<FromGitter> <KCreate> Why would you need that? You can't add new modules or classes at runtime
leonardschuetz is now known as KCreate
<FromGitter> <Zhomart> I want to set variable depending on what db was loaded. e.g. if "pg" was loaded then I want to set specific flags.
<RX14> launching crystal 1000 times: 7s raw, 8.5s with crane version manager
bjz has joined #crystal-lang
KCreate has left #crystal-lang [#crystal-lang]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <bcardiff> @Zhomart may I ask what you are trying to acchieve? Maybe there is a way to abstract which driver you are using.
KCreate has joined #crystal-lang
<FromGitter> <fridgerator> ah yeah, I had the same issue that I still haven't resolved: https://github.com/crystal-lang/crystal-db/issues/42
<FromGitter> <khepin> What’s a good way to dynamically build an array of NamedTuple s… ⏎ ⏎ ```my_array = [] of NamedTuple``` [https://gitter.im/crystal-lang/crystal?at=58d2d9a6fe6a638b1af2a455]
<FromGitter> <khepin> isn’t accepted by the compiler
<FromGitter> <khepin> and I’m not seeing a correct way to make it work
<FromGitter> <mverzilli> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58d2da465917e26076c29fa8]
<FromGitter> <khepin> oooo!!!!
<FromGitter> <khepin> Thank you so much. I don’t know how I missed that, I was on that page just a while ago ...
<FromGitter> <mverzilli> no prob!
KCreate has left #crystal-lang [#crystal-lang]
badeball_ has quit [Remote host closed the connection]
badeball has joined #crystal-lang
<FromGitter> <Zhomart> @bcardiff I just understood that the problem is different and defined? doesn't help it :).
<FromGitter> <bcardiff> @fridgerator I was waiting on your input regarding #42 ;-)
<FromGitter> <fridgerator> Yes sorry I haven't replied yet, I'll make time to do it this week
<FromGitter> <Zhomart> Just found bug with calling methods when instance is cast as parent class.
<RX14> looks like it's an issue with method overriding
<RX14> that it can't find the Int64.class override
tilpner has quit [Ping timeout: 256 seconds]
tilpner has joined #crystal-lang
<BlaXpirit> I don't get it
<RX14> I would expect not to get a String
<RX14> i'd expect to get a compile error honestly
<BlaXpirit> seems like crystal actually tracks all possible exception types that a function may give
<RX14> yeah...
<RX14> it just confused me
<FromGitter> <bcardiff> Yes, it tracks down the instances: https://carc.in/#/r/1qqh , it might change in the future that. Leaving that typeof(ex.value) to type to just Object.
<RX14> yeah...
<RX14> i think it's a little more strange and unexpected for that to be inferred
<RX14> compared to return types
<RX14> even though it's essentially the same as far as type inferrence I would think
fenicks has joined #crystal-lang
sardaukar has joined #crystal-lang
bjz has joined #crystal-lang
sardaukar has quit [Client Quit]
<crystal-gh> [crystal] will opened pull request #4177: Fix TCPSocket segfault on missing host and 0 port (master...fix-tcp-segfault) https://git.io/vSedL
akwiatkowski has quit [Ping timeout: 258 seconds]
<FromGitter> <faustinoaq> Hi!, I don't know if dynamic library is right but I'm playing with it. ⏎ https://github.com/faustinoaq/interactive-crystal
<FromGitter> <faustinoaq> Inspired by http://nullprogram.com/blog/2014/12/23/