Re: JESS: Strange behaviour of defadvice

Gaëtan Pruvost <[email protected]>
Newsgroups gmane.comp.java.jess
Message-ID <[email protected]>
  Thanks for the quick reply.

Your solution is perfect. I had seen in the doc that you could use 
"return" to prevent the adviced function to be called but I didn't think 
of it as a solution to my problem... That works great, though I was kind 
of expecting an infinite loop but it seems smart enough not to call the 
advice again.

Thanks for the help.
BTW, I'm working on a binding Jess<->OWL that would rely on Jena if 
people are interested...
I know there exists a bridge for OWL/SWRL in Protege but I was not very 
happy with it and also Jena is much lighter than Protege.



Le 07/10/2010 17:03, Ernest Friedman-Hill a écrit :
> Yes, a function can have only one advice. This wasn't originally the 
> case, but experience showed that allowing multiple advice per function 
> caused problems -- it was too easy to create infinite loops, for example.
>
> You can solve your problem with a before-advice which unbinds the 
> variables, calls bsave explicitly, rebinds the variables, and then 
> returns. If you check the documentation, it explains that explicitly 
> returning from a before-advice will result in the adviced function not 
> being called automatically.
>
>
> On Oct 7, 2010, at 8:44 AM, Gaëtan Pruvost wrote:
>
>> Hi everybody,
>>
>> I have a problem with defadvice's behavior. It looks like you can't 
>> add both a "before" and an "after" advice to the same function.
>> Here is an example that demonstrates it
>>
>> (deffunction f ()
>>     (printout t "during f" crlf))
>>
>> (defadvice before f (printout t "before f" crlf))
>> (defadvice after f (printout t "after f" crlf))
>>
>> (f)
>>
>>
>> It prints:
>> Jess> (batch "test.clp")
>> during f
>> after f
>> Jess>
>>
>> Looks like the after overwrote the before one and there is no way to 
>> define both at the same time...
>> I'm new to Jess so I hope this question is not stupid but i looked in 
>> documentation and in the old mailling-list messages and found no 
>> explaination for it. Is it the intended behaviour (in which case it 
>> would be good to precise it in the doc) or a bug? I'm using the last 
>> Jess71p2.
>>
>> I needed this to unbind global variables before a bsave and rebind 
>> after the bsave (this variable refers to a java Logger which is not 
>> serializable). I've found another solution wihtout using defadvice 
>> but I find the defadvice more elegant.
>>
>>
>> Best regards
>> -- 
>> ***********************************
>> Gaëtan PRUVOST
>>
>> LIMSI-CNRS BP 133
>> 91403 Orsay Cedex France
>> Tel:+33 1 69858110
>>
>> http://www.limsi.fr/Individu/pruvost/
>> ***********************************
>> <gaetan_pruvost.vcf>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences, Sandia National Laboratories
> PO Box 969, MS 9012, Livermore, CA 94550
> http://www.jessrules.com
>
>
>
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [email protected]'
> in the BODY of a message to [email protected], NOT to the list
> (use your own address!) List problems? Notify 
> [email protected].
> --------------------------------------------------------------------
>
gaetan_pruvost.vcf (text/plain, 188 B)
begin:vcard
fn;quoted-printable:Ga=C3=ABtan Pruvost
n;quoted-printable:Pruvost;Ga=C3=ABtan
email;internet:[email protected]
tel;work:+33 1
x-mozilla-html:TRUE
version:2.1
end:vcard
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.