ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | 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
<RX14> well
<RX14> time to sleep
<OvermindDL1> I want to teach OCaml again, it's fun
<OvermindDL1> Sleep well
<RX14> I'll revise for my univerity tomorrow I promise
<RX14> (been saying that for the last week)
* OvermindDL1 works at a college
<RX14> s/university/exams
<Vexatos> RX14, you will end up just working on your new website
<RX14> lol
<RX14> aaaaaaaa dont remind me
<RX14> only my 4th domain lol
<RX14> Vexatos, who was that guy who said he had like 60 domains, you remember?
<Vexatos> I do not, sorry
<RX14> :(
<OvermindDL1> Not me? 😅
<RX14> lol
<RX14> no this guy was crazier
<OvermindDL1> Lol
<RX14> night
<OvermindDL1> Night
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alex`` has joined #crystal-lang
shelvacu has quit [Ping timeout: 256 seconds]
shelvacu has joined #crystal-lang
marius has quit [Ping timeout: 252 seconds]
marius has joined #crystal-lang
<Groogy> Morning! o/
Nik736 has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #5913: Fix `String#tr` 1 byte `from` optimization bug (master...fix/string/tr-bug) https://git.io/vx1rW
Nik736 has quit [Ping timeout: 248 seconds]
flaviodesousa has joined #crystal-lang
<crystal-gh> [crystal] CaDs closed pull request #5762: added documentation for Kernel#sprintf method (fixes #3124) (master...fix/added_documentation_for_printf_method) https://git.io/vA9vk
<crystal-gh> [crystal] CaDs opened pull request #5914: added documentation for Kernel#sprintf method (fixes #3124) (master...fix/added_documentation_for_printf_method) https://git.io/vx1i4
<crystal-gh> [crystal] ysbaddaden pushed 1 new commit to master: https://git.io/vx1i1
<crystal-gh> crystal/master 9662abe TSUYUSATO Kitsune: Fix `String#tr` 1 byte `from` optimization bug...
jokke has quit [Quit: WeeChat 2.0.1]
jokke has joined #crystal-lang
<crystal-gh> [crystal] straight-shoota opened pull request #5915: Fix File.join with empty path component (master...jm/fix/file-join-empty) https://git.io/vx1MJ
<travis-ci> crystal-lang/crystal#9662abe (master - Fix `String#tr` 1 byte `from` optimization bug): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/362032912
Nik736 has joined #crystal-lang
ua has joined #crystal-lang
duane has joined #crystal-lang
early` has joined #crystal-lang
Groogy_ has joined #crystal-lang
Totoro- has joined #crystal-lang
johndescs_ has joined #crystal-lang
SuperChickeNES has joined #crystal-lang
duper_ has joined #crystal-lang
olbat__ has joined #crystal-lang
Groogy has quit [*.net *.split]
johndescs has quit [*.net *.split]
gewo has quit [*.net *.split]
z64 has quit [*.net *.split]
olbat has quit [*.net *.split]
Cyrus1 has quit [*.net *.split]
ChickeNES has quit [*.net *.split]
early has quit [*.net *.split]
Totoro has quit [*.net *.split]
duper has quit [*.net *.split]
johndescs_ is now known as johndescs
gewo has joined #crystal-lang
Cyrus1 has joined #crystal-lang
z64 has joined #crystal-lang
return0e has quit [Ping timeout: 256 seconds]
Papierkorb has joined #crystal-lang
<wuehlmaus> earlier a take method was used, it is gone, was it deleted or just renamed? e.g. https://play.crystal-lang.org/#/r/1gz
<wuehlmaus> take isn't that easy to google or even to find in CHANGELOG.md
<wuehlmaus> s/to/to find/
<FromGitter> <straight-shoota> fifth grep result
<wuehlmaus> ah take
<wuehlmaus> is now first?
<wuehlmaus> i found it :)
<FromGitter> <straight-shoota> yes
Papierkorb has left #crystal-lang ["Konversation terminated!"]
<FromGitter> <sdogruyol> just curious, how do you guys usually mock / stub?
<FromGitter> <ryankshah> When using `@var : Type` in an abstract class, I get thrown this error: `instance variable ... was not initialized directly in all of the 'initialize' methods, rendering it nilable. Indirect initialization is not supported.`
<FromGitter> <ryankshah> How can I fix this?
<FromGitter> <ryankshah> Do I have to give it a default value first in the abstract class?
<FromGitter> <straight-shoota> you mean like this? https://carc.in/#/r/3th3
<FromGitter> <straight-shoota> There is an issue for that: #2827
<DeBot> https://github.com/crystal-lang/crystal/issues/2827 (Abstract classes shouldn't complain about initialization)
<FromGitter> <ryankshah> Ahhh so it's a bug?
<FromGitter> <ryankshah> I found that providing a default value `@var : Bool = false` got rid of the errors
<FromGitter> <ryankshah> Also
<FromGitter> <ryankshah> Something like this would make life so much easier when writing documentation
shalmezad has joined #crystal-lang
return0e has joined #crystal-lang
<FromGitter> <girng> hello friends im having problem with int64
<FromGitter> <girng> `property selected_characterid = Int64` gives me `instance variable '@selected_characterid' of Client must be Int64:Class, not Int64` what am i doing wrong???
<FromGitter> <girng> If i do `Int32` it works
<jokke> `property selected_characterid : Int64`
<FromGitter> <girng> what's difference between : Int64 and : Int32, when = Int32 works?
That_Guy_Anon has joined #crystal-lang
<FromGitter> <plainas> so when I output an object in a string context, which method gets called to render that string?
<FromGitter> <plainas> as in puts "#{moyobject}"
<FromGitter> <plainas> it differs from the output of to_s
That_Guy_Anon has quit [Ping timeout: 240 seconds]
<FromGitter> <ryankshah> I think it depends on the Object
Jenz has joined #crystal-lang
<Jenz> Although pointers are unsafe, and I don't get them (as I've never properly used them), I like them
<Jenz> They look cool
<FromGitter> <ryankshah> @plainas I think that some objects override `Object.to_s` to print out a specific format such as the example here https://carc.in/#/r/3thx
<FromGitter> <ryankshah> But if you look here with no override of `to_s` in a new class i create called `MyClass`, it prints as follows https://carc.in/#/r/3thy
<FromGitter> <ryankshah> I'm probably wrong, but this is how it works in my head - Correct me if I'm entirely wrong
duane has quit [Ping timeout: 255 seconds]
<Jenz> You override Object#to_s(io); docs say you shouldn't override #to_s
<Jenz> But you are right, you override Object#to_s(io) to get a specific format or to print whatever you wish really
<Jenz> Like this: https://carc.in/#/r/3ti3
<Jenz> (if you're still here @ryankshah)
<Jenz> (`puts` calls #to_s on object if its not a string)
<FromGitter> <ryankshah> Ahhh okay that makes sense thanks for clarifying Jenz
<FromGitter> <ryankshah> Also, how can I check if a `Set` contains an element?
<FromGitter> <ryankshah> or if not possible, check if an `Array` contains an element (or to be able to check index) using `Set.to_a`
<FromGitter> <plainas> I am using kemal... if I print a websocket object in a string context I get a short sthing like this:
<FromGitter> <ryankshah> Since `Set` implements `Enumerable` would the best way to do this be using `Set.count(item)` and checking if `count(item) == 0`?
<FromGitter> <plainas> <HTTP::WebSocket:0x55a0e2694d00>
<FromGitter> <plainas> but If I print websocketobj.to_s, I get a huge dump with the buffers and whatnot
<FromGitter> <ryankshah> so parse the dump?
<FromGitter> <plainas> oh well, the question is not about a working solution, I am just trying to understand what's happening
<FromGitter> <ryankshah> Join the Kemal gitter
<FromGitter> <ryankshah> https://gitter.im/sdogruyol/kemal
<FromGitter> <ryankshah> Probably your best shot buddy :)
<FromGitter> <plainas> I usually hang out there as well
<FromGitter> <plainas> in fact more than here :D
<FromGitter> <ryankshah> Probably the better option then :D
<FromGitter> <plainas> But this is not kemal specific. HTTP::websocket is from the standard api
<FromGitter> <ryankshah> Oh right I thought you were implementing the web socket from kemal my bad
<FromGitter> <plainas> So the question that remains is how could ```puts #{myObject}``` possibly differ from puts myObject.to_s ?
<FromGitter> <ryankshah> That question was already answered
<FromGitter> <ryankshah> Right?
<FromGitter> <plainas> Jens touched it, but I don't know what "a specific" format refers to nor how to trigger it or control it
<FromGitter> <ryankshah> Well how about this
duane has joined #crystal-lang
<FromGitter> <ryankshah> Using this syntax everything between the opening #{ and closing } bits is evaluated as Crystal code, and the result of this evaluation will be embedded into the string surrounding it.
<FromGitter> <ryankshah> So `#{myObject}` will evaluate `myObject` and returns the value of `myObject` into the string
<FromGitter> <plainas> suposedly by calling .to_s on it... no?
<FromGitter> <ryankshah> Not necessarily
<FromGitter> <ryankshah> It is whatever the variable evaluates to
<FromGitter> <ryankshah> for example
<FromGitter> <ryankshah> ```s = "Hello World!" ⏎ puts "I said, #{s}"``` [https://gitter.im/crystal-lang/crystal?at=5ac4d6f5109bb04332890535]
<FromGitter> <ryankshah> This outputs `"I said, Hello World!"`
<FromGitter> <plainas> well, but .to_s of a string is the string itself. Could you show an example class where the above to snippets result in distinct output?
<FromGitter> <ryankshah> But.. using this example
<FromGitter> <ryankshah> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ac4d763c574b1aa3e675442]
<FromGitter> <ryankshah> Outputs `I said, #<MyClass:0x559b64a0ff00>`
<FromGitter> <plainas> what does puts c.to_s outputs?
<FromGitter> <ryankshah> The same thing
<FromGitter> <ryankshah> I think there is no difference unless `.to_s(io : IO)` is overriden
<FromGitter> <ryankshah> so much for all that
<FromGitter> <plainas> is that not what gets called on .to_s?
<FromGitter> <ryankshah> Take a read of this
<FromGitter> <ryankshah> It's to do with ruby but might give a clearer understanding
hightower2 has joined #crystal-lang
<FromGitter> <ryankshah> According to https://gist.github.com/virajkulkarni14/8770075 - `print`, `puts` and string interpolation(`#{}` syntax) use `to_s`
<FromGitter> <ryankshah> Although its ruby its kind of a similar concept
<FromGitter> <plainas> does that hold in crystal?
<FromGitter> <ryankshah> @straight-shoota mind helping?
<FromGitter> <straight-shoota> I didn't catch the original question...
<FromGitter> <straight-shoota> `to_s` in Crystal is similar to Ruby
hightower3 has quit [Ping timeout: 240 seconds]
<FromGitter> <straight-shoota> `to_str` is not implemented in Crystal stdlib
<FromGitter> <r00ster91> uh when I generate my docs with `crystal docs` and I for example have something like this in my shard: ⏎ ⏎ ```module MyShardName ⏎ module SomeModule ⏎ end ⏎ end``` ⏎ ⏎ then `crystal docs` will also generate a new folder "MyShardName" inside the docs folder. ... [https://gitter.im/crystal-lang/crystal?at=5ac4d980e3d0b1ff2c9ec212]
<FromGitter> <r00ster91> so it looks like theres an index.html missing. Why is crystal docs not generating this?
<FromGitter> <plainas> @straight-shoota so I am using kemal, and I am trying to print debug info of my websockets...
<FromGitter> <ryankshah> @straight-shoota he's trying to differentiate between `#{}` and `to_s`
<FromGitter> <plainas> in some places I get a short string reprensentation... in others I get a huge dump with all the attributes, includding low level stuff
<FromGitter> <ryankshah> @r00ster91 try adding a commend above each module to generate some sort of text and try again
<FromGitter> <straight-shoota> @r00ster91 do you have a link?
<FromGitter> <r00ster91> wait I will try
<FromGitter> <straight-shoota> comment is not needed, every type will have a docs page unless it is explicitly flagged as `# :nodoc:`
<FromGitter> <plainas> in short.... how do I get a representation like this: ```#<HTTP::WebSocket:0x55f89b21e700>``` instead of the one that its like a whole page of text
<crystal-gh> [crystal] ysbaddaden pushed 1 new commit to master: https://git.io/vxMGO
<crystal-gh> crystal/master b5a3a65 Johannes Müller: Fix File.join with empty path component (#5915)
<FromGitter> <straight-shoota> @plainas There is a difference between `#to_s` which returns a string representation of an object and `#inspect` which is usually more detailed
<FromGitter> <ryankshah> @straight-shoota so does string interpolation invoke `#inspect`?
<FromGitter> <straight-shoota> `HTTP::WebSocket` uses the default implementations of `Reference` where `#to_s` returns the class name and object id and `#inspect` prints all instance variables
<FromGitter> <straight-shoota> no, interpolation uses `#to_s(io : IO)`
<FromGitter> <ryankshah> ^^
<FromGitter> <ryankshah> Makes sense now
<crystal-gh> [crystal] MakeNowJust opened pull request #5917: MatchData: correct sample code for duplicated named capture (master...fix/regex-match-data/named-cap-doc) https://git.io/vxMZq
<FromGitter> <plainas> mmm I think the reason why sometimes I am getting a short description is because those are in the onClose cases
<FromGitter> <plainas> probably the websocket object is emptied before?
poopBot has joined #crystal-lang
<FromGitter> <plainas> mmmmm apparently not
<poopBot> hi i am exploring stuff, want to learn some other languge , wanted something whit better productivity and better crossplatformnes then c# , so i started little Nim , googling found Crystal too so would like to know what are Pros/Cons
<FromGitter> <plainas> If we take this example: http://kemalcr.com/cookbook/websocket_chat/ those print tatements are short.... but try and print one from the sockets array, bam... a huge amount of output floods my terminal
Nik736 has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <bararchy> @straight-shoota and RX14 are you guys planning on addressing my proposal for single msqueue ?
<FromGitter> <plainas> poppBot (lol@name) I am a crystal begginer too, I found it offer more direct benifit through better practicality. You can read the manual in a couple of hours, then there are good libraries out there for most stuff, shards and the compiler are easy to use and there is kemalcr which I love. Another differenciating factor was Fibers.... Nim didn't have any easy way to do things concurrently without using many
<FromGitter> ... resources. so here I am
<FromGitter> <r00ster91> pros: ⏎ ⏎ 1) the language is really fast and efficient ⏎ 2) the syntax is from ruby. A really nice syntax. ⏎ 3) you can really easy bind C stuff to Crystal ... [https://gitter.im/crystal-lang/crystal?at=5ac4dd7d109bb04332892828]
<dom96> plainas: async await? :)
<FromGitter> <girng> plz help, i can't define int 64 in property
<FromGitter> <girng> but i can do int32
<FromGitter> <plainas> I dislike async await idiom. very much. Why can't languages just implement P() and V() normaly on green threads?
<dom96> Why do you dislike it?
<FromGitter> <plainas> two things: 1. puts functions into to distinct categories 2. doesn't provide an easy way to control (limit) how many things you want to do at once.
<FromGitter> <plainas> assigning concurrency details to a function, rather than programming your concurrency separately from your functions is not intuitive, just my opinion i guess.
<dom96> I would think that async await provides more control
<dom96> With green threads everything is done behind the scenes
<FromGitter> <girng> async await makes code look more synchronous with asynchronous ability right??
<FromGitter> <straight-shoota> @bararchy I'm not really into threading support
<dom96> you have no control over when your thread yields to the event loop
<FromGitter> <plainas> it's not about threads being green... or threading. Crystal channels can be used like a semaphore. I don' even know how I would to that with async await... I asked a few js people I work with and the answer is always: "why would you need to do that"
<dom96> Also, for something that adds extra complexity (concurrency) you do want two distinct categories of functions.
<FromGitter> <plainas> spawn() + aquire() and relead() it's all i need really. And its trivial to use.
<dom96> JS people heh
<dom96> Please don't mistake JS' async with Nim's
<FromGitter> <plainas> dom96. I disagree... *what* I want to do, does not depend on how I want to pararelize it
<FromGitter> <girng> please @straight-shoota can u help me
<poopBot> i really like sytax i just looked you page first time and reading code was almost like reading Engish , that ruby stuff is nice , duno how i newer saw it
<FromGitter> <straight-shoota> with what?
That_Guy_Anon has joined #crystal-lang
<dom96> plainas: Out of curiosity, what types of apps are you writing?
<FromGitter> <girng> @straight-shoota im using this code ` property selected_characterid = Int64 ` but it won't work, but if i do ` property selected_characterid = Int32` it does. if I use the `Int64` I get `of Client must be Int64:Class, not Int64`
<RX14> dom96, having control over when you threads yield is moot as soon as you gain parallelism
<FromGitter> <straight-shoota> @girng are you sure you want to assign a type to that property?
<FromGitter> <straight-shoota> you probably mean `property selected_characterid : Int64`?
<RX14> in JS, async/await has some benefit because you have 1 thread executing 1 event loop
<RX14> in crystal we'll have multiple threads - you inherently have no control over your execution timing
<dom96> RX14: Perhaps, I don't really get the argument of controlling how many things are happening at once with concurrency
<dom96> You only ever have one thing happening at a time
<RX14> in crystal you can spawn n times and you know only n things are happening at once
<FromGitter> <girng> @straight-shoota but, what is the difference between ` = Int32 ` and ` : Int64`? why does Int32 work but Int64 doens't (when using the `=` operator)??
<dom96> It's the same in Nim. 1 thread = 1 event loop. You can create more threads with more event loops.
<RX14> but thats not how crystal will work
<RX14> it'll be like go
<dom96> It's not like async await is performing parallelism
<FromGitter> <straight-shoota> I don't know why Int32 didn't raise any issue
<FromGitter> <straight-shoota> would need to seem some context for that
<RX14> dom96, fibers will move transparently between threads
<FromGitter> <straight-shoota> `=` assigns the right hand side value to the variable,
<RX14> the only point to async/await is being able to see which parts of code you can ignore locking in
<FromGitter> <plainas> I am not talking about lower level details... I am talking about for example, read from many huge files at once. In crystal is trivial to do that for 1000 files but make sure that only 10 are open at a given time
<RX14> if you can NEVER ignore locking
<RX14> then there's no point
<FromGitter> <straight-shoota> `:` restricts the type of value that can be assigned
<dom96> plainas: it's the same in Nim
<RX14> besides, you almost always want synchronous procedural code to be the default
<RX14> because it's what you're used to
<FromGitter> <plainas> Can you show me a snippet? I wanted to do this, turned to nim, couldn't find an easy way to dot, red crystal manual, had a working solution in the same day
<RX14> in async/await you force people to write code differently depending on if it supports asyncio or not
<RX14> in crystal it's automatic and it makes a huge difference
<RX14> no more having to choose between making your interface simple and making it high performance
<RX14> you can't "forget" to make anything async
<dom96> plainas: do you have an example in Crystal that I could translate? Might be easier than me coming up with some guessed example :)
<travis-ci> crystal-lang/crystal#b5a3a65 (master - Fix File.join with empty path component (#5915)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/362151131
<DeBot> https://github.com/crystal-lang/crystal/pull/5915 (Fix File.join with empty path component)
<RX14> dom96, in nim do you have both sync and async IO?
<dom96> RX14: yep
<RX14> see that's what I hate
<RX14> it makes everything a pain
<RX14> because you have two systems for the same thing
<dom96> Sure, the Go-style concurrency is pretty nice
<RX14> then suddenly you want to use a library in your HTTP server
<RX14> but it's not async
<RX14> so you're fucked
<FromGitter> <plainas> dom96, the example in the crystal docs is not too evolved, but the classic semaphore usage.
<dom96> RX14: You'll still have this problem when wrapping C libraries
<dom96> even in Crystal
<RX14> yeah
<RX14> but it's not common to wrap C libraries
<dom96> for Nim libraries everyone will write async code, because why not?
<RX14> and less common for them to do IO
<RX14> dom96, so why do you provide sync IO
<RX14> if everyone uses async why make the interface more complex with more options
<dom96> RX14: In case developers don't want the complexity associated with epoll and all the other crap
<FromGitter> <plainas> here's an example in python using gevent https://gist.github.com/pydong/8106272
<dom96> Plus I solve the code duplication issue rather nicely with a multisync macro
<FromGitter> <plainas> worker1(), you can throw anything you want where that sleep(0) is
<RX14> dom96, or just solve it at the root with evented CSP :P
<RX14> nothing else makes sense to me
<FromGitter> <girng> @straight-shoota big misunderstanding, i got my = and : mixed up. thank you
<RX14> as nodejs has shown - evented IO has a far more significant effect on performance than runtime speed itself
<FromGitter> <plainas> Frankly I never understood why would anyone want anything else than P() and V() idiom as defined by Dijskstra.
<RX14> making it easy to use that evented IO is what will make your language fast in the real world
<RX14> with real people who don't want to think about event loops
<FromGitter> <plainas> I totally agree.
<dom96> To be honest I also wonder this :P
<RX14> as soon as you make evented IO harder than normal IO - and provide the option to use sync IO - someone will get lazy and use it and your performance is down the drain
<RX14> and you'll waste time debugging it
<dom96> I still love my async await implementation though
<FromGitter> <plainas> you want to be able to throw your IO to the background. But the webserver case was trivial, because you paralelize everything, what If I want to process 10.000 files, I want control over how many I want open at a given time. Not just open as many as possible. It will crash
<dom96> And it's encouraging to see Rust going the same way
<RX14> rust has to do it that way because of not having a runtime
<RX14> as soon as you allow yourself a runtime then CSP is far better
<RX14> i'm actually pretty sad rust is adding async/await
<dom96> FWIW it's trivial to create sync and async code in Nim without any code duplication
<dom96> You just mark your proc with {.multisync.}
<RX14> that's nice but I still think async/await and multisync are a hack around getting the core of the colution wrong
<RX14> and as we've discussed there's still some problems
heaven31415 has joined #crystal-lang
qard has joined #crystal-lang
<FromGitter> <girng> can i ask a question about multiple processes
<poopBot> i allow you
<poopBot> ask
<heaven31415> hi
<FromGitter> <girng> for example,in nodejs people sometimes run multiple nodejs "instances" that interact with redis or something to horizontally scale. the same thing can be done with crystal, right?
<RX14> yes
<FromGitter> <girng> cool =], tyhx
duane has quit [Ping timeout: 260 seconds]
duane has joined #crystal-lang
<FromGitter> <girng> where can i find benchmarks comparing crystal to nodejs?
<FromGitter> <ryankshah> This might be helpful
<FromGitter> <girng> @ryankshah cool, which one would be the most fairest / real?
<FromGitter> <ryankshah> Depends what you need to be fair
<FromGitter> <girng> somemthing useful in game dev world maybe
<FromGitter> <girng> networking test?
<FromGitter> <ryankshah> hmm
<FromGitter> <ryankshah> do a quick google
<FromGitter> <ryankshah> or do your own benchmark
alex`` has quit [Ping timeout: 276 seconds]
<FromGitter> <girng> i'm too newb and will prob create a bad benchmark :(
<FromGitter> <ezrast> Spoiler alert, most benchmarks are bad
<FromGitter> <ezrast> At least if "good" means "relevant to the work you are actually doing"
<FromGitter> <ezrast> what are you actually trying to prove?
<FromGitter> <ryankshah> I agree with @ezrast
<FromGitter> <ryankshah> I would only take them with a pinch of salt to get approximations towards what you want to achieve
<FromGitter> <girng> what do you mean what am i trying to prove
<FromGitter> <ezrast> what decision are you trying to use a benchmark to inform?
<FromGitter> <ezrast> why do you care how Crystal compares to Node at X task?
<FromGitter> <girng> @ezrast got it, well, i was just trying how big the performance difference is compared to nodejs and crystal for game dev stuff
<FromGitter> <girng> in, like networking maybe
tilpner has quit [Remote host closed the connection]
tilpner has joined #crystal-lang
shalmezad has quit [Quit: This computer has gone to sleep]
tilpner_ has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tilpner has quit [Ping timeout: 240 seconds]
tilpner_ is now known as tilpner
shalmezad has joined #crystal-lang
Jenz has quit [Ping timeout: 268 seconds]
<heaven31415> Where can I find the definition of epsilon for float32 in Crystal? By epsilon I mean: the difference between 1 and the least value greater than 1 that is representable in the given floating point type
duane has quit [Ping timeout: 260 seconds]
qard has joined #crystal-lang
duane has joined #crystal-lang
alex`` has joined #crystal-lang
Jenz has joined #crystal-lang
greengriminal has joined #crystal-lang
Jenz has quit [Quit: leaving]
<RX14> probably isn't one
<RX14> yeah nah
<RX14> you'll have to define it yourself
<RX14> you should open an issue
heaven31415 has quit [Ping timeout: 276 seconds]
heaven31415 has joined #crystal-lang
<FromGitter> <straight-shoota> I can't think straight... can this expression be simplified? `((i - (i > 0 ? 1 : 0)) / 3) * 3` ⏎ https://carc.in/#/r/3tjq
<FromGitter> <straight-shoota> results should be like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ac50abc270d7d370891fd01]
<FromGitter> <straight-shoota> I don't care about the value for 0, it can be undefined
That_Guy_Anon has quit [Remote host closed the connection]
<crystal-gh> [crystal] paulcsmith opened pull request #5918: Small typo fix in bash completion (master...patch-1) https://git.io/vxMy9
Jenz has joined #crystal-lang
Jenz has quit [Client Quit]
Jenz has joined #crystal-lang
<heaven31415> can I use uninitialized keyword for instance variables in constructor?
<Jenz> Yes
<Jenz> I think so at least...
<Jenz> Lemme double check
<heaven31415> Well I already tested code with it
<heaven31415> however was surprised to see that those variables were initialized to zero
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
<Jenz> What type were they?
<heaven31415> Float32
<Jenz> If they were ints, an uninitialized int has the value of zero
<Jenz> Not so sure about floats though
greengriminal has quit [Client Quit]
<Jenz> Could be same thing
<Jenz> Must be
<heaven31415> I think you are right
<heaven31415> maybe is it handled differenly for types not inheriting from value
<Jenz> But I don't see any point in uninitializing floats, initially just declaring them as zero is much easier than typing 'uninitialized'
<Jenz> unitialized floats*
<Jenz> I think the point about uninitialized is that they are not handled at all
<heaven31415> Well I'm porting some C++ code and it had uninitialized floats for performance reasons
<FromGitter> <straight-shoota> an uninitialized variable has whatever value is at that memory position
<Jenz> But im just a noob, RX14 isthe expert
<Jenz> Yes and memory positions are 0 by default
<RX14> don't use uninitialized
<RX14> just don't
<RX14> ever
<RX14> you won't notice the performance, ever
<Jenz> You're quite some low-level opposer :D
<Jenz> You're pretty much required to use it in some c binding situations though
<RX14> yes because most of the time it's a premature optimization that'll cause you security bugs
<RX14> yeah
<RX14> uninitialized is there for C bindings and for people who have actually benchmarked the code and can tell me exactly HOW MUCH faster uninitialized is than without
<RX14> most of the time people use it to shoot themselves in the foot
<RX14> so please, don't do it
<Jenz> You're not able to bind to things declared in c with `define` are you? I say 'things' because I've no idea what its called
<RX14> you mean macros?
<heaven31415> I promise I won't shoot myself in the foot
<RX14> #define?
<Jenz> Yes
<RX14> heaven31415, you will, don't use it
<heaven31415> I meant that I won't use uninit
<RX14> nice
<RX14> 90% of the time LLVM will just optimise it to the same code with or without uninitialized either way
<heaven31415> and what about those 10% XD?
<RX14> either using it as an ivar
<RX14> or complex situations where llvm can't prove you didn't use the memory before it was initialized
<RX14> and half of the latter is because of bugs
<Jenz> Sounds problematic
<RX14> not really
<RX14> all you're doing is eliding a memset if you're using uninitialized on scalars
<RX14> s/eliding/removing
<RX14> and most of the time llvm will elide that memset and remove it in release mode
<Jenz> elide?
<RX14> Jenz, elide means the compiler will remove it because it can prove it's unneccesary
<Jenz> Ok, i see
<heaven31415> RX14
<Jenz> And the answer to binding to macros was no?
<heaven31415> I would like to ask about inlining, if I'm porting some code to Crystal from C++ and I see inlining suggestion in C++ code, should I also use always inline attribute in Crystal code?
<Jenz> (c macros)
<RX14> heaven31415, @[AlwaysInline]
greengriminal has joined #crystal-lang
<heaven31415> so, it will be different from cpp inline
<FromGitter> <ryankshah> @RX14 technically you used elide in the wrong context, it only refers to omission when speaking otherwise it refers to joining/merging something
<FromGitter> <ryankshah> But we're programmers, who gives a crap
<Jenz> Google says otherwise 'omit (a sound or syllable) when speaking,' I mean, speaking, compiling, same shit
<FromGitter> <ryankshah> Jenz, that refers to a sound or syllable from a word or phrase, i.e. the consonant 'k' is elided from 'knight'
<Jenz> Oh, really? /s
<FromGitter> <ryankshah> Yeah 😆
heaven31415 has quit [Ping timeout: 260 seconds]
<RX14> @ryankshah but everyone uses elide to mean the removal of something in a compiler
<FromGitter> <ryankshah> Ahhh okay that's fair then :)
<FromGitter> <ryankshah> It's not a very common word hence my misconception of its use in compiler vocabulary
<Jenz> Would it be irrational to make it possible to bind to c macros?
heaven31415 has joined #crystal-lang
heaven31415 has quit [Client Quit]
<FromGitter> <straight-shoota> C macros only exist in the C source but not in the compiled library
<FromGitter> <straight-shoota> you need to translate to Crystal
<Jenz> Oh ok, thanks, im a noob in c as well
havenwood has joined #crystal-lang
<havenwood> Someone should change the title links to https since they all support it. :-)
<havenwood> I just wrote a tiny little git subcommand for pretty-printing the latest git shasum. I'd love to improve it if anyone has any comments. Thanks! https://gist.github.com/havenwood/1fc7eae317f8be8077156768191c0789
<FromGitter> <bew> havenwood I'm sure git can do that for you already, with conflict handling for big repository (your tool doesn't handle that)
<FromGitter> <bew> `git rev-parse --short HEAD`
<crystal-gh> [crystal] ysbaddaden closed pull request #5918: Small typo fix in bash completion (master...patch-1) https://git.io/vxMy9
<crystal-gh> [crystal] ysbaddaden closed pull request #5917: MatchData: correct sample code for duplicated named capture (master...fix/regex-match-data/named-cap-doc) https://git.io/vxMZq
<FromGitter> <ryankshah> @bew It does run `git rev-parse` though
<travis-ci> crystal-lang/crystal#011e688 (master - Small typo fix in bash completion): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/362296703
<travis-ci> crystal-lang/crystal#106d44d (master - MatchData: correct sample code for duplicated named capture): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/362296995
<FromGitter> <bew> Yes, but his short form has 7 digits, which might not always be enough
poopBot has quit [Remote host closed the connection]
<oprypin> git rev-parse --short HEAD is better, and i have it set to more digits :)
<oprypin> core.abbrev=9
<havenwood> oprypin: ah, nice
<oprypin> what @bew is trying to say is that it automatically adds more digits if it's necessary
<havenwood> aha, interesting
Jenz has quit [Ping timeout: 265 seconds]
<FromGitter> <bew> Yes, ty for clarifying :)
heaven31415 has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<heaven31415> hello
shalmezad has quit [Quit: Timezones are the bane of my existence.]
duane has quit [Ping timeout: 276 seconds]
qard has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
<FromGitter> <ryankshah> I have a class that I created, which I thought would inherit from Object. I tried calling `#clone` from my class object i created and it says it is undefined
<FromGitter> <ryankshah> Do I have to do `MyClass < Object`?
<FromGitter> <straight-shoota> no
<FromGitter> <straight-shoota> `Object#clone` is not defined
<FromGitter> <bew> Checkout `def_clone`
<FromGitter> <straight-shoota> you're probably looking for `Object#dup`
<FromGitter> <ryankshah> I thought `#dup` points to the same memory reference and doesnt actually create a new object?
<FromGitter> <bew> FWIW, def_clone a macro to easily create the clone method
<FromGitter> <ryankshah> @straight-shoota cheers!
<FromGitter> <straight-shoota> if you assign an object to a variable, it points to the same memory reference, but `#dup` creates a copy
<FromGitter> <ryankshah> Okay thanks for the clarification, also is it possible to have multiple `initialize` methods for overloading?
<FromGitter> <straight-shoota> sure
<FromGitter> <ryankshah> cool 👍
return0e has quit []
heaven31415 has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
greengriminal has quit [Quit: This computer has gone to sleep]
<havenwood> bew: oprypin: Thank you both! I was trying to find a nice example git command but I may have just jumped the shark here.
<havenwood> I tried to salvage my attempt by using the abbrev size for color: https://gist.github.com/havenwood/1fc7eae317f8be8077156768191c0789
<FromGitter> <bew> I think you'd better change the `Process.run` call whether short is given or not, instead of doing it yourself
<FromGitter> <bew> Or for your example, call it twice, once to get the full hash, another one to get the short hash
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has joined #crystal-lang
return0e has joined #crystal-lang
heaven31415 has joined #crystal-lang
return0e has quit [Ping timeout: 268 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
heaven31415 has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
greengriminal has quit [Quit: Leaving]
qard has joined #crystal-lang