Here’s some hypothetical ActiveRecord-like application metadata for a blog-like application along with a utility function for querying such metadata.
:- op(500, fx, many).
:- op(500, fx, one).
:- op(600, fx, always).
:- op(600, xf, notnull).
:- op(500, fx, at_least).
:- op(500, fx, at_most).
:- op(500, fx, exactly).
model(post,
title(length(at_least 10)) notnull,
many tags(name),
always one author(name notnull, email(email_addr), url(url)),
body(memo),
many comments,
chronological).
model(comment,
name,
email(validate_regex("\w+ blah blah line noise here")),
ip(ip_addr),
body(memo),
nonenull,
chronological).
get_predicate_instances(Predicate, Instance) :-
between(1, 255, Arity),
functor(Instance, Predicate, Arity),
predicate_property(Instance, interpreted),
call(Instance).
get_predicate_instances allows us to query all instances of a predicate without needing to restrict their arity by enclosing things in lists. Query facilities like it would allow you to place fewer restrictions on what kind of input a user can provide when describing an application.
The point is, if you create a domain-specific metadata language, Prolog can slice and dice it quite nicely. No XML required, no search/traversal boilerplate.
Designing a system like this in a vacuum would be a mistake; I was just toying with postfix and prefix operators more than anything else. What we need is an application we can use every day to drive the development of a system like this.