Running rule example causes interpreter to exit

13 views
Skip to first unread message

IanDickinson

unread,
Apr 18, 2008, 11:58:07 AM4/18/08
to Rools Users
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=1166&atid=4614

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

Thanks,
Ian

cappelaere

unread,
Apr 20, 2008, 7:44:57 PM4/20/08
to Rools Users
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:
> 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...

cappelaere

unread,
Apr 20, 2008, 9:38:43 PM4/20/08
to Rools Users
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.

IanDickinson

unread,
Apr 21, 2008, 8:27:13 AM4/21/08
to Rools Users
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

Pat Cappelaere

unread,
Apr 21, 2008, 9:48:27 AM4/21/08
to Ian Dickinson, Pat Cappelaere, rools...@googlegroups.com
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.

> From: Ian Dickinson <i.j.di...@gmail.com>
> Date: Mon, 21 Apr 2008 14:24:33 +0100
> To: Pat Cappelaere <cappe...@gmail.com>
> Cc: <rools...@googlegroups.com>
> Subject: Re: [rools-users] Re: Running rule example causes interpreter to exit
>
> Hi Pat,
> Well, I'm not sure what I said to generate a response like that. In


> your previous message, you wrote:
>
>> 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).
>

> which, to me, suggested that you didn't think it was very important to
> fix the issue. Fair enough, it's your project and entirely your call
> what to fix and when, no dispute from me. I was simply making a
> counter-argument why you might want to consider fixing it *at some
> point*. I wasn't thumping the desk and shouting fix it now.
>
> I have no desire to give you any grief, so I'll switch my project to
> use another approach. No grief all round then.
>
> Regards,
> Ian


Pat Cappelaere

unread,
Apr 21, 2008, 8:54:35 AM4/21/08
to rools...@googlegroups.com, i.j.di...@gmail.com
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 all
Reply to author
Forward
0 new messages