jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.18.7 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
pawnbox has joined #crystal-lang
Philpax has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
onethirtyfive has quit []
pawnbox has quit [Ping timeout: 258 seconds]
Philpax has quit [Ping timeout: 252 seconds]
onethirtyfive has joined #crystal-lang
snsei has quit [Remote host closed the connection]
onethirtyfive has quit []
onethirtyfive has joined #crystal-lang
devinacosta has joined #crystal-lang
<devinacosta> I'm running into issue with Crystal, I'm trying to declare a Hash
<devinacosta> in ./src/vzcheck.cr:100: can't declare variable of generic non-instantiated type Hash(K, V) servers = uninitialized Hash
<devinacosta> I have tried: servers = Hash.new()
<devinacosta> Also tried: servers = Hash
<devinacosta> None of those work
devinacosta has quit [Client Quit]
<havenwood> devinacosta: An example would be: servers = {} of Symbol => String
devinacosta has joined #crystal-lang
onethirtyfive has quit []
<devinacosta> When i'm trying to create as hash variable that's empty i get:
<devinacosta> Syntax error in ./src/vzcheck.cr:100: for empty hashes use '{} of KeyType => ValueType' servers = {}
<devinacosta> I figured it out.
devinacosta has quit [Ping timeout: 250 seconds]
onethirtyfive has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 244 seconds]
zenguyaz has joined #crystal-lang
pawnbox has joined #crystal-lang
Oliphaunte has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
<zenguyaz> If i have an hash that looks like : server = {"pcs1"=>["192.168.135.26", "10.241.146.231", "10.241.146.35"], "pcs2" => ["192.168.0.1","192.168.0.2"]}
<zenguyaz> is there an easy way if i pass the IP it tells me what key matches it?
pawnbox has joined #crystal-lang
<havenwood> zenguyaz: to get all of the keys with the ip you could do something like: server.select { |_, v| v.includes? ip }.keys
<zenguyaz> sweet thanks for that worked great.
pawnbox has quit [Ping timeout: 264 seconds]
Oliphaun_ has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
onethirtyfive has quit [Remote host closed the connection]
snsei has joined #crystal-lang
zenguyaz has quit [Ping timeout: 250 seconds]
Oliphaun_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/v6eIF
<crystal-gh> crystal/master f7fff74 Ary Borenszweig: Compiler: more refactors related to type and path lookup
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
<travis-ci> crystal-lang/crystal#f7fff74 (master - Compiler: more refactors related to type and path lookup): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/148622481
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
pawnbox has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
pawnbox has quit [Ping timeout: 258 seconds]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
onethirtyfive has joined #crystal-lang
onethirtyfive has quit []
ponga has joined #crystal-lang
ninja_ has joined #crystal-lang
<ninja_> is there an easy way with crystal when i'm pulling webpage, to get the response time it took to load the page?
<ninja_> response = HTTP::Client.get("#{url}") code = response.status_code body = response.body.lines
<ninja_> i don't see any function that gives me response time.
snsei has quit [Remote host closed the connection]
ninja_ has quit [Quit: Page closed]
onethirtyfive has joined #crystal-lang
pawnbox has joined #crystal-lang
onethirtyfive has quit [Ping timeout: 244 seconds]
<BlaXpirit> ...
pawnbox has quit [Ping timeout: 276 seconds]
snsei has joined #crystal-lang
pawnbox has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
rolha has quit [Quit: Textual IRC Client: www.textualapp.com]
rolha has joined #crystal-lang
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
onethirtyfive has joined #crystal-lang
hangyas has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
willl has quit [Quit: Connection closed for inactivity]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 265 seconds]
zodiak_ has joined #crystal-lang
zodiak has quit [Ping timeout: 250 seconds]
ome has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 258 seconds]
pawnbox has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
Oliphaunte has joined #crystal-lang
hangyas has quit [Quit: hangyas]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
pawnbox has joined #crystal-lang
<crystal-gh> [crystal] BlaXpirit opened pull request #3070: Fixes for documentation generator (master...docs-fixes) https://git.io/v6e0z
Oliphaunte has quit [Read error: Connection reset by peer]
Oliphaunte has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
snsei has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 2 new commits to master: https://git.io/v6eEc
<crystal-gh> crystal/master dd4fd7c Ary Borenszweig: Compiler: simplified a bit suggestions.cr
<crystal-gh> crystal/master 89fe6b7 Ary Borenszweig: Compiler: fixed path lookup relative to free variable
ome has quit [Quit: Connection closed for inactivity]
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
Oliphaunte has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
<BlaXpirit> how does this work? https://carc.in/#/r/1548
Oliphaunte has quit [Remote host closed the connection]
<FromGitter> <fridgerator> `s = ss.s` looks like its passing a value not a reference? just a guess, i’m new to the language
<jhass> I guess the question is how you model ss.s().a=(), as t = ss.s(); t.a=() or not
<BlaXpirit> well that really surprised me, it could be just an optimization bug or it could be intentional. strange either way
<FromGitter> <fridgerator> @BlaXpirit yeah it is strange
<jhass> well, it is convenient but inconsistent, yeah
<jhass> ss.@s.a=() should have that behavior
<BlaXpirit> where is the line where that stops working?
<jhass> I agree
<BlaXpirit> and where is the documentation? we're not sure if it's not a bug, anyway
Oliphaunte has joined #crystal-lang
<BlaXpirit> so this doesnt work anymore https://carc.in/#/r/154c but with `getter s` it still works
<jhass> that documentation is probably at asterite ;)
<jhass> huh, I see no difference?
<BlaXpirit> woops, my mistake
<BlaXpirit> it prints 0 0 on master!!!
<BlaXpirit> bleh, must be some weirdness with the playground
<jhass> prints 0 5 for me locally with both, 0.18.7 and master
<BlaXpirit> same for me, but playground does something weird
<RX14> it makes sense to me, because when you set a property in a struct you modify the struct, but when you use = you copy the struct
<RX14> then the = on the proeprty obviously doesn't update the S in the SS because it's been copied
<BlaXpirit> well at this point it is a bit scary https://carc.in/#/r/154f
<BlaXpirit> this has got to be an optimization bug
pawnbox has joined #crystal-lang
<jhass> well yes, the copy operation is on assignment and argument passing, not on return
<jhass> still that a.b.c = d isn't equivalent to t = a.b; t.c = d is a bit unexpected
<jhass> especially since whether b returns a class or struct should be rather opaque to the caller
<RX14> how so?
<RX14> a struct contains it's members
<RX14> not refers to them
<RX14> well
<RX14> i know what i meant
<RX14> a struct is embedded into it's container, right
<BlaXpirit> just check this out https://carc.in/#/r/154h
<RX14> so using dot notation just means you're setting memory inside the struct, but = means copy
<BlaXpirit> RX14 pls
<RX14> now thats a bug
<RX14> now thats weird
<jhass> it's the result of not clearly defined semantics
<jhass> I think we should just define chained dot as assignment to temporary variables and be done with it
<BlaXpirit> jhass, at this point i'm pretty sure they are well defined (simply always copy by value) but this goes against them due to a bug
<jhass> a.b.c should always be equivalent to t = a.b; t.c
<RX14> thats weird tho
<jhass> how so?
<RX14> ss.s.a = 5 should work to me, as you're simply calling a method on the s in ss which updates it in-place
<jhass> I should say chained method calls
<jhass> no, ss.s.a = 5 is ss.s().a=(5)
<jhass> ss.@s.a = 5 should work in place
<BlaXpirit> however ss.s() should return a copy. which you then modify on the fly and it is discarded
<RX14> hmmn i guess you're right
<BlaXpirit> at least thats what i expected when going into this
<RX14> i'm used to langauges where proeprties aren't functions
<jhass> ;)
<RX14> properties being functions gets weird with structs
<BlaXpirit> and after comfirming that this doesnt work, my next step would be to suggest a rework of structs
<BlaXpirit> i mean, how often do you use private fields in structs? how often do you not have properties exactly matching members?
<BlaXpirit> my suggestion would basically be, when it comes to structs, s.a is equivalent to s.@a
<jhass> almost all iterators?
<BlaXpirit> woops
<RX14> its an interesting suggestion
<RX14> and i like it in a way
<BlaXpirit> then you can properly do the ss.s.a = 5 and whatever
<RX14> well crystal could implement private properties
<RX14> but the thing is it makes everything more complcated
<RX14> because then you've really got 2 completely seperate semantics
<RX14> i think it's something thats worth suggesting and making an argument for on github
<BlaXpirit> bleh, i wouldn't have private properties or functions in the first place, coming from python :p
<RX14> why
<RX14> it's nice
<BlaXpirit> when it's half-assed, it isn't
<RX14> sometimes i have a function that i need for my class
<BlaXpirit> i mean, C++ has "friend classes" and they are there for a reason
<RX14> but really shouldn't be used outside it
<RX14> same for properties
<BlaXpirit> sometimes i have a function that i need throughout my library but users don't need it - what do i do?
<BlaXpirit> public and :nodoc: :|
<BlaXpirit> this is even worse for macros
<RX14> no but then you're intorducing an API
<RX14> which can't be changed after 1.0
<RX14> even if it's a messy implementation detail
<RX14> private exists for a reason
<BlaXpirit> but I cannot use it
<RX14> good
<RX14> because it's liable to change
<BlaXpirit> it's an implementation detail but other classes need access to it
<RX14> because it's private
<BlaXpirit> but they can't because it's private
<RX14> but if other classes needed access i would make a clean api
<RX14> but they dont
<RX14> sometimes you need something messy
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<BlaXpirit> made an issue about discussed topics
<FromGitter> <cjgajard> @BlaXpirit wasn't structs meant to be immutable? why you need that to be a struct instead of a class?
<RX14> structs aren't meant to be immutable
<RX14> they're meant to be pass-by-value
<BlaXpirit> cjgajard, it's not just about what I need
<RX14> which makes them ineffective at storing mutable data over a long period
<RX14> but they are still mutable, for example iterators
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 265 seconds]
<RX14> jhass, in this comment (https://github.com/crystal-lang/crystal/pull/2967#discussion_r72900717) did you mean to essentially "unpack" the fields from FileMetadata into the file method signature so you don't need the intermediate object?
<jhass> as an additional overload, yes
<RX14> hmmn
<RX14> would be nice if HTTP::Headers had a to_hash
<RX14> probably from_hash too
<FromGitter> <acterhd> I heard bignumer very slow in crystal
<FromGitter> <acterhd> why?
<jhass> to_h and it actually has from Enumerable, so it's fine if you add an optimized version that just returns a copy of the internal one
<RX14> where did you hear that acterhd?
<jhass> acterhd we're not too sure, we just bind libgmp, maybe not in an optimal manner in all cases yet
<RX14> libgmp should be really fast
<FromGitter> <acterhd> I want also SIMD in Crystal
<RX14> well of course big numbers are much slower than their native counterparts
<RX14> because they aren't native to the cpu
<RX14> jhass, should I type my callbacks as procs returning void, or returning nil? because i think procs typed to return nil fail if you accidentally have a value at the end
<jhass> just specify nothing
<RX14> how?
<jhass> alias Foo = A ->
<RX14> oh...
<RX14> you can do that?
<jhass> yes
<jhass> it's Void or Nil depending on Crystal version
<RX14> oh
Majost has joined #crystal-lang
<BlaXpirit> any way to take a screenshot of the whole screen and read the pixel data?
snsei has joined #crystal-lang
<tilpner> Can free variables in method definitions not occur in the return types?
<BlaXpirit> I don't understand
<BlaXpirit> tilpner, oh maybe i do. perhaps they can't. just don't specify the return type :/
<tilpner> But then how will I return an Array(T) without taking a T.class? :/
<jhass> https://carc.in/#/r/1552 seems to work
<tilpner> jhass - But only for a class with a free variable. What if I don't have one?
<jhass> I'm not sure what you're trying to do
<tilpner> jhass - Context: Returning an Array(T) from a crystal-db ResultSet, created by yielding to a T.
<tilpner> I can try writing out the type of the block, perhaps?
<jhass> this?
<tilpner> Indeed, I didn't think of that. This works better. :)
<FromGitter> <elorest> isn't there a way to chain each_with_index and reduce/inject together?
<tilpner> Is it possible to generate documentation for dependencies automatically, not just for the current shard, and easier than generating it manually for each lib?
<BlaXpirit> tilpner, just go into each folder and run crystal doc? i dont understand your use case
<jhass> elorest: seems to just work ;) https://carc.in/#/r/155o
<tilpner> BlaXpirit - That's what I've been doing so far, but it'd be nicer to generate all of them automatically and merge them into one output.
<tilpner> (And I can't quite figure out how to generate docs for sqlite3)
<BlaXpirit> tilpner, btw it is probably better to literally merge them into one folder
<BlaXpirit> merge sources, then run crystal doc
<FromGitter> <elorest> @jhass Thanks. Not sure why it wasn't working for me.
snsei has quit [Remote host closed the connection]
<tilpner> Hmm, that seems annoying if done manually, but sounds easy to automate, so it might be fine. :/
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 244 seconds]
elomatreb has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran_ has joined #crystal-lang
soveran__ has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
soveran_ has quit [Ping timeout: 244 seconds]
soveran__ has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 244 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Client Quit]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 264 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/v6eHK
<crystal-gh> crystal/master 8034212 Ary Borenszweig: Fixed #3071: detect recursive structs via subtypes
<travis-ci> crystal-lang/crystal#8034212 (master - Fixed #3071: detect recursive structs via subtypes): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/148737069
<RX14> jhass, I added the unhandled fields callback, anything more to get multipart merged?
<jhass> looks good from my side, but enough code to warrant a second opinion ;)
<RX14> BTW, I think we should seperate HTTP::Request into a server and client class
<RX14> response already does that
<RX14> and making request act like an IO is much saner that way
snsei has joined #crystal-lang
snsei_ has quit [Ping timeout: 260 seconds]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has quit [Ping timeout: 264 seconds]
matp has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 276 seconds]
soveran has quit [Remote host closed the connection]