ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.23.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
<FromGitter> <codenoid> Morning!
<FromGitter> <codenoid> mmm, why has not anyone written a book about crystal (about the crystal itself, not about ruby), like "Nim in Action" for the nim language, etc.
<FromGitter> <codenoid> there was my friend asking about that 😄
<FromGitter> <codenoid> or wait until 1.0 ? ✨
<FromGitter> <faustinoaq> Ivo Balbaert, The author of multiple awesome Julia books (https://julialang.org/learning) is writing a book about Crystal (https://pragprog.com/book/crystal/crystal) ⏎ ⏎ Also @sdogruyol wrote a book http://www.crystalforrubyists.com/ ⏎ ⏎ I think those books would polished, updated and published after 1.0 [https://gitter.im/crystal-lang/crystal?at=59c849c5177fb9fe7efb31ad]
<FromGitter> <codenoid> can't wait https://pragprog.com/book/crystal/crystal 😆 ✨
snsei1 has joined #crystal-lang
snsei has quit [Read error: Connection reset by peer]
snsei has joined #crystal-lang
snsei1 has quit [Ping timeout: 240 seconds]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
DTZUZO has joined #crystal-lang
bmcginty has quit [Ping timeout: 260 seconds]
bmcginty has joined #crystal-lang
<FromGitter> <fridgerator> anyone ever see a `Killed` error running a web server?
<FromGitter> <fridgerator> nvmd, dmesg tells me i'm running out of memory
raz has quit [Ping timeout: 246 seconds]
raz has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
weston1 has joined #crystal-lang
<FromGitter> <faustinoaq> Hi I just realize some people do like Null Errors 😅 ⏎ ⏎ > Sure, Kotlin has some nifty features, but it sacrifices readability for writing shorter code. Apply and run blocks are a good idea but in practice your code just looks very compressed and not easily readable. The forced null safety is also a bad thing [0] ⏎ ⏎ https://medium.com/@bramhaag/sure-kotlin
<FromGitter> ... -has-some-nifty-features-but-it-sacrifices-readability-for-writing-shorter-code-923caf9f0bea [https://gitter.im/crystal-lang/crystal?at=59c873dabac826f054f5e14c]
balduin has quit [Ping timeout: 240 seconds]
A124 has quit [Ping timeout: 255 seconds]
A124 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
weston1 has quit [Ping timeout: 248 seconds]
_whitelogger has joined #crystal-lang
balduin has joined #crystal-lang
<FromGitter> <codenoid> i'm @fridgerator https://linux-mm.org/OOM_Killer
Philpax has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
weston1 has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
balduin has quit [Ping timeout: 240 seconds]
weston1 has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
<FromGitter> <ekremkaraca> Morning Crystal lovers!
<FromGitter> <zyriuse75> good morning
<txdv> i love to do some crystal in the morning
<FromGitter> <Rinkana> Morning 😄
<FromGitter> <bararchy> Morning all
<FromGitter> <marin117> Morning 😄
<FromGitter> <sdogruyol> Morning everyone
<Groogy_> Morning!
<FromGitter> <marin117> Anybody knows how to read timestamp data from postgres db? Query returns timestamp as Slice(UInt8) and it means me nothing...
<FromGitter> <bararchy> Slice(UInt8) is just a step from String :) ⏎ ⏎ ```String.new(Slice(UInt8))``` [https://gitter.im/crystal-lang/crystal?at=59c8ad9bb59d55b8233414cd]
<FromGitter> <marin117> hmm, I get some weird characters :(
<FromGitter> <marin117> ??@ to be precise
<FromGitter> <bararchy> Guess it was not suppose to be a string then
<FromGitter> <bararchy> hahah
<FromGitter> <bararchy> maybe it's in a specific Time format ?
<FromGitter> <bararchy> not sure
<FromGitter> <marin117> It is fun cause I write Time format in timestamp
<FromGitter> <marin117> and as query result "this"
<FromGitter> <marin117> :D
<FromGitter> <crisward> @marin117 check the driver to make sure it has a time type. I implemented it in the Mysql Driver and it's binary there, with bytes for year, month, day etc... There is also a different format again for time spans, ie when you get the difference between two times. If it doesn't have a type parser within the driver, you may just be getting the raw bytes back.
<FromGitter> <marin117> this could be the problem, yes, cause I really need time diff, not exact time, more like, I need sum of time diffs and it is little complicated
claudiuinberlin has joined #crystal-lang
mark_66 has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
snsei has quit [Remote host closed the connection]
Groogy has quit [Disconnected by services]
Groogy_ is now known as Groogy
<Groogy> Lol I just accidentally wrote a template in C++ like it was a Crystal generic
Groogy2 has joined #crystal-lang
<Groogy> and was confused over the compilation errors
<FromGitter> <sdogruyol> haha
claudiuinberlin has joined #crystal-lang
<FromGitter> <ansarizafar> Why I getting \ in Json output ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59c8b274cfeed2eb6548c01c]
<Groogy> because it is a string
<Groogy> if you output it to a file the \ won't be there
<Groogy> it is just there to denote it is a "
<FromGitter> <bew> Don't use `result.to_json`
<FromGitter> <bew> Just `result`
<FromGitter> <bew> The last `finalResult.to_json` is enough
<FromGitter> <bew> You need to determine the type of `result` and put this as the value type of `finalResult`'s Hash
flaviodesousa has joined #crystal-lang
<FromGitter> <bew> In your method, you shouldn't have to deal with json types etc
<Groogy> Also do anyone here have experience creating a GUI? I would like some opinions on what worked well and what didn't work as well?
<FromGitter> <bew> (In your whole class actually)
<Groogy> I am worried I am just gonna convert my own old framework from C++ which.... isn't all that great
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter> <bararchy> It seems that Crystal HTTP::Client can't handle a response with no "Reason" status
rohitpaulk has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <ansarizafar> @Groogy typeof (result ) shows ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59c8bd8a7b7d98d30d32fa2d]
<FromGitter> <bararchy> Oh, nvm, seems to work
<Groogy> YAML::Type is a union, I would guess the same applies to JSON?
<Groogy> or wait it is result
claudiuinberlin has joined #crystal-lang
<Groogy> result can from me reading the code be either Nil, { "success" => true , "data" => @@store[key].call(value.as(Hash)) } or {"success" => false, "data" => nil}
<Groogy> that's why it is a union
claudiuinberlin has quit [Client Quit]
<Groogy> and the type between the two Hashes are also two different types
claudiuinberlin has joined #crystal-lang
<FromGitter> <bew> @ansarizafar why do your `Tools.json_param` returns some json types?
<FromGitter> <ansarizafar> @bew Tools.json_param is extracting an object from context.request.body and returning it as a hash. I am trying to port my Graphql inspired data layer library from Nodejs.
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <ansarizafar> Is it possible to define a proc without defining the return type in advance but returning a value. This is important If we can't determine a return value in advance.
<FromGitter> <bew> iirc you can say `def foo(&bar : String -> _)` to say that the block takes a `String` and return something, but it can be anything. However, if you want to store the proc (e.g: in a Hash), you'll need to know the return type if I remember correctly
<FromGitter> <bew> although I don't why you need to know all the proc's types to store it..
<FromGitter> <ansarizafar> Related question is it possible to define a hash without defining types
<FromGitter> <bew> heee no
<FromGitter> <bew> @ansarizafar here is your `Api.run` method a bit cleaner I think: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Do whatever you want with this. From this you just need to fix the type problem and it should work [https://gitter.im/crystal-lang/crystal?at=59c8cc8fcfeed2eb65493e00]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
bmcginty has quit [Ping timeout: 240 seconds]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
bmcginty has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
<FromGitter> <imonmyown> Hi all, ⏎ What's the right way to write code like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59c8d8a9b59d55b82334e42c]
<FromGitter> <bew> you can remove `self.` from `self.new` (as it is called from a class method, it will automatically call other class methods), otherwise it looks ok!
<FromGitter> <bew> you're making a singleton right?
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <imonmyown> I have a problem with it
<FromGitter> <imonmyown> Yeah, a singleton
<FromGitter> <bew> what problem?
<FromGitter> <imonmyown> ```Can't infer the type of class variable '@@generator' of Generator```
<FromGitter> <bew> oh right, you need to tell him the type of `@@generator`, in this case it's a `Generator`
<FromGitter> <bew> just add `@@generator : Generator` somewhere in the class, to tell the compiler that this class variable has a specific type
<FromGitter> <imonmyown> now I have another error: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59c8d9f4c101bc4e3a05c811]
<FromGitter> <bew> grr `@@generator : Generator?`
<FromGitter> <imonmyown> `@generator : Generator | Nil`?
<FromGitter> <bew> yeah, adding `?` to a type makes it a union like you just wrote
<FromGitter> <imonmyown> Oh, great. Thanks!
<Groogy> yeah it is shorthand to add it as a "can be potentially Nil"
balduin has joined #crystal-lang
<FromGitter> <imonmyown> Thanks guys!
<FromGitter> <bew> "potentially" ^^
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZU has quit [Ping timeout: 264 seconds]
<FromGitter> <marin117> Anybody knows how can I read JSON data from Http response?
<FromGitter> <bew> I guess the same way you do with a simple string?
<FromGitter> <bararchy> @marin117 Maybe you mean "parse" ? \
<FromGitter> <marin117> kinda parse, yes
<FromGitter> <bararchy> well, if the JSON is in the body ⏎ ⏎ ```json = JSON.parse(response.body)``` [https://gitter.im/crystal-lang/crystal?at=59c8e8a3210ac269206c9707]
<FromGitter> <bararchy> but if it's not the "whole body" , then I guess you will need to extract and parse it out
<FromGitter> <bararchy> via Regex or rules you decided uppon
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <crisward> If you know the structure of the data, it's not a bad idea to create a class with JSON.mapping. You can the just `res = Myclass.from_json(response.body)` Which will give you an object for your response.
rohitpaulk has joined #crystal-lang
<FromGitter> <marin117> @bararchy it is working, thank you :) ⏎ ⏎ @crisward I will consider that, it is good idea for sure
<FromGitter> <marin117> (code design does not depend on me, so ...)
claudiuinberlin has joined #crystal-lang
<FromGitter> <OldhamMade> Hey all. I'm trying to use the waterlink/mocks.cr library to mock Dir.glob so that it returns a fixed Array for testing, however I'm unable to actually get the mock to apply. Would anyone know the correct way to mock and call it so that I can control the result in my specs?
<FromGitter> <OldhamMade> I've seen mocks work with File.exists?, but that only has one definition in the source. Dir.glob has 4, and the mocks I'm applying don't seem to match the way it's being called.
<FromGitter> <bararchy> you can jusr redifine it in your spec
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59c8ebce32fc8b7e4039f606]
<FromGitter> <OldhamMade> that doesn't seem to work either
<FromGitter> <bew> how are you calling it?
<FromGitter> <ansarizafar> @bew thanks for the help
<FromGitter> <OldhamMade> I have a function that uses Dir.glob and does something with the results
<FromGitter> <bararchy> yeha, but what parameters are you passing ?
<FromGitter> <OldhamMade> I'd like to force Dir.glob to return a specific array so I can test how my code behaves around it
<FromGitter> <bararchy> so we can match the types
<FromGitter> <OldhamMade> for now, just `"*"`
<FromGitter> <OldhamMade> I've tried `["*"]` too, with various mocks, but I'm misunderstanding something
<FromGitter> <bararchy> su use my above exmaple but with `.glob(str : String)`
<FromGitter> <bararchy> should do it
<FromGitter> <ansarizafar> What's wrong with this statement ⏎ ⏎ ``` {success : true, data: result}``` ⏎ ⏎ getting this error -> expecting token 'CONST', not 'true' [https://gitter.im/crystal-lang/crystal?at=59c8edaebc46472974724ad7]
<FromGitter> <bararchy> success: true
<FromGitter> <bararchy> no space
<FromGitter> <bararchy> else it think you specify a type
<FromGitter> <bararchy> and types are Constants
<FromGitter> <OldhamMade> @bararchy still no joy, the following doesn't seem to get picked up: ``` ⏎ class Dir ⏎ def self.glob(patterns : String) ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=59c8ee0532fc8b7e403a0255]
<FromGitter> <bararchy> dir is not a class
<FromGitter> <bararchy> ASAIK
<FromGitter> <bararchy> it's a module
<FromGitter> <bararchy> module Dir
<FromGitter> <OldhamMade> if I use `module` it complains
<FromGitter> <bararchy> but let me make sure
<FromGitter> <OldhamMade> and I'm looking at the source now
<FromGitter> <OldhamMade> it's `crystal/glob.cr`
<FromGitter> <bararchy> yeha
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <bararchy> it shold be ⏎ ⏎ ```def self.glob(patterns : Enumerable(String))``` [https://gitter.im/crystal-lang/crystal?at=59c8ee90bac826f054f7dff4]
ShalokShalom_ is now known as ShalokShalom
<FromGitter> <OldhamMade> nope, that doesn't work either
<FromGitter> <OldhamMade> sorry about this, I'm very new to Crystal
<FromGitter> <bararchy> 😢
<FromGitter> <bararchy> no no, it's fine
<FromGitter> <bararchy> I dont get it either
<FromGitter> <OldhamMade> FYI, these are all the mocks I've tried: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59c8eede614889d4753835b4]
<FromGitter> <bararchy> @bew ? or @crisward ? any ideas ?
<FromGitter> <bew> working here https://carc.in/#/r/2skc
<FromGitter> <bew> with `self.glob(*patterns) : Array(String)`
<FromGitter> <OldhamMade> @bew thanks – I assumed it was something to do with the `*patterns` but I wasn't sure how to approach that.
<FromGitter> <bew> don't miss the `*` @OldhamMade in you mock
<FromGitter> <bew> ;)
<FromGitter> <OldhamMade> is the `*` similar to python's `*args`? eg. collect all arguments
<FromGitter> <bararchy> Thanks @bew
<FromGitter> <bew> yes
<FromGitter> <OldhamMade> perfect, that makes sense
<FromGitter> <bew> yw!
<FromGitter> <OldhamMade> so would this be the preferred approach, rather than using the `mock.cr` library?
<FromGitter> <OldhamMade> and would it even be possible using that lib?
<FromGitter> <bew> I think it should work yes
<FromGitter> <OldhamMade> I'm going to write this up to help other people coming to Crystal from non-ruby backgrounds
<FromGitter> <bararchy> It's better because it's clearer and less depends
<FromGitter> <OldhamMade> I found that doing something like the following would fail to build: ⏎ ⏎ ```Mocks.create_mock Dir do ⏎ mock self.glob(*patterns) ⏎ end``` ⏎ ⏎ and `mock self.glob` failed to patch [https://gitter.im/crystal-lang/crystal?at=59c8f0a2bac826f054f7e9e6]
claudiuinberlin has joined #crystal-lang
<FromGitter> <OldhamMade> eg. ⏎ ⏎ ```Mocks.create_mock Dir do ⏎ mock self.glob(patterns) ⏎ end``` ⏎ ⏎ ...generally wouldn't work, hence my question here :) [https://gitter.im/crystal-lang/crystal?at=59c8f0f4bac826f054f7eaf2]
<FromGitter> <bew> maybe it's a bug with `mocks.cr` library, not allowing splat argument?
<FromGitter> <bew> @waterlink are you around?
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter> <bew> what's the build error when using `*patterns`?
rohitpaulk has joined #crystal-lang
<FromGitter> <OldhamMade> actually, it's still not working with my tests when redefining :(
<FromGitter> <OldhamMade> build error with `*patterns`: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59c8f248614889d47538496e]
<FromGitter> <OldhamMade> As for how I'm calling `Dir`: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59c8f31732fc8b7e403a1951]
<FromGitter> <OldhamMade> `Dir.glob` is called from within `find_files()`
<FromGitter> <bew> can you show the line where you're calling it?
<FromGitter> <OldhamMade> ``` Dir.glob(patterns) do |file|```
<FromGitter> <OldhamMade> ```def find_files(basedir, patterns) ⏎ Dir.glob(patterns) do |file|``` [https://gitter.im/crystal-lang/crystal?at=59c8f3aebac826f054f7fd57]
<FromGitter> <bew> hmmm you're calling it with a block, that's different than calling it without, and the method signature is different, not sure how to mock a method with block with that library
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <OldhamMade> ah, I didn't realize that would have an effect
<FromGitter> <bew> maybe you can simply mock `find_files` ?
<FromGitter> <bew> Also the mocking library seems to have some limitation (https://github.com/waterlink/mocks.cr/issues/13)
<FromGitter> <OldhamMade> find_files is the thing I want to test :)
<FromGitter> <bew> not sure it's a good idea, but you could run it, and compare with a real call to Dir.glob? as it doesn't have side-effect, it should be ok I think
<FromGitter> <OldhamMade> yeah, I considered creating some files within my specs dir to glob against, but I wanted a bit more control to fully exercise the function
<FromGitter> <OldhamMade> I'm also taking it as an opportunity to properly learn how to mock correctly in Crystal :D
claudiuinberlin has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <OldhamMade> ok, I've changed my impleme
<FromGitter> <OldhamMade> would be nice to understand how to handle calling it with a block, to keep code terse in the future
rohitpaulk has joined #crystal-lang
<FromGitter> <mverzilli> did you try `Dir.glob(patterns).each do [ etc...]`
<FromGitter> <bew> this works though https://carc.in/#/r/2skh
<FromGitter> <bew> no idea how to do that with the mock lib..
<FromGitter> <bew> could also be written using `yield` https://carc.in/#/r/2ski (this is block forwarding)
<FromGitter> <OldhamMade> @mverzilli not explicitly, but assigning to `files` first is pretty-much the same
snsei has joined #crystal-lang
<FromGitter> <crisward> If you work out how to mock correctly in crystal, let me know. 😉
<FromGitter> <OldhamMade> @bew thanks for those examples! I'm not from a Ruby background, so I'll have to get myself used to blocks
<FromGitter> <OldhamMade> @crisward I think you'll get there way before I do!
<FromGitter> <OldhamMade> right, back to the paying job. thanks @everyone for the assistance!
<FromGitter> <crisward> @OldhamMade if you understand callbacks in node, blocks are the same, only you can't as easily pass the block around, though they can be converted to proc's to do that more easily. Think crystal book has something about it...
<FromGitter> <crisward> BTW you from Oldham?
snsei has quit [Ping timeout: 246 seconds]
<FromGitter> <sdogruyol> he's definitely from UK lol
bmcginty has quit [Ping timeout: 240 seconds]
<FromGitter> <bew> (from somewhere 😂)
sasdsadasd has joined #crystal-lang
sasdsadasd has quit [Client Quit]
bmcginty has joined #crystal-lang
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
alexherbo2 is now known as alex``
rohitpaulk has quit [Ping timeout: 246 seconds]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
sz0 has joined #crystal-lang
hightower4 has joined #crystal-lang
<FromGitter> <exts> how do you capture a block within a macro to be passed to a class method?
hightower3 has quit [Ping timeout: 255 seconds]
snsei has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Philpax_ has joined #crystal-lang
salvor has quit [Ping timeout: 240 seconds]
ShalokShalom_ has joined #crystal-lang
<FromGitter> <exts> bit rusty and compiler is yelling at me atm (error expanding macro), was never good with macros ⏎ ⏎ https://gist.github.com/exts/38647cb2407a7b81a3d447ceb464be6d
Philpax has quit [Ping timeout: 240 seconds]
<FromGitter> <asterite> However in your example you don't need the macro at all, you can probably use a method
<FromGitter> <exts> yeah I know, it's just an example that I wrote to be as simple as possible
<FromGitter> <exts> ah well, guess I'll wait for that to get sorted.
ShalokShalom has quit [Ping timeout: 260 seconds]
salvor has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
<FromGitter> <imonmyown> Hey guys
<FromGitter> <imonmyown> What code is generally put into `finalize`?
<FromGitter> <bararchy> So crystal-tensorflow or tensorflow.cr ?
<FromGitter> <bararchy> For repo name for Tensor flow lib binding
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> I like the last one
<FromGitter> <imonmyown> tensorflow in crystal sounds interesting
<FromGitter> <imonmyown> On my question above: I want to ensure some data is written to a file when an object is destroyed, do I use `finalize` for that purpose or there's a better and more idiomatic way?
<FromGitter> <bararchy> Already got libfann bindings
<FromGitter> <bew> @imonmyown none
<FromGitter> <bararchy> def close .. f.sync .. f.close .. end
<FromGitter> <imonmyown> @bew so there's no way to do that even with finalize?
<FromGitter> <bararchy> And call close
<FromGitter> <bew> `finalize` will not always run! It will run only when the GC is about to collect an object, but not when the program closes for example
<FromGitter> <imonmyown> right, didn't think about that
<FromGitter> <bew> @bararchy s/../;/g
<FromGitter> <bararchy> Hahaha yeha , was just to show the overall idea
<FromGitter> <imonmyown> I probably didn't succeed in providing a clear explanation of what I'm trying to do, let me hack up some code...
<FromGitter> <imonmyown> ```code paste, see link``` ⏎ ⏎ Will something like that work? [https://gitter.im/crystal-lang/crystal?at=59c9149d614889d475390ad1]
<FromGitter> <imonmyown> I guess the problem with `finalize` remains
<FromGitter> <bararchy> Can't you call the finalize manually after work is done (and rename it close)?
<FromGitter> <bararchy> do_work
<FromGitter> <bararchy> ===work===
<FromGitter> <bararchy> close
<FromGitter> <bararchy> end
<FromGitter> <bararchy> Etc...
<FromGitter> <imonmyown> That might be it, thanks @bararchy
<FromGitter> <bararchy> @imonmyown you welcome , hope it works :)
<FromGitter> <bew> There is also this form https://carc.in/#/r/2sl6
<FromGitter> <bararchy> Yeha its cool , like File.open do
hightower3 has joined #crystal-lang
alex`` has quit [Quit: WeeChat 1.9]
hightower4 has quit [Ping timeout: 240 seconds]
hightower4 has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hightower3 has quit [Ping timeout: 240 seconds]
DTZUZU has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
DTZUZO has joined #crystal-lang
hightower4 has quit [Ping timeout: 246 seconds]
<FromGitter> <jwaldrip> When is the next Crystal release?
DTZUZO has quit [Read error: Connection reset by peer]
hightower4 has joined #crystal-lang
DTZUZU has quit [Ping timeout: 248 seconds]
DTZUZU has joined #crystal-lang
DTZUZO has joined #crystal-lang
<Groogy> honestly not a clue
<FromGitter> <bararchy> @jwaldrip maybe you should ask @mgarciaisaia or RX14
<Groogy> haven't even tohught of it
<FromGitter> <bararchy> You can always just use head from got
<FromGitter> <bararchy> git*
<FromGitter> <bararchy> As long as Head builds and spec are passing , it's "good enough"
<FromGitter> <ansarizafar> I am finding it difficult to use Postgresql with crystal for rest apis. Is there any tutorial/example?
<FromGitter> <mverzilli> We'll tag 0.24 as soon as we merge the YAML revamp PR
<FromGitter> <bew> @mverzilli awesome!
ephemera_ has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <asterite> @mverzilli I'd include the Time PR, and also the Int128 and UInt128
<FromGitter> <asterite> Maybe also https://github.com/crystal-lang/crystal/pull/5017 , which will improve that situation just a bit
<Groogy> Oh native Int128 and UInt128?
<Groogy> How does that work? Won't it be occupying like two registers?
<Groogy> or does clang do magic with that stuff?
<FromGitter> <asterite> LLVM generates emulation code for it
<FromGitter> <bew> Groogy there is some discussion about it in https://github.com/crystal-lang/crystal/pull/5022#issuecomment-331556547 (and after)
<FromGitter> <asterite> Actually, I'm still not sure this is supported on every platform: https://github.com/zig-lang/zig/tree/master/std/special/compiler_rt
<FromGitter> <mverzilli> @asterite sounds good to me :). I was just waiting for the work on YAML to end mainly because the work put on the original PR was insane and it'd be a pity to have it wait until 0.25
<FromGitter> <asterite> :)
<FromGitter> <asterite> Yeah, the YAML PR is pretty much done :-D
<oprypin> mverzilli, don't forget about https://github.com/crystal-lang/crystal/pull/4894
<oprypin> i've been noticing that PRs get tagged as "Next" after they're merged
<oprypin> why not add that tag to PRs that are wanted before the next release, before merging them
<FromGitter> <asterite> But that's missing work, namely using `Random::Secure` instead of `Random::System`
<FromGitter> <jwaldrip> I would love for the YAML PR to get in. It looks good to me as it stands. I think the next big step for YAML before 1.0 would be to support a native crystal parser.
<FromGitter> <bew> @mverzilli can you add the mentioned issues to the `Next` milestone so we can better track when it will be done, and what needs work until next release?
<oprypin> asterite, no it's not missing work
<FromGitter> <asterite> @jwaldrip Why do we need a native crystal parser?
<FromGitter> <jwaldrip> Why not?
<oprypin> if u feel strongly about the name, u can change that yourself. and i guess you two do agree to that
<oprypin> but really it's a separate change
<FromGitter> <bew> ah oprypin I see we're thinking the same here about the Next milestone ^^
<oprypin> the pull request does not change that name
<FromGitter> <asterite> @jwaldrip Because it's bug-prone, more code to compile and more work on us
<FromGitter> <asterite> @oprypin I see. Yes, we can always merge that and later do the rename, it will be easier to review too :-)
<Groogy> might as well piggyback ride on someone dedicated to maintaining the parser
<FromGitter> <mverzilli> @oprypin because most of the time we don't care if a PR gets in "current + 1" or "current + 2" release
<oprypin> not sure about merging process, i'd like it to be squashed in a particular way
<FromGitter> <jwaldrip> I would love to see crystal to move to being less dependent on libraries. If you look at the route Go took, it has made the language more portable. Right now getting a portable crystal binary is MUCH harder than getting a portable Go binary
<oprypin> mverzilli, most of the time you don't, but you just said that this time you clearly do
<FromGitter> <jwaldrip> Getting Crystal to run on alpine linux in a process. Where as with go, once built, it runs anywhere.
<FromGitter> <asterite> Yes, but Go can compile a file into a binary. Crystal can't do that. So more code means more time to compile stuff.
<oprypin> jwaldrip, it's a lot of work, u know
<FromGitter> <mverzilli> yes, agree that in this case we could do that, just arguing against making it the general practice
<FromGitter> <jwaldrip> What do you mean compile a file into a binary?
<Groogy> it can't create object files
<FromGitter> <mverzilli> because ideally we should be able to release more less monthly (and before you mention that, I'm aware we've failed to do so in the last 2 or 3 releases)
<Groogy> it needs the entire context of all the code to generate the binary
<FromGitter> <jwaldrip> Go "can" have library deps. It just doesnt in the standard library.
<FromGitter> <bew> @jwaldrip in Go, you can have 1 file <=> 1 binary file. In Crystal it more all files <=> 1 binary file (iirc)
<FromGitter> <jwaldrip> Im just saying, it would be ideal if the crystal standard library became all native, one day...
<FromGitter> <asterite> And I'm just saying that if that happens one day, compiling a "Hello world" program would take 1 minute :)
<FromGitter> <jwaldrip> Why would it take one minute?
<FromGitter> <asterite> Because it would need to parse and type the whole program
<FromGitter> <jwaldrip> What does that have to do with a YAML parser?
<oprypin> nothing
<FromGitter> <jwaldrip> Maybe I dont understand Crystal... The more source code in crystal the longer it will take for programs to compile?
<oprypin> it's a separate discussion
<FromGitter> <asterite> Well, you do `require "yaml"` and instead of taking 1 second to compile it would take 3 or 4 seconds
<oprypin> oh nvm
<FromGitter> <asterite> If we change EVERYTHING to be written in Crystal, every program that requires anything will take more time to compile
<FromGitter> <asterite> Like, decoding dwarf stack frames is now done in Crystal, and compile times grew
<Groogy> I can already notice it in my framework
<FromGitter> <asterite> Printing floating points accurrately is now done in Crystal, and compile times grew again
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <asterite> And so on...
<Groogy> including my framework and compile a simple application takes a few seconds
<oprypin> basically, rewriting everything in crystal is not only something that can't be prioritized, but it also is kinda blocked by lack of incremental compilation
<FromGitter> <jwaldrip> Okay... so isn't their work to also optimize the compiler?
<oprypin> "their"?
<FromGitter> <jwaldrip> there*
<FromGitter> <jwaldrip> sorry
<Groogy> It is like this because of a design choice in the language
<oprypin> now that's incorrect xD
<Groogy> Well we can't have incremental linkage because it needs the context of the code right?
DTZUZO has quit [Ping timeout: 252 seconds]
DTZUZU has quit [Ping timeout: 255 seconds]
<Groogy> in order to generate the functions needed when you call the stuff
<Groogy> so including a .a or .so file is kind of out the window
<oprypin> no no, of course it has to be an intermediate representation
<FromGitter> <sdogruyol> Rust followed the same path
<FromGitter> <sdogruyol> they're far ahead though with MIR and so on
<FromGitter> <jwaldrip> Regardless of the how, I hope that someday, the compiler will be optimized so that the frameworks that are being built are compiled quickly, but that will also help to support the cause of putting everything in Crystal. This CAN be done with a strong development community and as the language evolves.
mark_66 has quit [Remote host closed the connection]
<FromGitter> <jwaldrip> So maybe YAML wont be native pre 1.0
<FromGitter> <jwaldrip> But I hope for it to be someday.
<FromGitter> <bew> 👍 I'd also love that
<FromGitter> <asterite> I'm not sure. I don't think a strong development community can solve the halting problem, for example
<Groogy> Well I would say only benefit of it really for majority of usage is if there's someone maintaining YAML parser next to the compiler, like as far as I remember the YAML parser for Ruby wasn't made by the Ruby team
DTZUZO has joined #crystal-lang
rohitpaulk has joined #crystal-lang
DTZUZU has joined #crystal-lang
<FromGitter> <pawandubey> Hi 👋 ⏎ From the docs I understand that there is no way to change the receiver of the method calls inside a captured block. Is there an alternate way to mimic Ruby's `instance_eval` & `class_eval`?
<Groogy> Hmm wasn't there something with yield?
<FromGitter> <pawandubey> Yeah there's `with object yield`
<Groogy> yeah?
<FromGitter> <pawandubey> But that doesn't capture the block - it evaluates it in context of the `object` and returns the result
<FromGitter> <bew> then what do you need?
<Groogy> yeah because it sounds like what oyu asked for?
<FromGitter> <pawandubey> I don't want it to evaluate immediately - I am looking for lazy evaluation
<Groogy> Well language is static so :/
<FromGitter> <bew> ah I did that, let me find the link
<Groogy> oh okay I have no idea what you trying to do ^^
<FromGitter> <pawandubey> I don't think being static prevents it from supporting lazy eval
<FromGitter> <pawandubey> @bew That would be great! Thanks :)
<FromGitter> <pawandubey> Ooh yeah
<FromGitter> <pawandubey> So you wrap the `with context yield` inside another lambda/proc
<FromGitter> <pawandubey> Nice
<FromGitter> <bew> note that I've not stress tested it, but feel free, I'd love to take feedback
<FromGitter> <pawandubey> Should have thought of that
<Groogy> ah now I get it alright
<FromGitter> <krypton97> Does anyone know what makes the Go compiler so fast? It's even faster than rust from what I've noticed..
<Groogy> I thought you meant evaluate the code lazily (as in if you were doing eval("string"))
<Groogy> though come to think of it D does have the mixin keyword that let's you generate code from constexpr strings so.... ¯\(°_o)/¯
<FromGitter> <pawandubey> Nope. Just prevent eval till stuff is defined :)
<FromGitter> <pawandubey> Not the literal `eval`
<Groogy> guess is also possible to do that
<Groogy> well you could have static eval as well technically I guess if Crystal eventually starts supporting more in way of constant expressions
<FromGitter> <pawandubey> It allows me to forward reference things that aren't defined yet (but that i know are going to be defined)
<FromGitter> <mverzilli> @krypton97 a very limited type system without generics and a lot of money :P
<FromGitter> <sdogruyol> nice sum up @mverzilli 💯
<FromGitter> <bew> ahahah
<FromGitter> <krypton97> Seems legit, time is money
<FromGitter> <ansarizafar> I am getting error -> undefined method 'name' Can some one tell me. what is wrong with the code ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59c92bd7210ac269206e0084]
<FromGitter> <pawandubey> You have the `:` at the wrong place @ansarizafar I think
<FromGitter> <bew> `{id: idn, name: fname}`
<FromGitter> <pawandubey> ☝️
<FromGitter> <bew> it's trying to call `name` with argment `:fname`
<FromGitter> <pawandubey> @bew Ooh, I see a major coincidence. I am actually writing a PEG parser library in Crystal. I remember seeing `Astral` when I first searched for prior art. Lol.
<FromGitter> <bew> oh nice! how is it?
<FromGitter> <ansarizafar> Now getting this error ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59c92c9af7299e8f536ea43a]
<FromGitter> <pawandubey> @bew I am along the way somewhere. https://github.com/pawandubey/pegasus ⏎ I have the DSL and everything but there is no polish (also this lazy-eval limitation was preventing me from supporting recursive grammars)
<FromGitter> <bew> cool!
<FromGitter> <pawandubey> @ansarizafar Your `fname` seems to be an `Int32` value while you declare the `data` array with both tuple values as string
<FromGitter> <ansarizafar> Ya Fixed
<FromGitter> <ansarizafar> Thanks
<FromGitter> <bew> @pawandubey did you see the Wiki of Astral? this is my current task, gather ideas and stuff about parsing, needs, cool things, and dsls, didn't start anything else right now
<FromGitter> <bew> Did you already planned some features? Or are you doing it as you feel the need?
sz0 has joined #crystal-lang
DTZUZO has quit [Ping timeout: 264 seconds]
DTZUZU has quit [Ping timeout: 260 seconds]
DTZUZU has joined #crystal-lang
DTZUZO has joined #crystal-lang
ShalokShalom_ is now known as ShalokShalom
Ven has joined #crystal-lang
Ven is now known as Guest72709
tilpner has joined #crystal-lang
tilpner has quit [Client Quit]
tilpner has joined #crystal-lang
Groogy2 has quit [Quit: WeeChat 1.9]
Guest72709 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <OldhamMade> @crisward there's a Crystal book? I'll give that a google. And no, I'm not from Oldham, but actually not too far away.
<oprypin> OldhamMade, probably just this https://crystal-lang.org/docs/
Ven has joined #crystal-lang
Ven is now known as Guest37155
Guest37155 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven_ has joined #crystal-lang
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
rohitpaulk has quit [Ping timeout: 252 seconds]
snsei has quit [Remote host closed the connection]
claudiuinberlin has joined #crystal-lang
snsei has joined #crystal-lang
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has quit [Remote host closed the connection]
<FromGitter> <eliasjpr> If you want some amber tees https://teespring.com/stores/amber-framework
<oprypin> thats nice
<oprypin> if only it said "crystal" instead of "amber" :p
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <bew> really nice!
mccallofthewild has joined #crystal-lang
mccallofthewild has quit [Client Quit]
<crystal-gh> [crystal] oprypin opened pull request #5035: Simplify rotate count calculation (master...rotate) https://git.io/vdI8U
cyberarm has quit [Ping timeout: 252 seconds]
cyberarm has joined #crystal-lang
<crystal-gh> [crystal] mverzilli closed pull request #5035: Simplify rotate count calculation (master...rotate) https://git.io/vdI8U
sp4rrow has joined #crystal-lang
<oprypin> asterite, if i added type annotations to a lot of methods in crystal (when those help document the method), would you accept the PR?
<FromGitter> <bew> it feels that it's missing the point of not having to write the types..
<oprypin> sigh
<oprypin> bew, you also don't have to write documentation, but people do, for some reason
<oprypin> this is documentation but better
<FromGitter> <bew> yeah I know, I don't know how to solve the documentation otherwize, but I'was just saying
<FromGitter> <zyriuse75> hi
<FromGitter> <zyriuse75> Do you know with what i can make a GUI in crystal ?
<FromGitter> <asterite> @oprypin Definitely!
<FromGitter> <asterite> I think the more type annotations we have, everywhere, the better. If later we have to change the language somehow to require these type annotations it will be easier to migrate :-)
<FromGitter> <asterite> But they also help document everything better
<FromGitter> <bararchy> @zyriuse75 we got QT5 bindings, also a few grphic engines
<FromGitter> <zyriuse75> @bararchy thank man i going to see that now !!
<FromGitter> <zyriuse75> do you know the others ?
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <charlie-hadden> Hey! I'm using crystal in a kind of weird environment where I'm not able to include the prelude. I've been able to get most of the stuff I need so far with the primitives, but I'm stuck on strings. Obviously I'm not going to get all of the methods on the class without including it, but is it possible to get access to the buffer? At the moment I have a workaround with macros but I'd like to do it a more
<FromGitter> ... proper way if possible
<FromGitter> <jose-rodrigues> "string".to_unsafe maybe?
<FromGitter> <charlie-hadden> Looks like that's defined in string.cr unfortunately https://github.com/crystal-lang/crystal/blob/e2a1389e8165fb097c785524337d7bb7b550a086/src/string.cr#L4054-L4056
<FromGitter> <charlie-hadden> Looks like the nodoc `HEADER_SIZE` is what I was after though. `Pointer(UInt8).new(address + STRING_HEADER_SIZE)` seems to work
<FromGitter> <asterite> You can just define to unsafe for string like that
<FromGitter> <charlie-hadden> Ah cool, that seems much safer than using a magic value
<FromGitter> <charlie-hadden> Do you know whereabouts that `@c` is defined?
<FromGitter> <asterite> program.cr
<FromGitter> <asterite> It's hardcoded in the compiler
<FromGitter> <charlie-hadden> Got it, thanks
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
<cerulean> does anyone know where to go for crystal jobs? just curious
sp4rrow has joined #crystal-lang
<crystal-gh> crystal/master ecd3368 Stefan Merettig: Add NamedTuple#merge(other : NamedTuple) (#4688)...
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/vdIwU
<FromGitter> <charlie-hadden> I need to get this project up on github soon. It's a little x86 kernel I'm working on just to see what's possible with low-level crystal
hightower4 has quit [Ping timeout: 252 seconds]
<FromGitter> <charlie-hadden> So far, apart from a little bit of assembly for bootstrapping, everything I've wanted to be possible has been
<cerulean> nice
<FromGitter> <charlie-hadden> Mostly wanted to try it because I've seen a few people say it wasn't possible 🤷
<FromGitter> <charlie-hadden> Well, that and that crystal is amazing to work with and the more I do with it the happier if makes me - thanks to all the contributors!
hightower4 has joined #crystal-lang
<FromGitter> <bew> good job @charlie-hadden ;)
hightower4 has quit [Ping timeout: 240 seconds]
hightower4 has joined #crystal-lang
<FromGitter> <uSide> How to delegate class method?
<FromGitter> <uSide> self.blabla
weston1 has joined #crystal-lang