Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

result of heterogeneous union

0 views
Skip to first unread message

Marshall Spight

unread,
Aug 31, 2003, 12:45:34 PM8/31/03
to
Hi all,

Suppose there exists a system that supports a type system
that includes union types, such as (int|string). Now
suppose one had two sets, the first a set of type int,
the second a set of type string. Set1 has exactly one
member = 1. Set 2 has exacly one member="hello".

What should be the result type of a union of the two tables?
Specifically, what is the type of the resulting set?

1. None; this causes a type error
2. (int|string)
3. Most specific supertype of int and string. (Possibly 'alpha'.)
4. alpha, the maximal supertype.

Of the choices, 2 and 3 seem the best, but I am unable to come
up wit a basis for choosing among the choices. Alternatively,
I could imagine making the choice between 2 and 3 (or even
1) an option somehow.

Your thoughts, please?


Marshall


Antti-Juhani Kaijanaho

unread,
Aug 31, 2003, 1:00:09 PM8/31/03
to
In article <OCp4b.314780$o%2.142913@sccrnsc02>, Marshall Spight wrote:
> Specifically, what is the type of the resulting set?
> 2. (int|string)
> 3. Most specific supertype of int and string. (Possibly 'alpha'.)

I probably would go for 2, probably with a twist where 2 is a subtype of 3.

--
Antti-Juhani Kaijanaho http://www.kaijanaho.info/antti-juhani/

Julkinen päiväkirja - http://kaijanaho.info/antti-juhani/diary/
Toys - http://www.cc.jyu.fi/yhd/toys/

Tim Sweeney

unread,
Aug 31, 2003, 9:35:31 PM8/31/03
to
> What should be the result type of a union of the two tables?
> Specifically, what is the type of the resulting set?
>
> 1. None; this causes a type error
> 2. (int|string)
> 3. Most specific supertype of int and string. (Possibly 'alpha'.)
> 4. alpha, the maximal supertype.

This depends on your type system.

In a type system like that of C++, this sort of typing scenario isn't
expressible.

In a C# style language with boxing, you could best say union(t,u)=the
most specific type that is a supertype of both t and u. Thus
union(int,string)=object.

To translate that most simply to Java, you would need to avoid basic
types like int, and only take unions of class type. So you might say
union(Int,String)=Object, though it's not quite possible to express
this in Java directly, even with the long-awaited generic type
extensions.

In the functional programming world, if you start with a simply-typed
language without subtyping, then add unions (and the resulting subtype
relations) in the obvious way, union(string,int) would be a supertype
of both int and string but of no other types besides subtypes of int
and string. This seems the cleanest approach which doesn't rely on
higher-order typing constructs. Here, you would most naturally have
union(set(t),set(u))=set(union(t,u)).

However, it's possible to be even more precise. In a type system like
McAllester's Ontic language (see
http://www.autoreason.com/ontic-spec.ps), you could say that, for any
value a, the type of a is just "the-set-of-all a", and never have
ambiguity in questions of "what is the type of this expression in this
context?" This approach is far outside of existing programming
language practice, but I recommend reading the paper, just to see
what's possible at one far extreme of the design space.

Marshall Spight

unread,
Sep 1, 2003, 4:52:49 PM9/1/03
to
"Tim Sweeney" <t...@epicgames.com> wrote in message news:9ef8dc7.03083...@posting.google.com...

>
> However, it's possible to be even more precise. In a type system like
> McAllester's Ontic language (see
> http://www.autoreason.com/ontic-spec.ps), you could say that, for any
> value a, the type of a is just "the-set-of-all a", and never have
> ambiguity in questions of "what is the type of this expression in this
> context?" This approach is far outside of existing programming
> language practice, but I recommend reading the paper, just to see
> what's possible at one far extreme of the design space.

I'm *very* interested to read this paper, so I downloaded it, and also
searched for more references. I didn't find too much; the first hit
on google was for a submission to the excellent Lambda the Ultimate
weblog by one Tim Sweeney. Sadly it did not spur much discussion.

Unfortunately, when I try to convert this file into anything I can view
or print (pdf, say) the fonts turn to mush. I could probably read it
anyway if I was 15 years younger, but not with the eyes I have now.

I know it's totally off-topic, but mightn't anyone have any idea how
to convert that .ps file into something with readable fonts? (Alternatively,
if you know how I can become 15 years younger, that would also
get a big "thank you.")

Does this idea of "nondeterminism" have anything to do with
constraint-based programming languages, such as Mozart?


Marshall


Aaron Denney

unread,
Sep 2, 2003, 2:45:17 PM9/2/03
to
In article <BkO4b.148664$2x.4...@rwcrnsc52.ops.asp.att.net>, Marshall Spight wrote:
>> http://www.autoreason.com/ontic-spec.ps), you could say that, for any
>
> Unfortunately, when I try to convert this file into anything I can view
> or print (pdf, say) the fonts turn to mush. I could probably read it
> anyway if I was 15 years younger, but not with the eyes I have now.
>
> I know it's totally off-topic, but mightn't anyone have any idea how
> to convert that .ps file into something with readable fonts? (Alternatively,
> if you know how I can become 15 years younger, that would also
> get a big "thank you.")

I'm slightly boggled; for me, postscript is much easier to print and
slightly easier to view, since any decent printer accepts postscript,
and its age means more tools are available to work with it.

Since it's not easier for you, I'm assuming you're using windows. You
want to get "gsview", although Adobe's Acrobat Distiller should also
work, for a price.

http://www.cs.wisc.edu/~ghost/gsview/

--
Aaron Denney
-><-

Tim Sweeney

unread,
Sep 2, 2003, 9:52:05 PM9/2/03
to
> > However, it's possible to be even more precise. In a type system like
> > McAllester's Ontic language (see
> > http://www.autoreason.com/ontic-spec.ps), you could say that, for any
> > value a, the type of a is just "the-set-of-all a", and never have
> > ambiguity in questions of "what is the type of this expression in this
> > context?" This approach is far outside of existing programming
> > language practice, but I recommend reading the paper, just to see
> > what's possible at one far extreme of the design space.
>
> I'm *very* interested to read this paper, so I downloaded it, and also
> searched for more references. I didn't find too much; the first hit
> on google was for a submission to the excellent Lambda the Ultimate
> weblog by one Tim Sweeney. Sadly it did not spur much discussion.

Someday I think it will be recognized as one of the most important
ideas in programming language foundations, aside Church's lambda
calculus and the Curry-Howard isomorphism. Admittedly nobody else
including the author seems to share this view.

> Unfortunately, when I try to convert this file into anything I can view
> or print (pdf, say) the fonts turn to mush. I could probably read it
> anyway if I was 15 years younger, but not with the eyes I have now.
>
> I know it's totally off-topic, but mightn't anyone have any idea how
> to convert that .ps file into something with readable fonts? (Alternatively,
> if you know how I can become 15 years younger, that would also
> get a big "thank you.")

For reading and printing .ps files, try GhostScript and GSView, from:
http://www.cs.wisc.edu/~ghost/

> Does this idea of "nondeterminism" have anything to do with
> constraint-based programming languages, such as Mozart?

Yes, in fact I think the Ontic style (though not necessarily syntax)
provides a far more expressive framework for constraint-based
languages than existing practice.

The important thing in understanding Ontic, and perhaps the reason it
hasn't become widely-known, is that its use of the word
non-determinism doesn't imply an unpredictable outcome, but merely
that a term may have multiple values (in the same order-independent
and unique-up-to-equality way that a set may contain multiple values),
and that sharing is handled properly in the presence of
multivaluedness. In other words, a term like {x:=3|4,y:=x+1} is
equivalant to {3,4}|{4,5} and does not include the value {4,4}.

Marshall Spight

unread,
Sep 4, 2003, 1:38:45 AM9/4/03
to
"Aaron Denney" <wno...@ugcs.caltech.edu> wrote in message news:slrnbl9p9t...@ofb.net...

> In article <BkO4b.148664$2x.4...@rwcrnsc52.ops.asp.att.net>, Marshall Spight wrote:
> >> http://www.autoreason.com/ontic-spec.ps), you could say that, for any
> >
> > Unfortunately, when I try to convert this file into anything I can view
> > or print (pdf, say) the fonts turn to mush. I could probably read it
> > anyway if I was 15 years younger, but not with the eyes I have now.
> >
> > I know it's totally off-topic, but mightn't anyone have any idea how
> > to convert that .ps file into something with readable fonts? (Alternatively,
> > if you know how I can become 15 years younger, that would also
> > get a big "thank you.")
>
> I'm slightly boggled; for me, postscript is much easier to print and
> slightly easier to view, since any decent printer accepts postscript,
> and its age means more tools are available to work with it.

We run in different circles. Postscript is the hardest of all the formats
I come across to do anything with. Nothing opens it natively; it's
uneditable (same as PDF; thanks Adobe) and breaks easily. The
tools for it are *terrible* by Windows or Mac standards. The fonts
are always jaggy to the point that I wont even bother with a paper
that's only available in postscript unless I really, really want to read
it, as I do for this one.

In rare cases I'll just print it out because then the jagginess is less of
an issue.


> Since it's not easier for you, I'm assuming you're using windows. You
> want to get "gsview", although Adobe's Acrobat Distiller should also
> work, for a price.

I already had distiller, and it gave me the usual pdf where the fonts
look like you could cut yourself on them. On the off chance that
gsview would do better, I went and installed the cygwin gsview.
Unfortunately, I wasn't paying attention as I do with a regular
cygwin install, and I got a new cygipc which broke my database
installation. It took me about 4 hours of chmod, chown, chgrp,
etc. to get to the point where I could run my database well enough
to do a backup, so I could then delete the data directory and
reinit the database. A number of things are still broken, but
at least the database is mostly working now.

All I can say is, it had *better* be as significant as Church! :-)


Marshall


Christian Szegedy

unread,
Sep 4, 2003, 6:30:14 AM9/4/03
to
Marshall Spight wrote:

> "Aaron Denney" <wno...@ugcs.caltech.edu> wrote in message news:slrnbl9p9t...@ofb.net...
>

> We run in different circles. Postscript is the hardest of all the formats
> I come across to do anything with. Nothing opens it natively; it's
> uneditable (same as PDF; thanks Adobe) and breaks easily. The
> tools for it are *terrible* by Windows or Mac standards. The fonts
> are always jaggy to the point that I wont even bother with a paper
> that's only available in postscript unless I really, really want to read
> it, as I do for this one.
>

It is complete nonsense. PS is well defined, it is human readable and
editable. (I have even generated ps files by hand and scripts).

The quality of the viewer programs is not state of the art, but
if you print a document, you won't notice any difference
to a document originally in pdf format.

A lot of published books were once postscript files.

Best Regards, Christian

Joachim Durchholz

unread,
Sep 4, 2003, 7:54:05 AM9/4/03
to
Christian Szegedy wrote:
> It is complete nonsense. PS is well defined, it is human readable and
> editable. (I have even generated ps files by hand and scripts).

Program-generated PS usually isn't readable.
Unless you know the "usual conventions" very, very well.
In other words: there are no WYSIWYG editors for it.

Besides, PS has hairy issues with paper size (unless a revision of the
language changed that in the last three years).
PDF got at least that one right.

> The quality of the viewer programs is not state of the art, but
> if you print a document, you won't notice any difference
> to a document originally in pdf format.

In theory, yes.
In practice, even printed documents look horrible. In most cases, the
kerning is totally off, bold and italic print are difficult to read, and
(worst of it all) not all the needed fonts are embedded.
None of these problems are intrinsic to PostScript, but most PS
documents have these problems.

> A lot of published books were once postscript files.

Of course - but these postscript files are printed in the same
environment in which they were created. If the environment doesn't match
well enough, it's made to match.
Postscript files sent over the net are usually not self-contained. And
that makes them a pain to use, unless you happen to have all the same
fonts installed.

Regards,
Jo

Marshall Spight

unread,
Sep 4, 2003, 12:05:14 PM9/4/03
to
"Christian Szegedy" <sze...@nospam.or.uni-bonn.de> wrote in message news:bj70uv$103c$1...@f1node01.rhrz.uni-bonn.de...

> Marshall Spight wrote:
>
> > We run in different circles. Postscript is the hardest of all the formats
> > I come across to do anything with. Nothing opens it natively; it's
> > uneditable (same as PDF; thanks Adobe) and breaks easily. The
> > tools for it are *terrible* by Windows or Mac standards. The fonts
> > are always jaggy to the point that I wont even bother with a paper
> > that's only available in postscript unless I really, really want to read
> > it, as I do for this one.
> >
>
> It is complete nonsense.

I am happy to hear that PS works well for your needs,
but for me, it's pretty well unusable.


> PS is well defined,

True.

> it is human readable and editable. (I have
> even generated ps files by hand and scripts).

Sure, if I want to spend the time to learn to read and
write .ps, which I don't. If I have some spare time, I'm
going to spend it learning Haskell.


> The quality of the viewer programs is not state of the art, but
> if you print a document, you won't notice any difference
> to a document originally in pdf format.

But I don't *want* to print documents; I want to *read* them.
For that, I need an onscreen viewer. And all the ways I know
of to get .ps on-screen have font rendering that is pathetic.
(Actually, even if I print them, I still have trouble reading
them, because academic papers typically use small fonts.)


Marshall


Nick Name

unread,
Sep 4, 2003, 4:59:09 PM9/4/03
to
Marshall Spight wrote:

> For that, I need an onscreen viewer. And all the ways I know
> of to get .ps on-screen have font rendering that is pathetic.

I don't know if you have already tried, and it's off topic here, but gv
rendering with antialias is superb under X11.

V.

Aaron Denney

unread,
Sep 4, 2003, 7:04:05 PM9/4/03
to
In article <FdA5b.347801$Ho3.51987@sccrnsc03>, Marshall Spight wrote:
> We run in different circles. Postscript is the hardest of all the
> formats I come across to do anything with. Nothing opens it natively;

Windows tools problem.

> it's uneditable (same as PDF; thanks Adobe)

In general, yes. I can see how it would be annoying in certain usage
patterns. There are a set of baroque conventions that make it somewhat
better, for programatic output, sort of like X's ICCCM. Hand-written
is often clear enough to edit by hand, while being difficult to
manipulate programatically.

> and breaks easily. The
> tools for it are *terrible* by Windows or Mac standards.

The tools available on Windows and Macs, of course.

> The fonts are always jaggy to the point that I wont even bother with a

Fonts can be an issue, but I have much more problem with PDFs with
missing fonts than PostScript files. It really sounds as if you don't
have fonts installed that you should. Being able to leave out a specific
default set of fonts does save a lot of space, but I do wonder if
it was the right tradeoff for shipping documents around. I'd say it
definitely is the right choice for a direct printer connection.

> On the off chance that
> gsview would do better, I went and installed the cygwin gsview.
> Unfortunately, I wasn't paying attention as I do with a regular
> cygwin install, and I got a new cygipc which broke my database
> installation. It took me about 4 hours of chmod, chown, chgrp,
> etc. to get to the point where I could run my database well enough
> to do a backup, so I could then delete the data directory and
> reinit the database. A number of things are still broken, but
> at least the database is mostly working now.

Eek. Sorry to hear that. I bet the standalone would have been
significantly easier.

To drag this back on topic, everyone does know that postscript is
a full-blown language, right? There have been at least two raytracers
implemented in postscript, one fairly straight-forward, and another
significantly obfuscated and compressed. Googling should be able
to find either fairly quickly. "Great" way to compress images in
papers. Just be sure to give the printer enough time...

John Atwood

unread,
Sep 4, 2003, 9:06:28 PM9/4/03
to

You might try ps2pdf, but I've had mixed success with that under windows,
depending on the fonts in the doc and the fonts installed on the machine;
I've gotten into the habit of ps2pdf'ing on linux, and reading under
windows.

John

Karl M Syring

unread,
Sep 5, 2003, 7:24:17 AM9/5/03
to

In most cases, the problem is caused by exotic fonts that are not
embedded in the document. There is a script called pkfix on the CTAN
archives that can fix the postscript file by replacing the fonts used.
You need TeX, gs and Perl installed on your machine.
(see http://www.tex.ac.uk/cgi-bin/texfaq2html?label=pkfix)

Karrl M. Syring

0 new messages