RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.0 | 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
<Papierkorb> If one's careful that thing doesn't even crash. Nice :P
<FromGitter> <fridgerator> lol
<FromGitter> <fridgerator> well I just released crecto v0.4.0, which includes Multi / Transactions
<Papierkorb> fridgerator, neat!
fazibear has quit [Ping timeout: 240 seconds]
go|dfish has quit [Quit: SIGQUIT]
go|dfish has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
triangles has quit [Quit: Leaving]
<sija> is there any way to install global exception handler?
<sija> (other than redefining `raise` which feels hack-ish)
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
Raimondi has quit [Ping timeout: 268 seconds]
pawnbox has joined #crystal-lang
<FromGitter> <schoening> @sija what are you working on, doesn't dependency injection work for your usecase?
<Yxhuvud> sija: wrap the file you compile with begin .. rescue ..end?
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
marciogm has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
akwiatkowski has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
bjz has joined #crystal-lang
Raimondi has joined #crystal-lang
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
mark_66 has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
bjz has quit [Ping timeout: 240 seconds]
akwiatkowski has quit [Ping timeout: 260 seconds]
elia has joined #crystal-lang
bjz has joined #crystal-lang
unshadow has joined #crystal-lang
<unshadow> How can I buffer a socket read ? lets say i got this: buffer_a=Bytes(10).new; socket.read(buffer_a_); now I want to move the data I got in the buffer to the "whole" package and buffer more data
fazibear has joined #crystal-lang
<unshadow> Maybe I can ask it better, how can I join two or more Slice(UInt8) objects ?
fazibear has quit [Ping timeout: 268 seconds]
pawnbox has joined #crystal-lang
fazibear has joined #crystal-lang
Raimondii has joined #crystal-lang
fazibear has quit [Ping timeout: 240 seconds]
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
fazibear has joined #crystal-lang
elia has quit [Quit: (IRC Client: textualapp.com)]
gloscombe has joined #crystal-lang
fazibear has quit [Ping timeout: 260 seconds]
fazibear has joined #crystal-lang
A124 has joined #crystal-lang
fazibear has quit [Quit: leaving]
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
akwiatkowski has joined #crystal-lang
sz0 has joined #crystal-lang
fazibear has joined #crystal-lang
<RX14> unshadow, well first of all IOs tend to be buffered and peakable by default now
<RX14> second you want to look at copy_from and move_from
fazibear has quit [Quit: leaving]
fedruantine has quit [Ping timeout: 240 seconds]
fazibear has joined #crystal-lang
fazibear has left #crystal-lang [#crystal-lang]
kubaxvx has quit [Ping timeout: 260 seconds]
<unshadow> Thanks RX14
fedruantine has joined #crystal-lang
fazibear has joined #crystal-lang
kubaxvx has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
fazibear has quit [Client Quit]
fazibear has joined #crystal-lang
<RX14> unshadow, typically you'd create one "large" slice then reuse that slice for moving bits of data around in it
<RX14> it can get quite complex though
<RX14> as IO#read doesn't have to return the number of bytes you ask for
fazibear has quit [Client Quit]
fazibear has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
<RX14> we do have IO#read_fully though
fazibear has quit [Client Quit]
fazibear has joined #crystal-lang
<unshadow> Well, What I want to achive is something like this: https://play.crystal-lang.org/#/r/1odu (Total pseudo code)
<RX14> what is big_packet
<RX14> and why don't you read it with 1 read call
<RX14> what's the end condition?
<unshadow> because the IO is non_blocking which means that Maybe I'll need more then one read
<RX14> yeah thats what read_fully is for
<RX14> if you know the exact amount of data you want
<unshadow> but then it's blocking :)
<RX14> what?
<unshadow> I want a non_blocking buffer loop
<RX14> what do you mean by "non_blocking"
<RX14> what other work do you need to do
<RX14> and why can't it be done in a fiber
<unshadow> It can, my issue is that read_fully is blocking , I want to use non_blocking IO, but, non_blocking IO might return imidetally without reading X bytes, and this is why I want it to loop again to see if there is more data to be read
<RX14> non_blocking = true/false has NO affect on the semantics of IO#read
<RX14> they only affect the scheduler and how IO is handled internally
<RX14> IO#read will block either way (but it can return only 1 byte)
Qchmqs has joined #crystal-lang
<RX14> IO#read_fully will block but will read as much as possible
<RX14> it will always return the amount of data you ask for
<RX14> UNLESS you reach EOF
<unshadow> A question then, socket has 50 redable bytes. if I use socket.read_fully(100), will that return with 50 bytes read or get stuck waiting for 50 more ?
<RX14> it'll block
<RX14> you're meant to block
fazibear has quit [Quit: leaving]
<RX14> if you only had 50 bytes but you wanted 100, could you do anything with those 50 bytes?
<RX14> if no, you definitely want read_fully
<unshadow> yes, it will block, but, read, wont block. lets say I would have called buff = Slice(100).new; socket.read(slice), it will return imidiatly with 50 bytes out of the 100 filled with the new data
<RX14> it's about whether you want data as soon as possible (usually because you don't know how much data you want, so you're waiting for a byte sequence)
fazibear has joined #crystal-lang
<RX14> or whether you know exactly how much data you want to the byte, and just want a single method to get all of that data
<unshadow> Yes, I don't know how much data is going to come in, but, I want also to make sure I read everything avilable (EOF), this is why a loop around read is what I want
<unshadow> does it make sense ? or am I'm looking at it wrong ?
<RX14> it doesn't make sense to me
<RX14> the problem with "reading until the end" into a slice is you don't know how big the data is
<RX14> so you could just get stuck in a loop of allocating larger slices
<RX14> untiul you run out of ram
<RX14> what, more generally, are you trying to do unshadow
<unshadow> I'm doing a proxy, TCP proxy between two machines, as I dont know the protocol (tcp level) I just want to read from a and pass to b, read from b and pass back to a.
<RX14> ok, so you don't know how much you want to read
<unshadow> exactly
<unshadow> but I want to make sure machine b got all it needed from a
<RX14> isn't that as simple as read into slice, write (valid part of) slice to another IO
<RX14> repeat in loop
<RX14> so... IO.copy
<RX14> in 2 fibers
<RX14> one for each direction
<unshadow> fiber1: IO.copy(machine_a, machine_b); fiber2: IO.copy(machine_b, machine_a) ?
<unshadow> something like that ?
<RX14> yup
<unshadow> will that "break" on EOF ?
pawnbox has joined #crystal-lang
fazibear has quit [Quit: leaving]
<unshadow> Cool, Thanks RX14 , that helped alot :)
<RX14> no problem
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
splitty_ has quit [Quit: Leaving]
splitty_ has joined #crystal-lang
fazibear has joined #crystal-lang
unshadow has quit [Quit: leaving]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 268 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<literal> so, with 0.21 it seems to always compile as if I'd supplied --debug: https://gist.github.com/hinrik/2dd1d467eecf5eedc75b78ecef260d82
Ven has joined #crystal-lang
<RX14> literal, yup
<RX14> thats the new default
<RX14> oh
<RX14> uhh
<RX14> yeah
<RX14> oh
<RX14> hmm
<RX14> is that flag defined at all?
<RX14> because if not it's probably just defined as being "when emitting debug information
pawnbox has joined #crystal-lang
pawnbox has joined #crystal-lang
<literal> it must be, since if I change this to flag?(:foobar) it prints nothing
<RX14> it's just because --debug is the default now
<RX14> it's just emitting debug info in the binary by default
<RX14> it's not a "generic" debug option
<Papierkorb> literal: try it with --no-debug
<Papierkorb> literal: Instead of testing :debug, test :release like benchmark does it: https://github.com/crystal-lang/crystal/blob/c2c2276ec667171af5c2347490f49acdbdc4a3ca/src/benchmark.cr#L85
<literal> alright
<RX14> --debug isn't the opposite of release
<RX14> they're unrelated
<literal> fair enough
<Papierkorb> they are, but it can be confused easily, and don't think it's really documented either. e.g. in gcc, they're the same iirc
<Papierkorb> err, same as in release = !debug
mark_66 has quit [Remote host closed the connection]
soveran has quit [Remote host closed the connection]
Qchmqs has quit [Ping timeout: 260 seconds]
akwiatkowski has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven 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
akwiatkowski has joined #crystal-lang
<FromGitter> <yxhuvud> Do release do anything else but turn on optimization?
Ven has quit [Ping timeout: 255 seconds]
<Papierkorb> not really
Ven has joined #crystal-lang
AckZ has quit []
zaiste has joined #crystal-lang
Svenskunganka has joined #crystal-lang
Svenskunganka has quit [Client Quit]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
zaiste has quit [Ping timeout: 260 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Ven has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
gloscombe has quit [Quit: Lost terminal]
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 260 seconds]
<FromGitter> <sdogruyol> how can generate pretty API docs for a Crystal project
<RX14> `crystal doc` :P
<FromGitter> <sdogruyol> crystal doc seems not to like top level namespaces in Kemal :(
<RX14> thats why you put the stuff in a module
<RX14> and include it in the top level
<FromGitter> <sdogruyol> hmm
<RX14> ??
<FromGitter> <sdogruyol> i mean this should produce some doc in Kemal module right?
<RX14> it should...
<FromGitter> <sdogruyol> yet i see only top level namespace
<RX14> well thats a bug
<FromGitter> <sdogruyol> now i am sad
Ven has joined #crystal-lang
Ven_ has joined #crystal-lang
<sija> @Yxhuvud @schoening I'm working on a sentry.io client which would love to have an entrypoint for uncaught exceptions :)
<sija> is it possible to rescue exceptions thrown in macro code?
<sija> like failed `system` call?
Ven has quit [Ping timeout: 240 seconds]
<FromGitter> <schoening> @sdogruyol https://youtu.be/xhy7dXWjpAA
<RX14> sija, why not just provide a block for people to wrap their code with?
<RX14> i wouldn't want to turn it on for everything by default
<RX14> stuff should be explicit, not magic
<FromGitter> <Sija> i know, still i like magic too ;)
<FromGitter> <schoening> @Sija very, very nice. I'm intrigued.
<FromGitter> <Sija> `Raven.capture { … }` is easy (and already done), I was looking for that extra magic spice
<RX14> i'd siggest a HTTP handler wrapper thingy
<FromGitter> <Sija> TBD for sure
<sija> any1 knows how to tame macro `system` to not throw exceptions in case of failure?
<Papierkorb> Make it never fail. What do you need it for?
<sija> i'd need `git rev-parse --short HEAD` which might fail
<Papierkorb> add `|| true`
<sija> ain't help, still errors out
<Papierkorb> Should work fine: `p {{ system("ls /root || true").stringify }}`
<Papierkorb> ls still writes to stderr (which of course you can suppress), but the program then prints an empty string
<sija> oh, i misunderstood you're intention, that works indeed, thx! :)
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
Ven has joined #crystal-lang
<sija> there's just global exception handler i'm missing now
zaiste has joined #crystal-lang
zaiste has quit [Ping timeout: 252 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
fazibear has quit [Ping timeout: 260 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ishahnaz has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
ishahnaz has quit []
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
akwiatkowski has quit [Ping timeout: 260 seconds]