Re: abstract data types in XQuery? information hiding?

Dimitre Novatchev <[email protected]> Mon, 17 Jun 2024 18:08:27 -0700
Newsgroups gmane.text.xml.devel
Message-ID <CAK4KnZc7fJwD24Tis5G8CkkuFoYpc7_CDzt9_D6RxegpVth2-g@mail.gmail.com>
--000000000000d1664d061b1fb8c5
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

 > For example, I could use a macro pre-processor to define a short name
> for the abstract data type and as its expansion supply the appropriate
> type description.

I was wondering if this could not be achieved by using a type-name (alias)
and an extensible record (that mandates that the user must add at least one
more field) ?

Thanks,
Dimitre

On Mon, Jun 17, 2024 at 10:51=E2=80=AFAM C. M. Sperberg-McQueen <
[email protected]> wrote:

> Suppose that a program written in a set of XQuery modules made use of
> some abstract data type.  Suppose further that the programmer wished to
> be able to experiment with different implementations of that abstract
> data type.  (Maybe it's an XML element node, or a sequence of elements,
> maybe it's a map indexed by strings, maybe it's a two-level map, maybe
> ...)
>
> Since XQuery doesn't have the ability to declare new type names (or am I
> missing something very important?), I don't see a straightforward way to
> do this inside of XQuery.
>
> As an alternative, I can imagine handling this with a level of
> indirection (is there any problem in programming that cannot be solved
> or papered over by adding a level of indirection?).
>
> For example, I could use a macro pre-processor to define a short name
> for the abstract data type and as its expansion supply the appropriate
> type description.
>
>     #define FOO element(foo)
>
> or
>
>    #define FOO map(*)
>
> Then I can declare a function as
>
>    define function make-foo($s as xs:string) as FOO {
>       ...
>    };
>
> and run my source code through the macro pre-processor before submitting
> it to the XQuery engine.
>
> I suspect there are other ways.  (In my case, I work with a literate
> programming system that allows me to maintain multiple versions of code
> in parallel.  But I'm finding that method a little klunky, and it does
> nothing to enforce appropriate information-hiding boundaries.  Although
> neither does a macro-preprocessor, come to that.)
>
> Do any readers of this list have experience with ways of layering some
> feature over XQuery by use of a preprocessor of some kind, or by other
> means?  Failing that, does anyone have ideas of suggestions that might
> be worth trying?
>
> Thanks!
>
> --
> C. M. Sperberg-McQueen
> Black Mesa Technologies LLC
> http://blackmesatech.com
>
> _______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: [email protected]
> subscribe: [email protected]
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>
>

--000000000000d1664d061b1fb8c5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div>
&gt; For example, I could use a macro pre-processor to define a short name<=
br>


&gt;=20

for the abstract data type and as its expansion supply the appropriate<br>


&gt;=20

type description.

</div><div><br></div><div>I was wondering if this could not be achieved by =
using a type-name (alias) and an extensible record (that mandates that the =
user must add at least one more field) ?</div><div><br></div><div>Thanks,</=
div><div>Dimitre<br></div></div><br><div class=3D"gmail_quote"><div dir=3D"=
ltr" class=3D"gmail_attr">On Mon, Jun 17, 2024 at 10:51=E2=80=AFAM C. M. Sp=
erberg-McQueen &lt;<a href=3D"mailto:[email protected]">cmsmcq@black=
mesatech.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddin=
g-left:1ex">Suppose that a program written in a set of XQuery modules made =
use of<br>
some abstract data type.=C2=A0 Suppose further that the programmer wished t=
o<br>
be able to experiment with different implementations of that abstract<br>
data type.=C2=A0 (Maybe it&#39;s an XML element node, or a sequence of elem=
ents,<br>
maybe it&#39;s a map indexed by strings, maybe it&#39;s a two-level map, ma=
ybe<br>
...)<br>
<br>
Since XQuery doesn&#39;t have the ability to declare new type names (or am =
I<br>
missing something very important?), I don&#39;t see a straightforward way t=
o<br>
do this inside of XQuery.<br>
<br>
As an alternative, I can imagine handling this with a level of<br>
indirection (is there any problem in programming that cannot be solved<br>
or papered over by adding a level of indirection?).<br>
<br>
For example, I could use a macro pre-processor to define a short name<br>
for the abstract data type and as its expansion supply the appropriate<br>
type description.<br>
<br>
=C2=A0 =C2=A0 #define FOO element(foo)<br>
<br>
or<br>
<br>
=C2=A0 =C2=A0#define FOO map(*)<br>
<br>
Then I can declare a function as<br>
<br>
=C2=A0 =C2=A0define function make-foo($s as xs:string) as FOO {<br>
=C2=A0 =C2=A0 =C2=A0 ...<br>
=C2=A0 =C2=A0};<br>
<br>
and run my source code through the macro pre-processor before submitting<br=
>
it to the XQuery engine.<br>
<br>
I suspect there are other ways.=C2=A0 (In my case, I work with a literate<b=
r>
programming system that allows me to maintain multiple versions of code<br>
in parallel.=C2=A0 But I&#39;m finding that method a little klunky, and it =
does<br>
nothing to enforce appropriate information-hiding boundaries.=C2=A0 Althoug=
h<br>
neither does a macro-preprocessor, come to that.)<br>
<br>
Do any readers of this list have experience with ways of layering some<br>
feature over XQuery by use of a preprocessor of some kind, or by other<br>
means?=C2=A0 Failing that, does anyone have ideas of suggestions that might=
<br>
be worth trying?<br>
<br>
Thanks!<br>
<br>
-- <br>
C. M. Sperberg-McQueen<br>
Black Mesa Technologies LLC<br>
<a href=3D"http://blackmesatech.com" rel=3D"noreferrer" target=3D"_blank">h=
ttp://blackmesatech.com</a><br>
<br>
_______________________________________________________________________<br>
<br>
XML-DEV is a publicly archived, unmoderated list hosted by OASIS<br>
to support XML implementation and development. To minimize<br>
spam in the archives, you must subscribe before posting.<br>
<br>
[Un]Subscribe/change address: <a href=3D"http://www.oasis-open.org/mlmanage=
/" rel=3D"noreferrer" target=3D"_blank">http://www.oasis-open.org/mlmanage/=
</a><br>
Or unsubscribe: <a href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a><br>
subscribe: <a href=3D"mailto:[email protected]" target=3D"_bl=
ank">[email protected]</a><br>
List archive: <a href=3D"http://lists.xml.org/archives/xml-dev/" rel=3D"nor=
eferrer" target=3D"_blank">http://lists.xml.org/archives/xml-dev/</a><br>
List Guidelines: <a href=3D"http://www.oasis-open.org/maillists/guidelines.=
php" rel=3D"noreferrer" target=3D"_blank">http://www.oasis-open.org/maillis=
ts/guidelines.php</a><br>
<br>
</blockquote></div><br></div>

--000000000000d1664d061b1fb8c5--