Article View: comp.lang.prolog
Article #1843Re: general data structures are [not] impossible
From: Mark William Hopkins
Date: Sun, 24 Feb 1991 02:28
Date: Sun, 24 Feb 1991 02:28
39 lines
1825 bytes
1825 bytes
In article <6406@skye.cs.ed.ac.uk> jha@lfcs.ed.ac.uk (Jamie Andrews) writes:
>o Manipulations of such data structures are greatly facilitated
> by languages with explicit types, named record fields, and so
> on. Pascal has these; most Prologs don't.
Predicates ARE records only in disguise...
PASCAL:
type Complex = record RE, IM: real end;
PROLOG:
complex(RE, IM) :- real(RE), real(IM).
if floating point came with your Prolog complete with its own real() predicate.
Or better yet as an example:
PASCAL:
type NodeTag = (RE, INT);
Node = record case Tag:NodeTag of
RE: (RVal: real);
INT: (IVal: integer)
end
PROLOG:
node(RE, X) :- !, real(X).
node(INT, X) :- !, integer(X).
Prolog types are far more powerful than corresponding Pascal types,
furthermore, since types in "procedure call"-s can be matched by Unification
in Prolog. The closest thing you have in Pascal is the limited Polymorphism
that the Standard attempted with array types.
A similar argument also proves that Prolog is a very powerful object-oriented
language in disguise.
Also, if you consult the lambda calculus and functional programming literature,
you'll find out about results concerning the correspondence (isomorphism)
between types and propositions which underlies this observation
(records <-> AND, unions/variants <-> OR, functions <-> IMPLICATION, etc.)
Technical Details
Message-ID:
<9732@uwm.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uwm.edu!csd4.csd.uwm.edu!markhReferences:
<6406@skye.cs.ed.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uwm.edu!csd4.csd.uwm.edu!markh From: markh@csd4.csd.uwm.edu (Mark William Hopkins) Newsgroups: comp.lang.prolog Subject: Re: general data structures are [not] impossible Message-ID: <9732@uwm.edu> Date: 24 Feb 91 02:28:36 GMT References: <6406@skye.cs.ed.ac.uk> Sender: news@uwm.edu Organization: University of Wisconsin - Milwaukee Lines: 39