Message from discussion
Using Templates
X-BeenThere: pyke@googlegroups.com
Received: by 10.150.77.36 with SMTP id z36ls244434yba.3.p; Tue, 15 Dec 2009
20:40:11 -0800 (PST)
Received: by 10.150.71.42 with SMTP id t42mr644747yba.15.1260938411545;
Tue, 15 Dec 2009 20:40:11 -0800 (PST)
Received: by 10.150.71.42 with SMTP id t42mr644746yba.15.1260938411513;
Tue, 15 Dec 2009 20:40:11 -0800 (PST)
Return-Path: <chriss...@gmail.com>
Received: from mail-yw0-f157.google.com (mail-yw0-f157.google.com [209.85.211.157])
by gmr-mx.google.com with ESMTP id 18si68144yxe.8.2009.12.15.20.40.11;
Tue, 15 Dec 2009 20:40:11 -0800 (PST)
Received-SPF: pass (google.com: domain of chriss...@gmail.com designates 209.85.211.157 as permitted sender) client-ip=209.85.211.157;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of chriss...@gmail.com designates 209.85.211.157 as permitted sender) smtp.mail=chriss...@gmail.com
Received: by mail-yw0-f157.google.com with SMTP id 29so1377730ywh.32
for <pyke@googlegroups.com>; Tue, 15 Dec 2009 20:40:11 -0800 (PST)
MIME-Version: 1.0
Received: by 10.101.165.35 with SMTP id s35mr29713ano.33.1260938411482; Tue,
15 Dec 2009 20:40:11 -0800 (PST)
Date: Tue, 15 Dec 2009 20:40:11 -0800 (PST)
X-IP: 76.99.162.38
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2b4)
Gecko/20091127 Remi/fc8 Firefox/3.6b4,gzip(gfe),gzip(gfe)
Message-ID: <c9c7c65e-d2e6-45ac-83c3-7b5594df45dd@r12g2000vbm.googlegroups.com>
Subject: Using Templates
From: Chris <chriss...@gmail.com>
To: PyKE <pyke@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Does Pyke support anything like the template feature in Clips?
I'm running into a problem with Pyke, where reifying anything non-
trivial becomes somewhat burdensome.
For example, say I have the facts:
(age Andrew 20)
(weight Andrew 80)
(height Andrew 188)
As the number of facts about Andrew becomes large, it becomes
considerably unwieldy. Using the string "Andrew" as an identifier is
also problematic, since it won't scale when lots of people get added
to the system, possibly including many Andrews.
Clips has a "deftemplate" operator, to allow facts to be bound
together in slots, without having to reify the accumulated data
object, so you could say:
(assert (personal-data (name Andrew) (age 20) (weight 80) ...)
Is there any similar feature in Pyke? I suppose there's nothing
stopping me from defining a fact in Pyke like:
personal-data((uid 1234234134134),(name Andrew),(age 20),(weight 80))
But the way I understand pattern matching in Pyke is that it doesn't
support keywords, in that if I wanted to match (name $n), I'd have to
separately test for it in the 1st, 2nd, 3rd, and however many argument
positions my personal-data fact contains.