Hi Cle, > it seemed to me, that only the last two rules of 'fact1' remained! All > the other were forgotten. > Now I wonder, if this is intended behavior?
Oh, yes, sorry! This is indeed the intended behavior, and I have to explain the reasons: In PicoLisp, a source file should always be written in such a way that it can be changed at any time, and then 'load'ed. Then the new definitions etc. should be manifest in the system. This works well for 'setq', 'de' and other functions that replace the value of a symbol. 'de' issues a message when the value was changed, and everything is OK. It gets problematic, however, when other structures are modified. For example, methods (defined with 'dm') put the definition into a list in current class symbol's value cell. When an existing method is replaced with a new definition, a message like in the case of 'de' is issued and the new method definition is stored. But when a method definition was simply removed from the source file, or commented out, no change will happen in the class. So here we have a discrepancy between the source file and the interpreter state. Fortunately, this is usually not such a big problem, because a deleted method will probably not do much harm (it will, however, if it overrides a method in a parent class). To be sure, it is safer to start the interpreter from scratch if method defintions were removed. For Pilog rules, the situation is worse. If a rule is just removed from a source file, the in-memory state will stay non-modified as in the case of the method. But the fact whether a rule is there or not is rather critical for the behavior of a Pilog program. To avoid such problems, Pilog obeys the following rule: Whenever a new rule is detected, it is assumed that the definition of the previous rule finished, and a new rule starts. Then all possibly old definitions get cleared, and the following definitions are collected into that rule. This makes it safe to 'load' and re-'load' a source file as often as desired. But, if a source file contains: (be fact1 (...)) (be fact1 (...)) (be fact2 (...)) (be fact2 (...)) (be fact1 (...)) (be fact1 (...)) then the fact1 definitions preceding those of fact2 will be lost, and only the final two remain. Pilog believes that 'fact1' is re-loaded. In summary, the assumption is that all rule definitions for a given symbol are always consecutive in the source. Though this is a bit confusing at the first sight, I think it is a quite practical convention. Cheers, - Alex -- UNSUBSCRIBE: mailto:[email protected]?subject=unsubscribe
