<raz>
yb66_gitlab: do you know all browser names beforehand?
<raz>
if yes, you could create fields for them with a marco
<raz>
but actually, probably cleaner/safer to have a class/struct for the body of each browser (assuming it's always identical) and populating it by iterating over the unmapped keys
<hightower2>
mm, from a macro, if I have a method from `@type.methods`, can I append something to its documentation section?
<sorcus>
Each `spawn` call requires 8kb of memory?
<sorcus>
asterite: ooops, duplicated `channel`. Anyway, it doesn't change the output from valgrind X-)
<FromGitter>
<asterite> I don't have time to dig into that code, but vallgrind shows memory allocations not only through GC
<sorcus>
asterite: Oh, ok.
<raz>
can i somehow change the stdout/stderr of the current process to an IO of my choice?
<raz>
(i want to capture the output instead of letting it through to stdout)
<sorcus>
raz: IO::Memory?
<raz>
yup, but how do i point STDOUT/STDERR to it?
<FromGitter>
<Blacksmoke16> can you do it the other way? supply the io you want to write to?
<raz>
nope, i need to capture all output that would normally go to stdout
<FromGitter>
<Blacksmoke16> how is it currently being sent to stdout? `puts "foo"`?
<raz>
yup, for example
<raz>
in ruby you can just re-assign $stdout. i'm looking for the equivalent in crystal :)
<FromGitter>
<Blacksmoke16> id vote you just dont do that
<FromGitter>
<Blacksmoke16> like to be clear `puts "foo"` is the same as `STDOUT.puts "foo"`, when you could just do like `io.puts "foo"` where io could be like `io : IO = STDOUT`
<FromGitter>
<Blacksmoke16> i.e. allow using a diff io but default to stdout
<raz>
but then athena might never have a pre-forking webserver 😏
<FromGitter>
<Blacksmoke16> what data is being sent to stdout anyway?
<raz>
logging from the forked workers
<FromGitter>
<Blacksmoke16> cant use MT mode?
<raz>
not production ready and slower than multi-process
<raz>
also less robust even when it's ready
<FromGitter>
<Blacksmoke16> diff logging backend that doesnt use STDOUT?
<raz>
won't capture other prints to stdout that the user may have
<FromGitter>
<Blacksmoke16> i should hope someone isnt using `puts` in prod..
<FromGitter>
<Blacksmoke16> could you redefine top level `puts` method?
<raz>
but that's not pretty and probably not robust either
<raz>
i don't want to capture Log, i want to capture STDOUT/STDERR
<straight-shoota>
you can use freopen to point fd 1 to something different
<raz>
ahhhh!
<raz>
now we are talking
<raz>
thx, will look into that - that will most likely do it
<raz>
hmpf, so close. but no way to get the FileDescriptor from an IO::Stapled or IO::Pipe it seems 😔
<oprypin>
raz, why arent u just using systemd
<raz>
cause it doesn't solve the problem. also docker
<oprypin>
well it does solve the problem. docker doesn't though xD
<raz>
neither does :) but i think i found a way to get at my pipes 🐿️
<oprypin>
it's just so wrong to do it but sure. i think indeed this is a way to get at a filedescriptor. https://crystal-lang.org/api/0.35.1/IO.html#pipe(read_blocking=false,write_blocking=false):Tuple(IO::FileDescriptor,IO::FileDescriptor)-class-method
<hightower2>
So printing with e.g.: ( io << "\x1b[" << row+1 << ';' << col+1 << "H" ) is better than ( io.print "\x1b[#{row+1};#{col+1}H" ) ? Is there anything even better?
Dreamer3 has quit [Quit: Leaving...]
teardown has quit [Remote host closed the connection]
<hightower2>
If I get the args to print via say, *args tuple, then is it ok to do args.each { |a| io << a }, or some even simpler/more efficient loop can be done?
<oprypin>
i dont think so
riffraff169 has left #crystal-lang [#crystal-lang]
<hightower2>
Hm why isn't IO.copy @from, @to doing the same that @to << @from is doing
<oprypin>
hightower2, your io is presumably positioned at the end, so it copies from the end to the end
<hightower2>
aha interesting, since the description says: "Copy all contents from src to dst."
<hightower2>
straight-shoota, awesome tip!
<FromGitter>
<watzon> Is there a way in doc comments to make a word link to a specific namespace? I know the parser will automatically search for inline code fragments and link them if it can, but sometimes it would be nice to be able to semi-manually link to the specific type you want without using the full namespace.
<hightower2>
straight-shoota I can use this for print, that is, when to_s is involved. Is there something similar (i.e. something other than each()) for when I need IO#write ?
<straight-shoota>
oprypin, well usability isn't that great, though. You'd need proper type lookup to reference relative namespaces.
<oprypin>
watzon, well let me know if you're interested. the migration to it is not trivial, and a proper release is still ~ a week away
<oprypin>
straight-shoota, i have type lookup
<straight-shoota>
like the same as the compiler?
<oprypin>
i havent mentioned it anywhere, have it 😬
<oprypin>
straight-shoota, with only tiny differences
<straight-shoota>
oh, great. Never mind then
<straight-shoota>
I'd still rather have that kind of stuff done by the compiler when extracting dos
<straight-shoota>
*docs
<oprypin>
that requires an interactive process
<straight-shoota>
why?
<oprypin>
straight-shoota, otherwise u need to predict all possible combinations
<straight-shoota>
combinations of what?
<oprypin>
lookups
<straight-shoota>
I mean the compiler could just interpret the link syntax and replace it with fully resolved paths in the doc comment
<oprypin>
thats not really how it works
<oprypin>
do you want to feed markdown to the compiler again?
<straight-shoota>
doesn't need markdown, just a simple regex replace
<straight-shoota>
if it works outside the compiler, maybe it isn't that bad.
<hightower2>
So based on collected advices, this should be the most optimal way to do it, right? https://carc.in/#/r/a6h5
<straight-shoota>
I just imagine the lookup algorithms could get out of sync
<straight-shoota>
but, even that's probably not a big deal (and there's not going to be much change to how lookup works)
<oprypin>
straight-shoota, oh yea btw, anything i can do to push though my pull requests?
<oprypin>
through *
<hightower2>
if I do io << args.join(';') , does it figure out that the output for join() is to an IO, or it constructs a string locally and then sends to io?
<straight-shoota>
hightwoer2, the latter
<straight-shoota>
you need to pass io explicitly
<straight-shoota>
oprypin, unfortunately no
<straight-shoota>
unless there's one missing waiting on my approval?
<straight-shoota>
apart from that, we just someone else from the core team to do reviews
_ht has quit [Remote host closed the connection]
<hightower2>
how can I debug which overload is crystal choosing?
<hightower2>
or rather, I am sure it is choosing a wrong overload, but can't reproduce it on carc
<hightower2>
I call args.join(@some_io), and this gets treated as separator rather than io
<hightower2>
which gets remedied if I prefix the argument with io: ...
<hightower2>
straight-shoota, maniacal deletion worked in the end. check the repo now, doesn't use any dependencies. I will try to minimize further and delete even more.
<hightower2>
(but same note applies - don't use tmux since it might confuse the results (by default it's not passing escape sequences into the underlying terminal emulator))
<straight-shoota>
Can't you just print the memory io to stdout or something?
<straight-shoota>
nice, oprypin
<hightower2>
straight-shoota, yes, basically that is done in the end (there is just an optional buffer in between but... probably unrelated to the issue.. will check that specifically)
<hightower2>
right, with STDOUT instead of that @_buf it's also reproducible
<hightower2>
ah, that's the answer to my question how to check the overload used :)
<hightower2>
does anything have to be done about this, or?
<straight-shoota>
I'll send a bugfix
<hightower2>
great, thank you kindly for the discussion/involvement
<straight-shoota>
sure, thanks for pointing it out
<FromGitter>
<Blacksmoke16> i bet id work it the other overload was `separator : String = ""`
<FromGitter>
<Blacksmoke16> if the*
deavmi has quit [Ping timeout: 272 seconds]
<straight-shoota>
oh, right yeah
deavmi has joined #crystal-lang
<hightower2>
right, but as straight-shoota pointed out, it's not desired to limit it to String
<hightower2>
or is it?
<FromGitter>
<Blacksmoke16> either way, id expect it to find the most specific one first
<straight-shoota>
maybe for the optimized version
<FromGitter>
<Blacksmoke16> PHP added a `Stringable` interface :S
<straight-shoota>
everything's stringable in Crystal
<FromGitter>
<Blacksmoke16> which is like `String | types_that_implement_to_string`
<straight-shoota>
the thing is, the optimized version works differently from the non-optimized one.
<FromGitter>
<Blacksmoke16> yea but cant really tell one that does it in a more meaningful, but i suppose it'd be easy enough to have your own stringify method
<straight-shoota>
optimized calls separator.to_s once, whereas non-optimized appends separator to the IO each time, essentially calling separator.to_s(io)
<straight-shoota>
if separator returns different values on each to_s, the optimized version doesn't do that
<straight-shoota>
so maybe it's even better to just restrict the optimized version to String