> From: es1234 <es1234@eng.warwick.ac.uk>
> Dear all,
>
> I am at present a student at Warwick University, working on
> a project on translating a Knowledge Acquisition Module from Franz
> Lisp to Pop-11.
>
> There are some functions that I could not re-write in Pop-11,
> even though I tried for a long time.
>
> I would be grateful if anyone can kindly let me know any
> possible way for re-writting them. The functions are as follows:
>
> Franz Pop-11
> -----------------------------------------------
> plist
> eval
> get
> putprop
> remprop
> -----------------------------------------------
WARNING: I'm no Lisp expert... I've just refreshed what little Lisp I
ever new from the Poplog REF files :-)
The closest Pop-11 equivalent to -eval- is probably -pop11_compile-
pop11_compile([ 1 + 1]) VS (eval (+ 1 1))
REF * POPCOMPILE gives an overview of the Pop-11 compilation process and
the various flags which effect its operation.
Probably the most direct translation of property-lists in Pop-11 would
be to use properties. For example:
vars foo = newassoc([ [a 10] [b 20]]);
VS
(defvar foo nil)
(setf (get 'foo 'a) 10)
(setf (get 'foo 'b) 20)
To access the value associated with a specified indicator (or "key" in
Pop-11 terminology) you just apply it to the Pop-11 property.
foo("a")=>
** 10
the Lisp equivalent would be
(get 'foo 'a)
To remove an association between an indicator and its value in Pop-11
you assign the default value (for properties created with -newassoc-
this is -false-, you can create properties with different default values
using other proceedures.)
So:
false -> foo("a");
is the same as
(remprop 'foo 'a)
For more details on the many interesting and wonderful things you can do
with properties see REF * PROPS.
However if you're using properties as records are used in other
languages, the -defclass- contruct would be more sensible. Pop-11
properties are implemented as hash-tables which are rather inefficient
in comparison to records if you know the type and number of fields you
will be dealing with. For example, the following Pop-11 code
defclass address {street, town, postcode};
Defines a new Pop-11 recordclass "address". The above causes the
following to be defined.
consaddress --- for constructing address records
destaddress --- for "de-constructing" address records
street, town, postcode --- for accessing and destructivly updating
the fields in an address record
isaddress --- for recognising address records
address_key --- the "key" of address records (all data types in
Pop-11 have an associated "key" structure which
contains information on the way that type behaves,
see REF * KEYS for full details.)
EG:
;;; CONSTRUCT A NEW ADDRESS RECORD
vars foo = consaddress('10 Foo Rd', 'Notown', 'GH1 23C')
foo=>
** <address '10 Foo Rd' 'Notown' 'GH1 23C'>
;;; CHECK TYPE
isaddress(foo)=>
** <true>
;;; ACCESS
street(foo)=>
** '10 Foo Rd'
;;; UPDATE
'11 Foo Rd' -> street(foo);
;;; DE-CONSTRUCT
vars s, t, p;
destaddress(foo) -> (s, t, p);
s=>
** '11 Foo Rd'
t=>
** 'Notown'
p=>
** 'GH1 23C'
;;; THE KEY
datakey(foo)==address_key =>
** <true>
See REF * DEFSTRUCT for the full and gory details of how to create your
own Pop-11 data classes.
I've no idea what the functions -plist- and -putprop-. They're not in
Poplog Lisp so I presume they are not standard Common Lisp. Perhaps
someone more familier with Lisp than I can help you with these.
Hope this helps.
aids (email: adrianh@cogs.susx.ac.uk, phone: +44 (0)273 678367)
ObDisclamer: Poplog used to pay my wages
|