Google Groups Home
Help | Sign in
Running rule example causes interpreter to exit
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
IanDickinson  
View profile
 More options Apr 18, 11:58 am
From: IanDickinson <i.j.dickin...@gmail.com>
Date: Fri, 18 Apr 2008 08:58:07 -0700 (PDT)
Local: Fri, Apr 18 2008 11:58 am
Subject: Running rule example causes interpreter to exit
Hi,
I have a problem trying to run an example rule with Rools 0.4. I
wasn't sure where to post the problem description, so I've logged it
on the rools support request tracker:

http://rubyforge.org/tracker/index.php?func=detail&aid=19630&group_id...

but I can re-post it here if that's your preferred mode for providing
support.

Thanks,
Ian


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
cappelaere  
View profile
 More options Apr 20, 7:44 pm
From: cappelaere <cappela...@gmail.com>
Date: Sun, 20 Apr 2008 16:44:57 -0700 (PDT)
Local: Sun, Apr 20 2008 7:44 pm
Subject: Re: Running rule example causes interpreter to exit
Ian,

Can you reproduce this error in Ruby rather than JRuby?
I do not use JRuby...
Thanks,
Pat.

On Apr 18, 11:58 am, IanDickinson <i.j.dickin...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
cappelaere  
View profile
 More options Apr 20, 9:38 pm
From: cappelaere <cappela...@gmail.com>
Date: Sun, 20 Apr 2008 18:38:43 -0700 (PDT)
Local: Sun, Apr 20 2008 9:38 pm
Subject: Re: Running rule example causes interpreter to exit
Ian,

Here is what I found.
I can duplicate the problem using ruby irb (rather than JRuby).
Interestingly enough, the problem does not show up when you load the
same example in a file and run it.
So it seems particular to the interpreter mode.  Is this a requirement
for you?
I can patch the code so it does not fail (and still passes the tests
but I am not too happy about it).
Feel free to experiment with it and give me more feedback:

in lib/rools/default_parameter_proc.rb

   def method_missing(sym, *args)
        facts = @rule.rule_set.get_facts
        if facts.has_key?( sym.to_s )
          #puts "return fact #{facts[sym.to_s].value}"
          return facts[sym.to_s].value
        else
          if sym.to_s != "inspect"
            raise Exception, "symbol: #{sym.to_s} not found in facts"
          else
            return nil
          end
        end
    end

Thanks,
Pat.

On Apr 20, 7:44 pm, cappelaere <cappela...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
IanDickinson  
View profile
 More options Apr 21, 8:27 am
From: IanDickinson <i.j.dickin...@gmail.com>
Date: Mon, 21 Apr 2008 05:27:13 -0700 (PDT)
Local: Mon, Apr 21 2008 8:27 am
Subject: Re: Running rule example causes interpreter to exit
Hi Pat,
Thanks for your reply. I did note in my original support request that
it applies in ruby and jruby both. I in fact implemented a similar
patch myself as a temporary workaround. However, I think you should
fix this problem properly, for two reasons:

1. it's a common pattern for people to paste example code from a
project's own documentation into the interpreter while getting to know
a Ruby library. An early question we all ask when trying out a new
library is "does this thing work?". Causing the interpreter to exit
suddenly from the example code is likely to lead to more "no" answers
than your hard work merits.

2. the reason for the problem is that in your method_missing, all no-
arg methods that are not facts raise an exception. Here is a case
where there's a legitimate no-arg method, inspect, that is not a fact
and should not be an exception. Are you satisfied that there is no
other possible case in which that method_missing legitimately receives
a no-arg message? If not, you have a latent bug that's waiting to
happen to someone else.

Regards,
Ian


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pat Cappelaere  
View profile
 More options Apr 21, 9:48 am
From: Pat Cappelaere <cappela...@gmail.com>
Date: Mon, 21 Apr 2008 09:48:27 -0400
Local: Mon, Apr 21 2008 9:48 am
Subject: Re: [rools-users] Re: Running rule example causes interpreter to exit
Ian,

I took the time to look at it and provided you with a patch while you had
one and did not provide it to me.

So yes I want to fix this and attempted to address your problem the best I
could. And I also said that I was not satisfied with that fix and why.

And if you have a better fix, it would be nice to offer it to the community.

This is Open Source after all and not a one-way street.
Think about it.

Pat.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pat Cappelaere  
View profile
 More options Apr 21, 8:54 am
From: Pat Cappelaere <cappela...@gmail.com>
Date: Mon, 21 Apr 2008 08:54:35 -0400
Local: Mon, Apr 21 2008 8:54 am
Subject: Re: [rools-users] Re: Running rule example causes interpreter to exit
Ian,

Thanks for not submitting your patch and giving me grief for not fixing it
while I am trying to understand what the real problem is.

I certainly understand that it would be nice to support the interpreter.  I
am sorry if I did not catch that problem before and I am not sure how I
could test for it.  I have tried to add test cases to get 100% coverage so I
guess I failed miserably.

My concern is that the fix I provided to you addresses your problem but I am
still not satisfied that there is not another case out there.  So YES, there
is a latent bug that's waiting to happen.  And if you are smarter than I am
and can fix it, please let us know.

Regards,
Pat.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google