ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.20.3 | 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
soveran has quit [Remote host closed the connection]
<crystal-gh> [crystal] bcardiff closed pull request #3797: Makefile: Fix typo in intructions. (master...make) https://git.io/vMTRJ
<DeBot> https://github.com/crystal-lang/crystal/pull/3797 (Makefile: Fix typo in intructions.)
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vMk3I
<crystal-gh> crystal/master e65f2ee Linus Sellberg: Makefile: Fix typo in intructions. (#3797)
<DeBot> https://github.com/crystal-lang/crystal/pull/3797 (Makefile: Fix typo in intructions.)
martinium has joined #crystal-lang
<travis-ci> crystal-lang/crystal#e65f2ee (master - Makefile: Fix typo in intructions. (#3797)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/187348432
<DeBot> https://github.com/crystal-lang/crystal/pull/3797 (Makefile: Fix typo in intructions.)
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
martinium has quit [Ping timeout: 260 seconds]
A124 has quit [Quit: '']
A124 has joined #crystal-lang
ruby has joined #crystal-lang
ruby is now known as Guest53205
vikaton has joined #crystal-lang
ome has joined #crystal-lang
Yxhuvud has quit [Ping timeout: 264 seconds]
mgarciaisaia has joined #crystal-lang
schnittchen has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
mgarciaisaia has quit [Quit: Leaving.]
<TheGillies> Just aliased this room as #crystal:matrix.org on matrix woo
<FromGitter> <fridgerator> matrix woo?
<TheGillies> matrix, woo
<TheGillies> heh
<TheGillies> http://matrix.org
<TheGillies> i.e. irc++
<FromGitter> <fridgerator> lol, ah
<TheGillies> How do I read from keyboard without pressing enter?
<TheGillies> I tried STDIN.gets(1) but that doesn't seem to work
pawnbox has quit [Remote host closed the connection]
Guest53205 has quit []
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<FromGitter> <bcardiff> https://crystal-lang.org/api/0.20.3/IO.html#read_char%3AChar%3F-instance-method
pawnbox has quit [Remote host closed the connection]
<TheGillies> That blocks until I hit enter
pawnbox has joined #crystal-lang
<TheGillies> It's like the characters don't enter STDIN until I press enter
<TheGillies> Wonder If I should be reading from a different IO
ome has quit [Quit: Connection closed for inactivity]
<TheGillies> that awkard moment to read STDIN.raw and cry because control c no longer works
<TheGillies> you read*
vikaton has quit [Quit: Connection closed for inactivity]
matp has quit [Quit: ZZzzzZz...]
_whitelogger has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
triangles has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
bjz has joined #crystal-lang
soveran has quit [Remote host closed the connection]
matp has joined #crystal-lang
vivus-ignis has joined #crystal-lang
Kug3lis has joined #crystal-lang
<Kug3lis> Hi
<Kug3lis> how to skip multiple iterations with next ?
<Kug3lis> i tried like `next 2` but didnt worked out
vivus-ignis has quit [Ping timeout: 245 seconds]
vivus-ignis has joined #crystal-lang
bjz has quit [Ping timeout: 245 seconds]
bjz_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<Kug3lis> Maybe someone could help on figuring out why after iteration set value of outside variable on next iteration is nil?
bmcginty has quit [Ping timeout: 258 seconds]
bmcginty has joined #crystal-lang
matp has quit [Quit: Bye!]
matp has joined #crystal-lang
<BlaXpirit> Kug3lis, maybe
<Kug3lis> BlaXpirit Somehow I figured out, that I cant have nil variable if I want to change it in iterator...
<BlaXpirit> uhh wut
tatey has joined #crystal-lang
pawnbox_ has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondi has joined #crystal-lang
tatey has quit [Quit: ZNC - http://znc.in]
pawnbox has quit [Ping timeout: 256 seconds]
tatey has joined #crystal-lang
vivus-ignis has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
<Kug3lis> BlaXpirit never mind I figured out...
kellabyte_ has joined #crystal-lang
avdi_ has joined #crystal-lang
poikon_ has joined #crystal-lang
jokke has quit [*.net *.split]
Liothen has quit [*.net *.split]
RX14 has quit [*.net *.split]
fedruantine has quit [*.net *.split]
Cyrus has quit [*.net *.split]
poikon has quit [*.net *.split]
kellabyte has quit [*.net *.split]
avdi has quit [*.net *.split]
bjmllr has quit [*.net *.split]
elomatreb has quit [*.net *.split]
tliff has quit [*.net *.split]
nickc2 has quit [*.net *.split]
Liothen has joined #crystal-lang
Liothen has joined #crystal-lang
kellabyte_ is now known as kellabyte
poikon_ is now known as poikon
fedruantine has joined #crystal-lang
tatey has left #crystal-lang ["Textual IRC Client: www.textualapp.com"]
nickc2 has joined #crystal-lang
Cyrus has joined #crystal-lang
elomatreb has joined #crystal-lang
RX14 has joined #crystal-lang
jokke has joined #crystal-lang
tliff has joined #crystal-lang
avdi_ is now known as avdi
bjmllr has joined #crystal-lang
tatey has joined #crystal-lang
<Kug3lis> how to implode array values?
<Kug3lis> because I cant find nothing in API in array
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tatey has quit [Quit: ZNC - http://znc.in]
tatey has joined #crystal-lang
<FromGitter> <asterite> PHP's implode? I think it's `split`
<FromGitter> <asterite> Ah, no, it's `join`
<FromGitter> <asterite> I always confused implode and explode in PHP :-P
<FromGitter> <splattael> Did anyone try to do memory profiling for Crystal?
<FromGitter> <splattael> I'd like to something similar to Ruby's "hotch" gem: https://github.com/splattael/hotch#memory-profiler-1
<FromGitter> <splattael> I tried to intercept `GC.malloc` calls etc. but I got segfaults when trying to create a `CallStack` during `GC.malloc` :worried:
vivus-ignis has joined #crystal-lang
Kug3lis has joined #crystal-lang
damireh has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tatey has quit [Quit: ZNC - http://znc.in]
tatey has joined #crystal-lang
A124 has quit [Read error: Connection reset by peer]
A124 has joined #crystal-lang
<FromGitter> <cschlack> Hi! I'm trying to call C code that potentially blocks for a long time (libgit2 in my case). How would you call a blocking function without blocking other fibers?
<FromGitter> <cschlack> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=586501130730ce6937210a8a]
<BlaXpirit> can't
<BlaXpirit> for now
pawnbox_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<FromGitter> <cschlack> The code above works for me. But as soon, as I'm trying to communicate anything from the background thread to the main thread, that contains a string, I'm seeing something like this:
<FromGitter> <cschlack> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=586502c5c02c1a3959c59142]
schnittchen has joined #crystal-lang
<FromGitter> <cschlack> What does it mean?
schnittchen has quit [Client Quit]
vivus-ignis has quit [Ping timeout: 258 seconds]
<BlaXpirit> cschlack, means you're doing something that you can't do
<BlaXpirit> standard library and mainly GC crashes when you use threads
Yxhuvud has joined #crystal-lang
<BlaXpirit> thread support is high priority but is not possible currently
<BlaXpirit> only very limited and very careful usages are possible, but channel communication is not one of them. i can'tcome up with any way to accomplish this, other than checking whether a boolean has been set in a busy loop
damireh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<FromGitter> <cschlack> @BlaXpirit: Thanks, I tried that as well. It works with just a boolean flag. The problem remains: How to transport a String from the background thread without crash (String.new doesn't seem to work).
<FromGitter> <cschlack> OR: is it possible to detect crystal from C side and yield control to the main loop while waiting for io?
<FromGitter> <mjago> What is the idiomatic way to do UInt8 => ascii or unicode (i.e. build a string from slice(UInt8))?
mgarciaisaia has joined #crystal-lang
<FromGitter> <mjago> ahh .chr
mgarciaisaia has quit [Ping timeout: 246 seconds]
mgarciaisaia has joined #crystal-lang
<BlaXpirit> cschlack, you don't transport a string
<BlaXpirit> because you don't create a string in a background thread because it's not allowed
bjz_ has quit [Ping timeout: 245 seconds]
<BlaXpirit> real question is, why do you need a Crystal String in a background thread
bjz has joined #crystal-lang
<BlaXpirit> cschlack, maybe you should pass the struct pointer to the main thread, get info from it and free it from there
<BlaXpirit> your idea about yielding control to main loop is interesting
<BlaXpirit> but if it's made in recursive calls, maybe it'll bust the stack. not sure what other way to do it
vivus-ignis has joined #crystal-lang
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
Kug3lis has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> @cschlack if you want to do it the hard way, you can write a C wrapper which does all the blocking stuff in threads in C, then exposes the results on a pipe or fifo
<RX14> then you can bind your wrapper C lib
<RX14> and pass back file descriptors
<RX14> which you listen on to recieve results from threads
<RX14> I think zmq does this
<RX14> although I think the best route for implementing zmq in crystal is to implement zmtp in pure cr
Yxhuvud has quit [Ping timeout: 265 seconds]
w0ls0n has joined #crystal-lang
w0ls0n has left #crystal-lang [#crystal-lang]
<FromGitter> <cschlack> @RX14: thanks. I'd rather not do it 'the hard way', but what are my options...
Yxhuvud has joined #crystal-lang
Philpax_ has quit [Ping timeout: 258 seconds]
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kug3lis has joined #crystal-lang
bcardiff has joined #crystal-lang
braidn[m] has joined #crystal-lang
<RX14> @cschlack reimplementing the library in crystal is harder :)
<RX14> you might want to look at how nodejs binds libgit2 then
<RX14> because thats evented too
<FromGitter> <martinium> @RX14 do you know of a way to strip ALL whitespace from userinput?
<RX14> no
<FromGitter> <martinium> I was trying to remove from a user inputted string via the delete method
<FromGitter> <martinium> no luck so far
<Yxhuvud> martinium: so if the user input " a \n b <tab> C " then you want to get "abC" back?
<Yxhuvud> I'd use gsub for that.
<FromGitter> <martinium> even simpler then that only want to remove “ “ empty spaces
<FromGitter> <martinium> ‘ ‘ etc
<FromGitter> <martinium> I am concatenating to a URL and need all spaces removed in case a user enters a space
<FromGitter> <martinium> looking into your gsub suggestion
<braidn[m]> Wow the from gitter is chatty
<braidn[m]> oh wait we can interop with it?
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <martinium> I think so braidn[m]
<Yxhuvud> If it is *only* spaces that should be removed I'd use String#tr.
<FromGitter> <martinium> i didn’t find gsub in documentation for crystal
<Yxhuvud> https://crystal-lang.org/api/0.20.1/String.html#gsub%28pattern%3ARegex%2Creplacement%2Cbackreferences%3Dtrue%29-instance-method
<Yxhuvud> note that there is a version that takes a block as well
<FromGitter> <martinium> keep getting stockSymbols = readLine(stdin).replace(' ', '')
<FromGitter> <martinium> keep getting an error
<FromGitter> <martinium> undefined method gsub for Nil
<FromGitter> <martinium> trying to do gets.gsub(/\s+/, “”)
<FromGitter> <martinium> or STDIN.gets.gsub(/\s+/, “”)
<FromGitter> <martinium> do I need to require any specific module?
<FromGitter> <martinium> gsub is an instance method so seems I need to create a string instance
<FromGitter> <Exilor> IO#gets can return nil, thats why the compiler complains
<FromGitter> <Exilor> you can use gets.not_nil! if you're sure it won't be returning nil, or gets.to_s if you don't mind an empty string if there's nothing to read
hako has joined #crystal-lang
<FromGitter> <martinium> yep that helped
<FromGitter> <martinium> got it to work
<FromGitter> <martinium> :D
<FromGitter> <martinium> believe it it or not I used gets.not_nil!.delete(' ')
<FromGitter> <martinium> to remove all whitespace
<FromGitter> <martinium> from a string
<FromGitter> <martinium> no fancy gsub regex needed
<FromGitter> <martinium> works for my simplistic use case
<RX14> yes
<RX14> "delete spaces" and "delete whitespace" are totally different problems
<RX14> well
<FromGitter> <Exilor> there's also String#strip to remove whitespace
<RX14> i forget half the string ops...
<FromGitter> <martinium> isn’t a space and whitespace basically the same thing
<RX14> too many is a better problem to have than too little though
<FromGitter> <martinium> yeah, choice is good
<RX14> whitespace includes \n,\r,\s,\t
<RX14> space is just \s
<FromGitter> <Exilor> there's non-breaking space which looks like whitespace but isn't
<RX14> and yeas
<FromGitter> <martinium> &nbsp
<RX14> unicode whitespace
<RX14> unicode whitespace is even more of a pain
<FromGitter> <martinium> the rabbit holes goes deep
<RX14> well
<RX14> Crystal has Char#whitespace?
<FromGitter> <Exilor> sublime text + macos = nonbreaking space everywhere
<RX14> ...why?
<FromGitter> <Exilor> no idea. especially around { |x| ...
<FromGitter> <Exilor> oh you weren't asking
<FromGitter> <Exilor> it was a method with ? lol
<RX14> yes
<RX14> i'm glad we have full unicode support
<braidn[m]> Whitespace, the term is usually reserved for space chars at the beginning or end of the string
<braidn[m]> 'spaces' can occur anywhere inbetween the first word and last
<RX14> no
<braidn[m]> but RX14 nailed the diff
<RX14> thats incorrect
<FromGitter> <martinium> in general terms seems to be
<RX14> whitespace has always meant the same regardless of the character's position in the string
<RX14> it's commonly a *problem* at the beginning or end of the string
<RX14> but the definition is any character, that when printed, only shows "white space"
<RX14> all kinds of newlines, tabs and spaces fulfil this definition
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
bmcginty has quit [Ping timeout: 265 seconds]
bmcginty has joined #crystal-lang
<crystal-gh> [crystal] maiha opened pull request #3798: Fix: Socket.unix (master...fix-socket-unix) https://github.com/crystal-lang/crystal/pull/3798
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<Yxhuvud> macos produces nonbreaking space on alt-space, which is a bloody nuisance when you use alt to produce each of {}|
<Yxhuvud> and it is, well, whitespace, so you don't see the error until you try to compile
bcardiff has quit [Quit: bcardiff]
<FromGitter> <dlanileonardo> Hello Everybody! Please why this don't work: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58657431c895451b7534d24a]
<FromGitter> <fridgerator> insert `extra_fields = {} of String => RecursiveType` before `extra_fields =` and then it works
vivus-ignis has quit [Ping timeout: 268 seconds]
<FromGitter> <fridgerator> and remove `of String => RecursiveType` from the end
<FromGitter> <dlanileonardo> Oh! :clap: Thanks!!!
<FromGitter> <fridgerator> np
soveran has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Kug3lis has joined #crystal-lang
bcardiff has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Kug3lis has quit [Quit: Textual IRC Client: www.textualapp.com]
<RX14> line 6 in that gist does nothing apart from add an extra allocation
<RX14> if you actually want it to be a Hash(String, RecursiveType) then you should fix the actual problem
<RX14> and yes, that's a mess
<RX14> which is why in crystal you are heavily encouraged to type your data properly using classes, instead of shoving it into hashes
<FromGitter> <dlanileonardo> https://carc.in/#/r/1i87 is empty for me, There's nothing
<FromGitter> <dlanileonardo> But, i fix this code like this: https://play.crystal-lang.org/#/r/1i8d
<FromGitter> <dlanileonardo> This is correct way?
<RX14> hmm
<RX14> i'm not sure why "deep" doesn't need the `of`
<FromGitter> <dlanileonardo> Omg! We think together, ok i will put of in all nested objects.
<RX14> that is definitely broken
<FromGitter> <dlanileonardo> Ok! got it
<RX14> yeah i think that i'll manage to get a segfault from this
<FromGitter> <dlanileonardo> I Forget deep var. But Thank you so much, i learn crystal yet, but i love this language.
<FromGitter> <dlanileonardo> Thank You for help! :smile:
<RX14> yeah this is broken. https://play.crystal-lang.org/#/r/1i8j
bjz has joined #crystal-lang
<RX14> ok
<RX14> this makes it WAY more obvious
<RX14> bug report
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has quit [Remote host closed the connection]
mgarciaisaia has quit [Quit: Leaving.]
<RX14> @andyfleming there is no private and public for instance variables
<RX14> in your example, how would you access @example_one from the outside?
<FromGitter> <andyfleming> I was under the impression that it was public. So `person = Person.new`, the n`person. example_one # => "instance variable" : String`
<FromGitter> <mverzilli> I was about to ask the same, but then I added `puts Person.new.@example_one` to the end of his snippet and it works
<FromGitter> <andyfleming> (based on what I read here: https://crystal-lang.org/docs/syntax_and_semantics/new,_initialize_and_allocate.html )
<RX14> you need to define getters for any instance variable to be public
<RX14> in your example on github person.example_one will not work
<RX14> unless you define a getter method manually
<RX14> person.@example_one is a hidden, undocumented syntax for accessing private instance variables
<RX14> never use it
<RX14> it's meant for the stdlib only
<FromGitter> <andyfleming> Ohhhhhh
<FromGitter> <andyfleming> Gotcha
<FromGitter> <andyfleming> So it's private by default unless you create getters/setters
<FromGitter> <mverzilli> wow, didn't know that, it looked like a pretty nasty bug
<FromGitter> <andyfleming> Is there a github issue for that?
<RX14> for which?
<FromGitter> <andyfleming> accessing a private instance variable publicly?
<FromGitter> <andyfleming> ``` ⏎ person.@example_one`````` [https://gitter.im/crystal-lang/crystal?at=58659f7c7a3f79ef5db683cd]
<RX14> it's meant to be there
<RX14> just undocumented
<FromGitter> <andyfleming> why is it meant to be there?
<FromGitter> <andyfleming> Shouldn't we guard against it somehow?
<RX14> if you can reopen a class and add a getter
<RX14> there's no reason
<RX14> it's bad syntax though
<RX14> you also can't assign
<RX14> person.@example_one = "foo" won't work
<FromGitter> <andyfleming> Gotcha
<FromGitter> <andyfleming> Fair enough
<RX14> plus, trusting users isn't really a bad thing
<RX14> which is why we allow monkey-patching in the first place
<RX14> using that syntax to log some instance variable when puts debugging is really useful sometimes
<RX14> without having to define a getter
<FromGitter> <andyfleming> The examples on https://crystal-lang.org/docs/syntax_and_semantics/methods_and_instance_variables.html are pretty rough
<RX14> how so?
<RX14> oh
<RX14> yes they don't define getters
<FromGitter> <andyfleming> Opened a PR to add them here: https://github.com/crystal-lang/crystal-book/pull/61
<FromGitter> <andyfleming> I can see why one might want to exclude them, but when you are learning, it would be helpful to have code you can run
<FromGitter> <andyfleming> What is the recommended way to add a getter and setter? (I see the getter example, but didn't see an example with both)
<RX14> @andyfleming see macro docs on Object: https://crystal-lang.org/api/0.20.3/Object.html#getter%28%2Anames%29-macro
<RX14> scroll down to see all the possible getter/setter/property macros
<FromGitter> <andyfleming> Yup, I see them now
<FromGitter> <andyfleming> I may try to add examples to the docs of those. I think they are important
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RX14> we've discussed this
<RX14> and we've said that introducing macros so early is a bit advanced
<RX14> but manually writing out the getters when they're missing is a must