RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
return0e has quit [Remote host closed the connection]
<FromGitter> <fridgerator> crystal tshirts!! <3
<FromGitter> <fridgerator> ..... and the check out is broken
<FromGitter> <nickbclifford> can anyone familiar with JSON::PullParser help me out here? there's hardly any documentation and I can't for the life of my figure out why this is erroring https://carc.in/#/r/4rek
akaiiro has quit [Remote host closed the connection]
<FromGitter> <bew> @nickbclifford in you case the simplest thing you can do is to use a tmp object like this: https://carc.in/#/r/4ren
_whitelogger has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <yxhuvud> @fridgerator shirts? Where?
ashirase has quit [Ping timeout: 260 seconds]
alex`` has joined #crystal-lang
ashirase has joined #crystal-lang
<FromGitter> <vladfaust> Noice ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b769c82e7971d5f10952e66]
<FromGitter> <vladfaust> `(-∞..∞)` works too. That's beautiful
<FromGitter> <bararchy> why not just `alias` ?
<FromGitter> <vladfaust> Alias doesn't work expecting constant. That's a minor issue for me though because sometimes there are situations when I'd like to use UTF-8 symbols as constants, but Crystal doesn't allow to. E.g. `π = Math::PI` to beautifully use in formulas.
<FromGitter> <j8r> @vladfaust Nice, I like even more: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b76a1047a178641253b6dae]
<FromGitter> <vladfaust> Nah, ugly. `_` followed by infinity symbol doesn't look good
<FromGitter> <rishavs> which is faster, a for loop to infinity or a while-do loop?
<FromGitter> <j8r> This is the float
<FromGitter> <j8r> `pp! 2.5.to_∞` works also
<FromGitter> <vladfaust> @rishavs as far as I remember, `while do` is kinda slow
<FromGitter> <vladfaust> @j8r it's not clear whether are you trying to convert 2.5 to infinity :)
<FromGitter> <j8r> Yes totally
<FromGitter> <j8r> Like `#toward_∞`
<FromGitter> <vladfaust> `2.toward_∞` vs `(2..∞)`. Seriously? :D
<FromGitter> <vladfaust> A developer doesn't exactly know what `toward` would mean, while range is range
<FromGitter> <j8r> The infinity isn't really infinity
<FromGitter> <vladfaust> It would save him from digging into your docs defining `toward`
<FromGitter> <j8r> And this is the actually `Float::Infinity`, not the general infinity we would hope
<FromGitter> <vladfaust> I'm sure it works in 99% cases
<FromGitter> <j8r> Anyway i prefer to use `Float64::Infinity` directly - more explicit
<FromGitter> <vladfaust> From my years of experience, ensuring edging cases is bad for any project
<FromGitter> <vladfaust> Just thinking
<FromGitter> <sclee15> Hmm. looks like 0.26.0 is not mentioned here at ⏎ https://github.com/Homebrew/homebrew-core/blob/master/Formula/crystal.rb ⏎ I guess this is the brew problem for latest crystal.
petercommand has joined #crystal-lang
<RX14> is amber dead? hasnt been a commit for a month and nobody seems forthcoming to merge the 0.26.0 update
DTZUZO has joined #crystal-lang
<FromGitter> <yxhuvud> nice, thanks
<RX14> elorest hasnt had any activity on github since june, eliasjpr hasn't had any activity on amber since july 5th, etc
<FromGitter> <rishavs> that would suck. I love Amber. :(
<FromGitter> <rishavs> @faustinoaq has merge privileges and he is active on Github
hightower3 has joined #crystal-lang
<hightower3> Hey, I have a getter for which I get: "instance variable '@path' of Fluence::Accessible was not initialized directly in all of the 'initialize' methods, rendering it nilable. Indirect initialization is not supported.". The line it is pointing me to is the line of the getter ("getter path : String") so I have no clue where the initialize() that I need to fix is.
<hightower3> Any hints how to find that out?
<RX14> you have to look at your code
<RX14> unfortunatelt
<RX14> unfortunately
<hightower3> yeah, (unfortunately I have only one initialize(), and in it I do have an explicit @path = ... so really not sure what/where else to look...)
<hightower3> the other initialize I suppose is coming from the objects YAML.mapping, but @path is defined as not-nil there
scott_tams has joined #crystal-lang
<RX14> can I see the code?
<FromGitter> <fridgerator> @yxhuvud But I can't check out, I just get an error
<FromGitter> <j8r> How can I have utime and ctime of a file? I can use `File.utime` to set `atime` and `mtime`, but there is no longer File.stat
<hightower3> RX14, sure, thanks! It is in branch "uninitialized" here: https://github.com/crystallabs/fluence/tree/uninitialized
<hightower3> RX14, there are a bunch of changes there which most likely don't compile because I was in the middle of larger changes, but the first error that pops up when you try to run src/fluence.cr is the one I mentioned
<RX14> whats the type called
<RX14> oh, nvm i see
<RX14> hightower3, there's a mix of spaces and tabs everywhere in your code
<RX14> please consider using crystal tool format --check as part of CI
<hightower3> RX14, yeah, I use an editor which sets tabs to 2 spaces so it looks the same. (Personally I prefer tabs, but that's not where the general trend is going)
<RX14> if you used tabs everywhere that'd be understandable but thats not what's happened :P
<hightower3> Sure :) part of the code was inherited from another project, and I was delaying the unification until larger problems are solved :)
<RX14> so Accessible is an abstract struct right?
<hightower3> yes
<RX14> so you basically have to look at all the inheritors and their constructoirs
<RX14> what classes inherit it?
<hightower3> yes, there is only one -- src/fluence/lib/page.cr
<hightower3> oh wait, maybe another file is getting require-d due to a wildcard somewhere, let me check
<hightower3> (hm, no)
<RX14> well everything was getting required
<RX14> but i removed Media and it didnt fix it
<hightower3> yes, that's what I meant. I also noticed that the function used there (@path = Page.name_to_directory ...) doesn't exist, but also if you directly say @path = "test" the error still shows up
<RX14> oh
<hightower3> (actually it exists, n/m)
<RX14> basically this
<hightower3> ouch, ok great, thanks much for looking into it
<hightower3> it definitely seems to me it should be "corrected"
<RX14> you basically need to define an initialize in the abstract baseclass
<RX14> and then have the initialize in the lower class call it with the appropriate values
<RX14> which is just needlessly more verbose
<RX14> it seems to work with YAML.mapping though
<hightower3> RX14, hm, I tried following asterite's suggestion (the part where he said "Basically, write the code like this:"), but still the same error. (I've pushed it to the same branch)
<hightower3> I've modified your carc paste and it seems to work, though
<RX14> diff?
<RX14> try not initializing 'toc and @intlinks before calling super
<RX14> like assign them all to lcal vars
<RX14> call super
<RX14> than @toc = toc
<hightower3> same thing (I thought this could be an issue so I just commented that whole block)
<RX14> fuck
<RX14> comment out the yaml stuff?
<RX14> just the YAML mapping
<RX14> just to see
<hightower3> For now I commented the whole initialize and just put there: path, name, url, title = "1", "2", "3", "4"; super(path, name, url, title) ... Will try to remove the @slug now and then remove the YAML stuff
<hightower3> RX14, yeah, without YAML.mapping() it works
<RX14> fuck
<RX14> the only thing I can think of is creating a new type with the YAML mapping
<RX14> forwarding from_yaml to that type
<RX14> then taking the values from that type and copying them to the new type
<RX14> using a private constructor for every field
<RX14> if you understand what i'm saying?
<hightower3> sure, seems it could work. Ok I'll update that github issue with our findings and then change the code
<hightower3> thanks!
<RX14> like `def self.from_yaml(*args); fake = FakeMedia.from_yaml(*args); Media.new(fake.path, fake.name, ...); end`
<RX14> it'd be *much* cleaner if that issue was fixed though
<hightower3> RX14, hm, however, do you see any explanation why this works though: https://carc.in/#/r/4rh7
<RX14> no
francisl has joined #crystal-lang
<RX14> i tried that and i'm confused why your thing doesn't work
<hightower3> It works if I remove the two "include"s at the top of struct in https://github.com/crystallabs/fluence/blob/uninitialized/src/fluence/lib/page.cr
<hightower3> gonna check what's in them in more detail now
<RX14> the compiler will commonly just give up if you mix too much abstract classes/modules/generics
<hightower3> I thought the issue is that I reopen "struct Page < Accessible" in both of those includes. But even if I change their contents to "module Fluence::Page::InternalLinks; end" , it still fails if the includes are there.
<hightower3> RX14, here's what seems the minimal reproducible case: https://carc.in/#/r/4rhk
<hightower3> (if either the "include" or YAML are removed, it works)
scott_tams has quit [Ping timeout: 272 seconds]
<RX14> hightower3, https://carc.in/#/r/4rht is the same
<RX14> but yeah
<RX14> thats a bug
<hightower3> RX14, hehe yeah, was just working on doing that and updating the comment
<RX14> thanks for the reproducible code, you should report that
<hightower3> I did to that ticket. Do you judge it requires a separate issue, or a comment to that existing issue is related/relevant?
<RX14> hmm
<FromGitter> <j8r> I've also encounter this type of problem, ivars' type wasn't recognized when inheriting from an abstract, but I haven't be able to isolate it.
<FromGitter> <j8r> Not sure it's exactly related though. I've workaround ed by using getters
flaviodesousa has joined #crystal-lang
ua has quit [Read error: Connection reset by peer]
ua has joined #crystal-lang
<FromGitter> <vegai> should StringBuilder not say in its documentation that one should never use that class directly
<FromGitter> <vegai> doesn’t seem correct to me
<RX14> why?
<RX14> it's true
<RX14> String.build constructs the string builder for you and then passes you the builder
<FromGitter> <vegai> Ohh, right. That’s the part I missed. Thanks.
<RX14> i mean it does say use String.build
<FromGitter> <vegai> the part that confused me is String.build’s signature
<FromGitter> <vegai> `.build(capacity = 64, &block) : self`
<FromGitter> <vegai> so it looks like it’s returning a String, not a StringBuilder
<FromGitter> <vegai> I mean a String::Builder
<RX14> but it is
<RX14> it is returning a string
<RX14> thats what you want
<RX14> the string builder is passed to the block
<FromGitter> <vegai> yeah, I know
<RX14> i'm confused
<FromGitter> <vegai> wasn’t reading with full attention
<FromGitter> <vegai> nothing to be confused, I read wrong :)
<FromGitter> <vegai> “self.build is returning a String, that’s not what I want. I want a StringBuilder"
akaiiro has joined #crystal-lang
ua has quit [Quit: Leaving]
ua has joined #crystal-lang
<FromGitter> <bcardiff> FYI the brew formula for 0.26.0 was merged.
<FromGitter> <fridgerator> wohoo 🎉
<FromGitter> <drosehn> 👍
<FromGitter> <fernandes> > FYI the brew formula for 0.26.0 was merged. ⏎ ⏎ good news! I just got @mgarciaisaia PR and used locally hahaha
<FromGitter> <fridgerator> @Prutheus ^
akaiiro has quit [Ping timeout: 256 seconds]
akaiiro has joined #crystal-lang
<FromGitter> <asterite> We should probably hide `String::Builder` from the docs
<RX14> nah
<RX14> just the constructors
<RX14> the API methods on String::Builder are good
flaviodesousa has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
francisl has quit [Quit: francisl]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
<FromGitter> <asterite> it's unsafe
akaiiro has quit [Ping timeout: 272 seconds]
go|dfish has joined #crystal-lang
<RX14> it should really just be a standard IO interface I guess, just layed out in memory with the string header
<FromGitter> <diegogub_gitlab> Hello! Is it possible to receive on a closed buffered channel? If the producer does not have more data, how should I notify the receiver?
<FromGitter> <diegogub_gitlab> At the moment I'm doing :
<FromGitter> <diegogub_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b772fd9802bc42c5f33a988]
<RX14> if you close the channel, the channel will raise when you try and recieve
<RX14> you can also use recieve?
<FromGitter> <diegogub_gitlab> yup, but how do I break the loop? I was using , ch.closed? . but I was missing data
<RX14> yeah you have to recieve until the buffer is empty
<FromGitter> <diegogub_gitlab> yes, but the issue with that is sometimes the buffer could get empty..but not closed
<FromGitter> <diegogub_gitlab> haha I see, I can ask if it's closed after receive?
<FromGitter> <diegogub_gitlab> Sorry for the silly question
<RX14> no
<RX14> you don't even ask if it's closed
<RX14> ever*
<RX14> you wait until you get the closed error - or nil if you're using `recieve?` and then you know it's closed
<RX14> your example is basically correct
<FromGitter> <diegogub_gitlab> > nil if you're using recieve? and then you know it's closed
<RX14> yes
<FromGitter> <diegogub_gitlab> thats what I need
<FromGitter> <diegogub_gitlab> thanks, I will try to raise the exception, doesnt look good
<FromGitter> <diegogub_gitlab> thank you
<RX14> obviously it doesn't work when you're sending nil down the channel
<RX14> in that case you need to rescue the exception
tilpner has quit [Remote host closed the connection]
tilpner has joined #crystal-lang
tilpner has quit [Ping timeout: 240 seconds]
tilpner has joined #crystal-lang
tilpner has quit [Remote host closed the connection]
tilpner has joined #crystal-lang
hightower3 has quit [Remote host closed the connection]
akaiiro has joined #crystal-lang
<FromGitter> <ezrast> Can someone elucidate on what's unsafe about String::Builder? I've used it in places where String.build isn't flexible enough.