Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 19 18:56
    asterite ready_for_review #12405
  • Aug 19 18:56
    asterite edited #12405
  • Aug 19 17:43
    asterite labeled #12405
  • Aug 19 16:38
    Blacksmoke16 labeled #12405
  • Aug 19 16:38
    Blacksmoke16 labeled #12405
  • Aug 19 16:02
    asterite synchronize #12405
  • Aug 19 16:01
    asterite opened #12405
  • Aug 19 15:34
    kramerul synchronize #12404
  • Aug 19 15:23
    kramerul synchronize #12404
  • Aug 19 15:13
    kramerul synchronize #12404
  • Aug 19 15:10
    kramerul synchronize #12404
  • Aug 19 15:08
    Blacksmoke16 labeled #12404
  • Aug 19 15:08
    Blacksmoke16 labeled #12404
  • Aug 19 15:08
    Blacksmoke16 labeled #12404
  • Aug 19 15:06
    wonderix opened #12404
  • Aug 19 14:20
    asterite closed #12403
  • Aug 19 12:42
    straight-shoota milestoned #12403
  • Aug 19 12:42
    straight-shoota milestoned #12403
  • Aug 19 12:03
    asterite synchronize #12403
  • Aug 19 11:34
    straight-shoota closed #11420
Rubi
@codenoid
agree
schoening
@schoening
should modules start with an uppercase?
Bar Hofesh
@bararchy
It seems that read_timeout and write_timeout does not work for pipes
From IRC (bridge bot)
@FromIRC
<vegai> @schoening: https://crystal-lang.org/docs/conventions/coding_style.html here's something to start with :⁠)
schoening
@schoening
ups
.. wrong chat sorry
@vegai thank you, crystal has it all specified nicely. I was actually trying to ask in the typescript room :p
From IRC (bridge bot)
@FromIRC
<vegai> :}
Bar Hofesh
@bararchy
Can I cast an Array(UInt8) to Slice(UInt8) ?
Ghost
@ghost~55586c4815522ed4b3e08557
You should be able to do #to_slice on it
Bar Hofesh
@bararchy
@bew
Error in line 3: undefined method 'to_slice' for Array(UInt8)
From IRC (bridge bot)
@FromIRC
<Papierkorb> @bew, that never went through lul
Bar Hofesh
@bararchy
So... no way I guess right ?
Ghost
@ghost~55586c4815522ed4b3e08557
Huh right not defined... Why? Idk
Well, could do Slice.new(arr.to_unsafe, arr.size) but it's not pretty..
Bar Hofesh
@bararchy
Better then nothing
:)
kipar
@konovod
There was a discussion about it. @asterite said that Slice is supposed to be safe, but Array.to_slice isn't safe at all - array can be reallocated after this call, making slice bad. So creating slice should be ugly)
From IRC (bridge bot)
@FromIRC
<Papierkorb> cough StaticArray
kipar
@konovod
for StaticArray there is to_slice as it's safe. But their usage is of course limited. Size can't be too big etc
From IRC (bridge bot)
@FromIRC
<Groogy> well Static array isn't safe?
<Papierkorb> It's .. the opposite of safe
<Groogy> It can't reallocate but it is way more prone to be destroyed in comparison
Ghost
@ghost~55586c4815522ed4b3e08557
@bararchy what did you tried that failed for #4891 ?
Bar Hofesh
@bararchy

Get a process output via a IO::Memory, as in

output = IO::Memory.new
ps = Process.new("/bin/bash", output: output)
output.size
output.to_s

This wont print anything from process to the output, I played with a different processes also, IO#pipe works

I think It can't work because the Process needs an actual FD which IO::Memory is not
@bew
From IRC (bridge bot)
@FromIRC
<Papierkorb> Correct
Bar Hofesh
@bararchy
In that case, It should not compile and give an error that IO::Memory cannot be used with Process (no overload of...)
Ghost
@ghost~55586c4815522ed4b3e08557
right.. it's weird because there should be a copy from the process output, to the memory io..
even looking at the code I can't understand why it's not working, can't find what I'm missing here..
From IRC (bridge bot)
@FromIRC
<Papierkorb> It has no file descriptor.
Bar Hofesh
@bararchy
@bew The process needs an actual FD to write output to, it can't write to the Crystal memory buffer as it's not aware of it's existese
Ghost
@ghost~55586c4815522ed4b3e08557
I know, but there should be a pipe created, at this point: https://github.com/crystal-lang/crystal/blob/master/src/process.cr#L224
Bar Hofesh
@bararchy
You can create a dummy FD that is piped to the IO::Memory, but then it's no longer IO::Memory , it's IO#pipe
From IRC (bridge bot)
@FromIRC
<vegai> there's no way to make operators take optional arguments, is there?
<Papierkorb> Thankfully not.
<vegai> :⁠)
kipar
@konovod

It's .. the opposite of safe

why? I thought local variables are GC'd anyway, so if there is a Slice pointing to it it won't be gone.

From IRC (bridge bot)
@FromIRC
<vegai> I'm having this problem where I'm defining / for my type, and it might be benificial to have the max precision of the operation be an optional parameter
<Papierkorb> @konovod, StaticArray lives on the stack. The GC never sees it.
Ghost
@ghost~55586c4815522ed4b3e08557
@bararchy following need_pipe? def, https://github.com/crystal-lang/crystal/blob/master/src/process.cr#L349 an IO::Memory will return true
From IRC (bridge bot)
@FromIRC
<vegai> but perhaps I'll just define "div" to do that
Ghost
@ghost~55586c4815522ed4b3e08557
and this line https://github.com/crystal-lang/crystal/blob/master/src/process.cr#L228 should continuously copy the coming output to the memory io... no?
kipar
@konovod
@Papierkorb, oh, i see now.
Ghost
@ghost~55586c4815522ed4b3e08557
Papierkorb, sorry for direct mention, but.. can you spot what I'm missing above?
From IRC (bridge bot)
@FromIRC
<Papierkorb> @bew, from just reading those few lines, yep that needs_pipe branch should be taken
Bar Hofesh
@bararchy
So a bug then ?
Ghost
@ghost~55586c4815522ed4b3e08557
@bararchy maybe your example fails because you're not waiting for the process to finish executing, so you don't have any output yet?