otisolsen70 has quit [Remote host closed the connection]
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
Paris has joined #ruby
Paris has quit [Remote host closed the connection]
Paris has joined #ruby
desnudopenguino has quit [Read error: Connection reset by peer]
desnudopenguino has joined #ruby
schne1der has quit [Ping timeout: 255 seconds]
yziquel has quit [Quit: Client closed]
bambanxx has joined #ruby
bambanxx has quit [Client Quit]
bambanxx has joined #ruby
desnudopenguino has quit [Read error: Connection reset by peer]
Paris has quit [Remote host closed the connection]
desnudopenguino has joined #ruby
desnudopenguino1 has joined #ruby
desnudopenguino1 has quit [Read error: Connection reset by peer]
desnudopenguino has quit [Ping timeout: 256 seconds]
desnudopenguino has joined #ruby
desnudopenguino has quit [Read error: Connection reset by peer]
desnudopenguino has joined #ruby
constellati0n has joined #ruby
desnudopenguino has quit [Read error: Connection reset by peer]
desnudopenguino has joined #ruby
graywolf has joined #ruby
brokkoli_origin has quit [Ping timeout: 256 seconds]
Vonter has quit [Ping timeout: 256 seconds]
Vonter has joined #ruby
brokkoli_origin has joined #ruby
desnudopenguino1 has joined #ruby
<xkoncek>
how do i write a module's content so that it is reachable both using scope resolution syntax (::) as well as being include-able in the main files?
constellati0n has quit [Ping timeout: 245 seconds]
<xkoncek>
writing def method vs def self.method enables one but disables the other option of accessing them
desnudopenguino has quit [Ping timeout: 268 seconds]
desnudopenguino1 is now known as desnudopenguino
___nick___ has joined #ruby
TomyWork has quit [Remote host closed the connection]
flowersandsharks has joined #ruby
flowersandsharks has quit [Client Quit]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 255 seconds]
desnudopenguino1 is now known as desnudopenguino
xkoncek has quit [Ping timeout: 245 seconds]
constellati0n has joined #ruby
constellati0n has quit [Ping timeout: 260 seconds]
wand has joined #ruby
constellati0n has joined #ruby
constellati0n has quit [Ping timeout: 252 seconds]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
<ox1eef_>
xkoncek: I don't see rb_mod_private_constant in ruby.h - but, 'private_constant :Foo' is a method. You can call it as a method from C.
<xkoncek>
ahh
szkl has quit [Quit: Connection closed for inactivity]
<ox1eef_>
With C extensions in the past I try to implement an interface I can expose to Ruby, and then write Ruby methods that use that C interface. It is not always required to call private_constant from C with that appproach, often easier to do it from Ruby.
<xkoncek>
i am new to Ruby, i chose it mainly because of its neat syntax, however i still haven't managed to find an answer to my question regarding importing symbols
Linux_Kerio has quit [Ping timeout: 255 seconds]
<xkoncek>
it seems in Ruby there is simply no way to import individual symbols into current scope
<ox1eef_>
It sounds like you want one of two features. 'extend self', or 'module_function'.
<ox1eef_>
You could also swap 'extend self' for 'module_function' in that example, and it'd be almost the same. The primary difference is that when Foo is included, 'bar' will be private by default.
<xkoncek>
hmm... right, seems to work
<dorian>
random question: why can't you `include` a class (TypeError, not a module), even if Class.is_a? Module
<ox1eef_>
On a conceptual level, you could think of it as a behavior that a class overrides.
<dorian>
hm
<xkoncek>
ox1eef_: i want to create a DSL of sorts, seems like the most popular approach is widely using blocks, however i noticed that when i use blocks on a struct which defines its methods, those methods will inevitably shadow whatever global object the block may have wanted to reference
<xkoncek>
instance_exec
<ox1eef_>
Do you mean that the methods of the struct you define with 'def' do not have access to the block's scope?
<ox1eef_>
You can use define_method to work around that if that's the case... Struct.new(:foobar) { a = 42; define_method(:bar) { a } }
<xkoncek>
as a library writer i am to make sure there are no unavoidable name collisions
<ox1eef_>
The second definition of foo, within bar, redefines the 'global' foo. It appears you might want to use a lambda, or Proc, in place of that second definition.
<xkoncek>
in the end i chose to use @foo = lambda ...
<ox1eef_>
That seems reasonable based on the example, but I might be missing a bigger context.
<xkoncek>
i am writing something similar to Rake, but majority of the code is native
<xkoncek>
i just want the scripts to look nice
<xkoncek>
i switched from Lua because even tho it is easily embeddable, the Lua code does not look nice
<ox1eef_>
I don't think it is common to define a method inside a method, and there's patterns that can be used to deal with name collision and the nature of being able to monkey patch. Are you using mruby?
<xkoncek>
i no longer define methods inside the method, instead i instantiate a private struct and instance_exec the block on it
<ox1eef_>
https://github.com/mruby/mruby - this sounds more in line with what you might want, especially since you're using C and mentioned being able to embed.
<xkoncek>
hmmm... Fedora doesn't package it :(
<ox1eef_>
It can work standalone from the git repository. I think that's more common with mruby than MRI.