havenwood changed the topic of #ruby to: Ruby 3.3.2, 3.2.4, 3.4.0-preview1 https://www.ruby-lang.org | Logs https://libera.irclog.whitequark.org/ruby
hightower2 has joined #ruby
cappy has joined #ruby
dipnlik has quit [Ping timeout: 268 seconds]
dipnlik has joined #ruby
jardsonto has quit [Ping timeout: 260 seconds]
jardsonto has joined #ruby
jardsonto has quit [Ping timeout: 268 seconds]
jardsonto has joined #ruby
fercell has quit [Ping timeout: 260 seconds]
fercell has joined #ruby
cappy has quit [Quit: Leaving]
Linux_Kerio has joined #ruby
Vonter has joined #ruby
dipnlik has quit [Ping timeout: 268 seconds]
grenierm has joined #ruby
konsolebox has joined #ruby
gaussianblue has joined #ruby
boki_ has quit [Quit: Leaving]
brw has quit [Quit: The Lounge - https://thelounge.chat]
brw has joined #ruby
user71 has joined #ruby
rvalue- has joined #ruby
rvalue has quit [Ping timeout: 252 seconds]
rvalue- is now known as rvalue
xdminsy has quit [Quit: Konversation terminated!]
xdminsy has joined #ruby
user71 has quit [Quit: Leaving]
jaredce has joined #ruby
fercell has quit [Quit: ZNC - https://znc.in]
fercell has joined #ruby
jaredce has quit [Ping timeout: 268 seconds]
grenierm has quit [Ping timeout: 250 seconds]
TomyWork has joined #ruby
grenierm has joined #ruby
grenierm has quit [Quit: Client closed]
user71 has joined #ruby
jaredce has joined #ruby
tarel2 has quit [Quit: Client closed]
user71 has quit [Quit: Leaving]
donofrio__ has joined #ruby
donofrio_ has quit [Ping timeout: 268 seconds]
konsolebox has quit [Ping timeout: 268 seconds]
rdsm has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
mretka has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
rdsm has joined #ruby
mretka has joined #ruby
manveru has quit [Quit: bye]
manveru has joined #ruby
konsolebox has joined #ruby
dipnlik has joined #ruby
dipnlik has quit [Changing host]
dipnlik has joined #ruby
gaussianblue has quit [Quit: leaving]
FetidToot3 has quit [Quit: The Lounge - https://thelounge.chat]
FetidToot3 has joined #ruby
FetidToot3 has quit [Client Quit]
FetidToot3 has joined #ruby
donofrio has joined #ruby
jaredce has quit [Ping timeout: 268 seconds]
donofrio has quit [Remote host closed the connection]
donofrio has joined #ruby
Al2O3 has quit [Quit: Good mourning, good after nun, g'nite, and goober evenings.]
donofrio__ has quit [Ping timeout: 268 seconds]
jaredce has joined #ruby
Exa has quit [Quit: see ya!]
user71 has joined #ruby
Exa has joined #ruby
user71 has quit [Quit: Leaving]
cappy has joined #ruby
user71 has joined #ruby
dipnlik has quit [Ping timeout: 240 seconds]
user71 has quit [Quit: Leaving]
cappy has quit [Quit: Leaving]
dipnlik has joined #ruby
srbaker has quit [Ping timeout: 252 seconds]
dipnlik has quit [Ping timeout: 268 seconds]
dipnlik has joined #ruby
user71 has joined #ruby
gaussianblue has joined #ruby
graywolf has joined #ruby
jaredce has quit [Ping timeout: 264 seconds]
graywolf has quit [Quit: WeeChat 4.3.0]
dipnlik has quit [Remote host closed the connection]
dipnlik has joined #ruby
dipnlik has quit [Changing host]
dipnlik has joined #ruby
crespire has joined #ruby
crespire1 has quit [Ping timeout: 264 seconds]
TomyWork has quit [Remote host closed the connection]
xkoncek has joined #ruby
<xkoncek> is there anything like lazy string interpolation in Ruby?
jaredce has joined #ruby
jaredce has quit [Ping timeout: 268 seconds]
<konsolebox> xkoncek: Don't know but another strategy to prevent interpolating everything at once is to also receive an optional composer block. I just wonder if Ruby has optimized that part already so procs don't have to be repeatedly compiled.
<konsolebox> xkoncek: It's helpful when passing a message to a logger function that could be disabled if function level is lower (or higher depending on the strategy) than the current logging level.
<xkoncek> maybe i'll go with the good ol' % substitution
<konsolebox> xkoncek: As an example, I could have log.debug{ "Exception received: #{ex.class.to_s}: #{ex.message}\nBacktrace: #{ex.backtrace.join("\n\t")}" }
<konsolebox> xkoncek: How does that make it lazy?
<xkoncek> what does the {} do in your case?
<konsolebox> xkoncek: That's a block.
<konsolebox> xkoncek: If debugging mode is enabled the proc block is called and the message gets composed. No composing happens if debugging is enabled since the block won't be called.
<konsolebox> xkoncek: However, if I call log.debug with a message parameter instead, the string is always composed.
<konsolebox> xkoncek: So it's not "lazy"
<xkoncek> so in my case, i did not exactly meant lazy, i meant deferred
<kjetilho> it's the same
<konsolebox> Why do you seek deferred?
<kjetilho> or what do you mean by deferred? it will not be evaluated before the value is needed.
<xkoncek> imagine something like this: func("manpage.adoc", ["asciidoctor", "-b", "manpage", "-D", "doc", $SOURCE])
<kjetilho> you want deferred *function* calls, not strings?
<xkoncek> the function call creates an object, and the actual substitution would happen later
<konsolebox> xkoncek: Substitution always happens when evaluated. Don't compose anything if keep the objects the way they are if you want to keep the composition of the string to be delayed. You can also utilize the strategy I mentioned above.
donofrio has quit [Quit: Leaving]
donofrio_ has joined #ruby
donofrio_ has quit [Remote host closed the connection]
donofrio_ has joined #ruby
<konsolebox> xkoncek: You can also try deferred object solutions like the use of observables which seems dead in Ruby: https://github.com/ReactiveX/RxRuby. You'll want to switch to JS for that: https://github.com/reactivex/rxjs
<xkoncek> i found the `eval` function
<kjetilho> oh noes.
<konsolebox> xkoncek: That doesn't really make anything more efficient. Why not compose a proc?
<kjetilho> code blocks in Ruby is one of its best features
<konsolebox> xkoncek: Lookup Ruby lambdas. You might find them more appropriate for your use case.
<xkoncek> yeah so..., i tried something like this, seems like it will work https://paste.centos.org/view/48f89dd8
<xkoncek> and the syntax is... not the worst thing in the world
user71 has quit [Quit: Leaving]
jardsonto has quit [Quit: leaving]
rvalue has quit [Read error: Connection reset by peer]
goldfish has joined #ruby
rvalue has joined #ruby
mretka has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
rdsm has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
rdsm has joined #ruby
mretka has joined #ruby
konsolebox has quit [Quit: .]
xdminsy has quit [Ping timeout: 255 seconds]
<xkoncek> in the Ruby C API, how can i achieve converting a lambda to a block and instance_exec'ing it?
<xkoncek> lamb = ->{ puts @x }; instance_exec(&lamb)
<xkoncek> rb_obj_instance_exec uses the block passed to the current function
cappy has joined #ruby
donofrio_ has quit [Ping timeout: 264 seconds]
cappy has quit [Client Quit]
<xkoncek> the answer is: use `rb_funcall_with_block`
Linux_Kerio has quit [Ping timeout: 252 seconds]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
dipnlik has quit [Ping timeout: 246 seconds]
gaussianblue has quit [Quit: leaving]
hightower3 has joined #ruby
ua_ has quit [Ping timeout: 264 seconds]
hightower2 has quit [Ping timeout: 246 seconds]
deadmarshal_ has quit [Remote host closed the connection]
dipnlik has joined #ruby
dipnlik has quit [Ping timeout: 268 seconds]
deadmarshal_ has joined #ruby
eam has quit [Ping timeout: 272 seconds]
eam has joined #ruby