Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aquarium 0.5.1 and Ruby 1.9.3 #41

Open
nvoynov opened this issue Oct 6, 2014 · 3 comments
Open

Aquarium 0.5.1 and Ruby 1.9.3 #41

nvoynov opened this issue Oct 6, 2014 · 3 comments

Comments

@nvoynov
Copy link

nvoynov commented Oct 6, 2014

Hello, colleagues.

I'm trying execute next code from the basic example

require 'aquarium'
include Aquarium::Aspects

class Foo
  def foo
    'foo'
  end
end

Aspect.new :around, :calls_to => :all_methods, :on_types =>  [Foo] do |joint_point, object, *args|
  p "Entering: #{join_point.target_type.name}##{join_point.method_name} for object #{object}"
  result = join_point.proceed
  p "Leaving: #{join_point.target_type.name}##{join_point.method_name} for object #{object}"
  result  # block needs to return the result of the "proceed"!
end

foo = Foo.new
foo.foo

and have next console output

d:/apps/Ruby193/lib/ruby/gems/1.9.1/gems/aquarium-0.5.1/lib/aquarium/aspects/aspect.rb:402: warning: redefining `object_id' may cause serious problems
d:/apps/Ruby193/lib/ruby/gems/1.9.1/gems/aquarium-0.5.1/lib/aquarium/aspects/aspect.rb:403: stack level too deep (SystemStackError)

It possible to get worked aspectr code for Ruby 1.9.3p545?

@deanwampler
Copy link
Contributor

I'll take a look later this week.

dean

Dean Wampler, Ph.D.
Typesafe
"Functional Programming for Java Developers",
"Programming Scala", and
"Programming Hive" - all from O'Reilly
twitter: @deanwampler, @chicagoscala
http://typesafe.com
http://polyglotprogramming.com

On Mon, Oct 6, 2014 at 8:32 AM, Nikolay Voynov [email protected]
wrote:

Hello, colleagues.

I'm trying execute next code from the basic example

require 'aquarium'
include Aquarium::Aspects

class Foo
def foo
'foo'
end
end

Aspect.new :around, :calls_to => :all_methods, :on_types => [Foo] do |joint_point, object, *args|
p "Entering: #{join_point.target_type.name}##{join_point.method_name} for object #{object}"
result = join_point.proceed
p "Leaving: #{join_point.target_type.name}##{join_point.method_name} for object #{object}"
result # block needs to return the result of the "proceed"!
end

foo = Foo.new
foo.foo

and have next console output

d:/apps/Ruby193/lib/ruby/gems/1.9.1/gems/aquarium-0.5.1/lib/aquarium/aspects/aspect.rb:402: warning: redefining `object_id' may cause serious problems
d:/apps/Ruby193/lib/ruby/gems/1.9.1/gems/aquarium-0.5.1/lib/aquarium/aspects/aspect.rb:403: stack level too deep (SystemStackError)

It possible to get worked aspectr code for Ruby 1.9.3p545?


Reply to this email directly or view it on GitHub
#41.

@chicagoscala
Copy link
Contributor

I'm afraid I won't have time to look at this for a few weeks. I'm on a busy
travel schedule at the moment.

I'm not working with Ruby anymore, so it takes me several hours to update
my tools, etc., etc., just to get started. In fact, I'm looking for people
to take over the project...

Anyway, the github code is a bit newer than than the last 0.5.X release. It
might already fix your issue. Also, from your stack trace, it appears to be
using 1.9.1 gems, instead of 1.9.3 gems.

https://github.com/deanwampler/Aquarium

Sorry I can't address this right away.

dean

Dean Wampler, Ph.D.
Typesafe
"Functional Programming for Java Developers",
"Programming Scala", and
"Programming Hive" - all from O'Reilly
twitter: @deanwampler, @chicagoscala
http://typesafe.com
http://polyglotprogramming.com

On Wed, Oct 8, 2014 at 8:03 AM, Dean Wampler [email protected]
wrote:

I'll take a look later this week.

dean

Dean Wampler, Ph.D.
Typesafe
"Functional Programming for Java Developers",
"Programming Scala", and
"Programming Hive" - all from O'Reilly
twitter: @deanwampler, @chicagoscala
http://typesafe.com
http://polyglotprogramming.com

On Mon, Oct 6, 2014 at 8:32 AM, Nikolay Voynov [email protected]
wrote:

Hello, colleagues.

I'm trying execute next code from the basic example

require 'aquarium'
include Aquarium::Aspects

class Foo
def foo
'foo'
end
end

Aspect.new :around, :calls_to => :all_methods, :on_types => [Foo] do
|joint_point, object, *args|
p "Entering: #{join_point.target_type.name}##{join_point.method_name}
for object #{object}"
result = join_point.proceed
p "Leaving: #{join_point.target_type.name}##{join_point.method_name}
for object #{object}"
result # block needs to return the result of the "proceed"!
end

foo = Foo.new
foo.foo

and have next console output

d:/apps/Ruby193/lib/ruby/gems/1.9.1/gems/aquarium-0.5.1/lib/aquarium/aspects/aspect.rb:402:
warning: redefining `object_id' may cause serious problems

d:/apps/Ruby193/lib/ruby/gems/1.9.1/gems/aquarium-0.5.1/lib/aquarium/aspects/aspect.rb:403:
stack level too deep (SystemStackError)

It possible to get worked aspectr code for Ruby 1.9.3p545?


Reply to this email directly or view it on GitHub
#41.


Reply to this email directly or view it on GitHub
#41 (comment).

@seeurchin
Copy link
Contributor

seeurchin commented Jan 30, 2019

Hi @nvoynov, you might need to apply options :method_options => :exclude_ancestor_methods
it becomes like this:

Aspect.new :around, :calls_to => :all_methods, :on_types =>  [Foo], :method_options => :exclude_ancestor_methods do |joint_point, object, *args|
  p "Entering: #{join_point.target_type.name}##{join_point.method_name} for object #{object}"
  result = join_point.proceed
  p "Leaving: #{join_point.target_type.name}##{join_point.method_name} for object #{object}"
  result  # block needs to return the result of the "proceed"!
end

Without that constraint Aspect try to redefine every method on ancestor chain. How about we make that constraint by default when "all_methods" is used @deanwampler ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants