All the Perl that's Practical to Extract and Report

Navigation

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Without JavaScript enabled, you might want to
use the classic discussion system instead. If you login, you can remember this preference.

Currently, I only have a modest module with no real functionality beyond what I have described. I would like to post it to the CPAN, but only after there's enough there for it to be useful. If you absolutely have to play with it (and stroke my little ego), you can download it from my site [easystreet.com]. The documentation is minimal and I wouldn't even consider this alpha quality code.

If you want to see what it does, you'll have to read the tests. If you want to see how it does it, you're crazy:) -- though it's not really difficult to figure out.

The following is provided on the off chance that you want to add stuff and submit patches and tests.

The only thing that would give you pause is the HoHoAoHoAoH. That, believe it or not, is not as difficult as it appears.

Let's say I add one fact to the database -- database being a Prolog term, not what we usually think of:

In this example, the predicate 'owns' gets an ID of 1, 'Ovid' gets an ID of 2 and 'Cheap Whiskey' gets an ID of 3. I should also add that the order of a predicate's arguments does not truly have meaning so long as it is consistent. Therefore, the above fact is just ask likely to mean that "Ovid owns cheap whiskey" as "cheap whiskey owns Ovid", but I prefer not to think about the latter.

The first item in that nasty data structure is a single key _arg_levels (which I forgot to rename). In the above example, the predicate ID for 'owns', 1, becomes a key in the _arg_levels hash. In fact, every predicate 'owns' will have the same ID, just different arguments -- but the same number of arguments -- so what we have left is the AoHoAoH. The above fact generates the following array values for the predicate 'owns':

[0]{2}[1]{3} = {}
[1]{3} = {}

What that means is that for the first argument we have 'Ovid' (id of 2) who has in the second argument position a value of 'Cheap Whiskey' (that's the first line). The second line says that for the second argument, we have the value of 'Cheap Whiskey' and no dependants. It can be confusing, but once you read through the code and get a feel for it, you'll see what this does and why. To verify a fact of X arguments, this data structure requires at most X+1 iterations. Space for time, space for time...

My next step on this is going to be taking a first pass at the unification problem. If that goes well, simple things can be written, though a natural way of creating new rules is a barrier (you'll still have to hardcode rules that deal with more than one predicate).

I also have to tackle allowing lists and embedded facts. The list syntax will be easy:.

That would work because everything in the database will have a unique ID (I haven't assigned those to individual facts yet) and I can embed the ID for a particular fact in another fact. Still, I think it's ugly as sin. Prolog makes it simple. Perl should make it simple.