jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.14.1 | Fund Crystals 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
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
Philpax has joined #crystal-lang
onionhammer1 has quit [Read error: Connection reset by peer]
onionhammer1 has joined #crystal-lang
ragmaanir__ has joined #crystal-lang
ragmaanir_ has quit [Ping timeout: 240 seconds]
trapped has quit [Read error: Connection reset by peer]
<crystal-gh> [crystal] DougEverly opened pull request #2375: Added Process.daemonize, spec, and samples (master...daemonize2) https://git.io/vVfLS
<crystal-gh> [crystal] DougEverly closed pull request #2363: Added Process.daemonize (master...daemonize) https://git.io/vaxHy
ytti has joined #crystal-lang
ytti has quit [Ping timeout: 240 seconds]
ytti has joined #crystal-lang
ytti has quit [*.net *.split]
ytti has joined #crystal-lang
ytti has quit [Ping timeout: 240 seconds]
ytti has joined #crystal-lang
ytti has quit [Ping timeout: 240 seconds]
ytti has joined #crystal-lang
ytti has joined #crystal-lang
ytti has quit [Ping timeout: 240 seconds]
ytti has quit [*.net *.split]
kfpratt has joined #crystal-lang
kfpratt has quit [Remote host closed the connection]
ytti has joined #crystal-lang
ytti has quit [*.net *.split]
buggs has quit [Quit: WeeChat 0.4.2]
ytti has joined #crystal-lang
ragmaanir__ has quit [Quit: Leaving]
ytti has quit [Ping timeout: 240 seconds]
kfpratt has joined #crystal-lang
ytti has joined #crystal-lang
ytti has quit [*.net *.split]
ytti has joined #crystal-lang
ytti has quit [Ping timeout: 240 seconds]
ytti has joined #crystal-lang
pawnbox has joined #crystal-lang
zeno_ has quit [Remote host closed the connection]
zeno_ has joined #crystal-lang
ytti has quit [Ping timeout: 240 seconds]
kfpratt has quit [Remote host closed the connection]
zeno_ has quit [Client Quit]
pawnbox has quit [Ping timeout: 264 seconds]
zeno_ has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
ytti has joined #crystal-lang
ytti has quit [*.net *.split]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
ytti has joined #crystal-lang
ytti has quit [Ping timeout: 240 seconds]
ytti has joined #crystal-lang
ytti has quit [*.net *.split]
ytti has joined #crystal-lang
ytti has quit [Ping timeout: 240 seconds]
ytti has joined #crystal-lang
ytti has quit [Ping timeout: 240 seconds]
ytti has joined #crystal-lang
ytti has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
pawnbox has joined #crystal-lang
ytti has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
ytti has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
ytti has joined #crystal-lang
ozra has joined #crystal-lang
ytti has quit [*.net *.split]
hangyas has joined #crystal-lang
<hangyas> has anybody else trouble with the summer daylight saving time?
ytti has joined #crystal-lang
ytti has quit [*.net *.split]
edjsu has quit [Quit: WeeChat 1.2]
edjsu has joined #crystal-lang
hangyas has quit [Quit: hangyas]
hangyas has joined #crystal-lang
hangyas has quit [Ping timeout: 246 seconds]
<BlaXpirit> trouble waking up?
bjz_ has joined #crystal-lang
Ven has joined #crystal-lang
bjz has quit [Ping timeout: 246 seconds]
trapped has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
zeno_ has quit [Quit: 离开]
Rinkana has joined #crystal-lang
Philpax has quit [Ping timeout: 244 seconds]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RX14> Is there a promise library for crystal yet?
ozra has quit [Ping timeout: 276 seconds]
Ven has joined #crystal-lang
bjz_ has quit [Ping timeout: 244 seconds]
bjz has joined #crystal-lang
dome22xl has joined #crystal-lang
Ven has quit [Client Quit]
marcosdsanchez has quit [Ping timeout: 264 seconds]
marcosdsanchez has joined #crystal-lang
Ven has joined #crystal-lang
dome22xl has quit [Read error: Connection reset by peer]
pawnbox has quit [Remote host closed the connection]
Ven has quit [Client Quit]
pawnbox has joined #crystal-lang
hangyas has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
<RX14> BlaXpirit, why did you implement the network module in crsfml?
zeno_ has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
bjz_ has joined #crystal-lang
<BlaXpirit> RX14, cuz why not
<BlaXpirit> i'm sure it has some features that crystal doesnt
<RX14> ehh
<RX14> maybe
<RX14> I sure wouldn't use them
Philpax has joined #crystal-lang
pawnbox has joined #crystal-lang
<Rinkana> Can a crystal file return an array? Like that you can call something like File.read and it returns an array of objects?
<RX14> a crystal file?
<BlaXpirit> Rinkana, maybe you're looking for json
<BlaXpirit> or maybe just a `require`
<RX14> oh, you want to
<RX14> use the crystal file module
<RX14> to open multiple files at once?
<RX14> you want to make an array of the filenames then use .map to map them to their contents
<RX14> ["file", "file2"].map { |f| File.read f }
<Rinkana> No, i want to define an array of objects within that file. And the only use of that file is for that array. And when i open that file i get the array.
<Rinkana> Let me create a snippet of what i want to achive
<RX14> like the nodejs require system? where you require a file and it retuns an object?
pawnbox has quit [Ping timeout: 244 seconds]
<RX14> just have the file define a single method
<RX14> that returns it
<RX14> or a constant
<RX14> or use JSON
<RX14> if it's static
<RX14> just make the file define a constant
<RX14> it's the best way
matp has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Rinkana> RX14 thanks, that was indeed the only thing needed
Ven has joined #crystal-lang
pawnbox has joined #crystal-lang
matp has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
bjz_ has quit [Ping timeout: 244 seconds]
bjz has joined #crystal-lang
A124 has quit [Ping timeout: 240 seconds]
splattael has joined #crystal-lang
ragmaanir has joined #crystal-lang
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
zeno_ has quit [Remote host closed the connection]
tony_ has joined #crystal-lang
matp has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 252 seconds]
matp has joined #crystal-lang
marcosdsanchez has quit [Read error: Connection reset by peer]
marcosdsanchez has joined #crystal-lang
tony_ has quit [Ping timeout: 264 seconds]
Philpax has quit [Ping timeout: 246 seconds]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tony_ has joined #crystal-lang
hangyas has quit [Remote host closed the connection]
hangyas has joined #crystal-lang
tony_ has quit [Ping timeout: 260 seconds]
ozra has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
splattael has quit [Quit: Connection closed for inactivity]
mgarciaisaia has quit [Quit: Leaving.]
bjz_ has quit [Ping timeout: 244 seconds]
krtv` has joined #crystal-lang
bjz has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
nstnst has joined #crystal-lang
<nstnst> hello everyone, was curious if anyone could help me out with some concurrency features of crystal. I was wondering if there's a technique for coordination between multiple fibers, kind of like golang's sync.WaitGroup or sync.Once. More details in this ticket: https://github.com/crystal-lang/crystal/issues/2366
<RX14> nstnst, waitgroup can be accomplised using the parallel macro
<nstnst> RX14: Thanks for the pointer! Looks like it might get close to what I want, but what if I have two fibers and I want to know which one finishes first? Looks like that parallel macro waits for all jobs to complete?
<RX14> yep it does
<RX14> you will probably have to rig it all together with channels
<RX14> you can see the concept
<RX14> that a fiber sends a "nil" as a marker down a channel when it completes
<RX14> if you only want one to finish, only recieve once on the channelk
<RX14> then kill the other fibers once you recieve that
<RX14> and if your fibers return a value - might as well return that value down the channel
<RX14> channels are the main way of communication between fibers
<RX14> and they work very well
<nstnst> cool, very go like
<RX14> there probably should be something in the standard library for this
<RX14> but it's early days
<nstnst> :) Totally, I would love to see it
<nstnst> another question: In other langs I might expect that channel receive / channel send to have a mutex around it. Why don't require it here? Is it how fibers are scheduled? (still learning crystal :))
<nstnst> mutex lock *
<RX14> fibers only run on one core
<RX14> so you don't really need it at the moment
<RX14> it's like node, in that you have to run one crystal process per core
<RX14> that SHOULD change in the future though
<RX14> unlike node
<nstnst> word, is there a ticket for that change? would love to read more
<RX14> https://github.com/crystal-lang/crystal/issues/1698 this seems like the main one
<nstnst> Great, thanks!
<RX14> nodejs can get away with being single core because it's meant for servers
<RX14> crystal is designed to be more general purpose, so we should be able to schedule coroutines over multiple cores
<nstnst> RX14: one last thing if you don't mind: In my experiements, I've had some fibers that I expect to run for a long time, and would prefer that the short running fiber executes quickly and short-circuit the long-running one. I want to learn more about what garuntees I can make for this; is there more reading material on how the fibers are scheduled? I recall reading something about switching them after a certain timing threshol
<RX14> fibers are cooperatively scheduled
<RX14> fibers yield their own control
<nstnst> "A fiber must explicitly tell the Runtime Scheduler to switch to another fiber. For example if there's I/O to be wait, a fiber will tell the scheduler "Look, I have to wait for this I/O to be available, you continue executing other fibers and come back to me when that I/O is ready"."
<RX14> the trick is, that IO calls yield that control for you
<RX14> so, unless your fiber makes blocking calls it will run forever
<RX14> in go, fibers are scheduled on method calls
<RX14> or something like that
<RX14> so if you have a method with an infinite loop, it will never yield
pawnbox has quit [Remote host closed the connection]
<nstnst> RX14: What if I have a fiber that is simply waiting for a timeout to signal a short-circuit
pawnbox has joined #crystal-lang
<RX14> sleep reschedules the fiber too
<nstnst> RX14: Interesting; so when that sleep finishes, the fiber will be re-scheduled to be called again?
<RX14> yep
<nstnst> hmm cool, I'll give it another shot!
<nstnst> In short I was attempting to port this functionality: https://github.com/kellydunn/breaker/blob/master/breaker.go#L82-L124
<nstnst> in a nutshell, trying to coordinate between long running operation vs timeout: which one finishes first
<RX14> yeah i've seen timeouts done with fibers in the crystal stdlib
<RX14> i'll find an example
<RX14> hmmn
<RX14> ok I got no idea nstnst
<nstnst> RX14: all good, thanks for your help :) Excited to see the future of Crystal concurrency. Multi-core!
<RX14> looks like you can't force a fiber to resume
<RX14> oh actually
<RX14> you can
<RX14> so
<RX14> trick is
<RX14> you get a handle to the fiber you want to be able to time out
<RX14> then you wait the timeout, set a falg saying the timeout is hit and then resume the fiber manually
<RX14> then when you finish the blocking call, you should be able to check the flag and throw or whatever
<RX14> probably won't work for blocking IO but they all have timeouts anyway
<nstnst> cool! thanks!
dome22xl has joined #crystal-lang
<dome22xl> Hi All, is there anyway to append to a file in Crystal ?
<BlaXpirit> dome22xl, File.open( , mode: "a")
<RX14> nstnst, trouble is that IO calls should be more wrapped than slep calls so they will probably just reschedule themselves when they are resumed, so you can never manually resume them
<nstnst> RX14: Thanks! I think I'll play around with it a bit more :) Thanks again for all your help
<nstnst> RX14: gotcha; yeah it sounds like multi-core is what I'd be looking for
<nstnst> thanks again!
nstnst has quit [Quit: Page closed]
<dome22xl> @f = File.open("#{filename}", mode: "a"); @f.write("#{entry}")
<dome22xl> I'm getting not overload matches File#Write
<RX14> @f is nillable
<RX14> because it's an instance variable
<RX14> therefore you need to nil check it, which is probably the error you are getting
tony_ has joined #crystal-lang
<BlaXpirit> dome22xl, #{filename}" == filename
<BlaXpirit> dome22xl, "#{filename}" == filename
<dome22xl> Yeah thanks its the no overload matches 'File#write' with type String
<dome22xl> So i can't send text to the write function ?
tony_ has quit [Ping timeout: 268 seconds]
rolha has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
<RX14> dome22xl, did you listen to me
<RX14> you have to null check it
<RX14> File#write exists
<RX14> i'm sure
<RX14> nope
<RX14> i'm wrong
<RX14> it's File#puts
<RX14> ignore me
hangyas has quit [Quit: hangyas]
Rinkana has quit [Ping timeout: 250 seconds]
dome22xl has quit [Read error: Connection reset by peer]
dome22xl has joined #crystal-lang
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
A124 has joined #crystal-lang
dome22xl has quit [Read error: Connection reset by peer]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
kfpratt has joined #crystal-lang
greengriminal has joined #crystal-lang
Rinkana has joined #crystal-lang
petercommand has quit [Ping timeout: 260 seconds]
pawnbox_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
kfpratt has quit [Remote host closed the connection]
greengriminal has quit [Quit: This computer has gone to sleep]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
krtv` has quit [Remote host closed the connection]
umurgdk has joined #crystal-lang
petercommand has joined #crystal-lang
<BlaXpirit> >> a = 5; pointerof(a).is_a? Pointer
<DeBot> BlaXpirit: # => true - https://carc.in/#/r/vcl
<yxhuvud> why isn't it pointerto(a) ?
Rinkana has quit [Ping timeout: 250 seconds]
<RX14> huh
<RX14> >> record A, a : Int8, b : Int8; a = A.allocate; a_slice = Slice.new(pointerof(a) as Pointer(UInt8), sizeof(A)); a_slice[0] = 10; p a
<DeBot> RX14: no overload matches 'Slice(UInt8)#[]=' with types Int32, Int32 - https://carc.in/#/r/vdj
greengriminal has joined #crystal-lang
<RX14> >> record A, a : Int8, b : Int8; a = A.allocate; a_slice = Slice.new(pointerof(a) as Pointer(UInt8), sizeof(A)); a_slice[0] = 10_u8; p a
<DeBot> RX14: A(@a=10, @b=0) - more at https://carc.in/#/r/vdq
<RX14> it's interesting how you acn write directory to a struct
<RX14> i.e. write a struct directory to IO and read it back again in crystal
<RX14> directly*
<RX14> not that you should
ozra has quit [Ping timeout: 246 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
elia has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
marcosdsanchez has quit [Quit: leaving]
marcosdsanchez has joined #crystal-lang
kfpratt has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
tony_ has joined #crystal-lang
kfpratt has quit [Ping timeout: 250 seconds]
greengriminal has quit [Client Quit]
bcardiff has joined #crystal-lang
Philpax has joined #crystal-lang
greengriminal has joined #crystal-lang