tiedyedave: (Default)
[personal profile] tiedyedave
From Pierce's Types and Programming Languages:

"There are three rules for type casts: in an upcast the subject is a subclass of the target, in a downcast the target is a subclass of the subject, and in a stupid cast the target is unrelated to the subject."

Date: 2004-10-11 12:21 am (UTC)
From: [identity profile] rjmccall.livejournal.com
To the Honored Fathermaster David Wilson Kitchin IV:

Suppose a functional language were to replace concrete types with signatures, so that "int" would simply be a signature with a standard presumed implementation using machine integers. Is there any use for subtyping in such a language?

I also wonder how such a language might express tagged sums (which would presumably still be useful for structure implementation)?

Your disciplined discipline,
J.

special guest replier!

Date: 2004-10-11 06:30 am (UTC)
From: [identity profile] adamch.livejournal.com
You can encode Everything in untyped lambda calculus, and so you can encode Everything with "objects" where each has one method (an 'apply' method). The idea is to encode any object as a function analogous to an elimination rule of a type system. So, for example, a sum can be represented as a function that takes two arguments. Each is a function that takes the value carried by one of the branches of the sum and does what it pleases with it. The value for the sum runs its first argument if it inhabits the left branch and its second argument if it inhabits the right branch.

As for the use of subtyping, I personally wouldn't want to have it, but there are standard treatments of subtyping for lambda calculus.

Re: special guest replier!

Date: 2004-10-11 07:57 am (UTC)
From: [identity profile] rjmccall.livejournal.com
I, too, have studied lambda calculus in the past; the challenge was not to embed sum types in the implementation (which would probably not run on the untyped lambda calculus) but to find an adequate signaturing mechanism for sum types, such that they could still be computably case-analyzed.

Re: special guest replier!

Date: 2004-10-11 08:02 am (UTC)
From: [identity profile] adamch.livejournal.com
For the type (T + U), the signature can be:

method case : forall V, (T -> V) -> (U -> V) -> V

Re: special guest replier!

Date: 2004-10-11 10:12 am (UTC)
From: [identity profile] rjmccall.livejournal.com
That's not bad; I hadn't considered making case part of the signature, but it's clearly the sensible move. Maybe a record type instead of a curried list, since ordering is a bit arbitrary -- so, in SML syntax:

datatype foo = bar of X | baz of Y
val case: { bar: X -> 'a, baz: Y -> 'a } -> foo -> 'a

Date: 2004-10-11 06:26 am (UTC)
From: [identity profile] mtolan.livejournal.com
That, sir, is a poor defintion.
One could characterize all stupid casts in java as an upcast to java.lang.Object, followed by a the relevant downcast. This would make it possible to eliminate all stupid casts in java, which is clearly a contradiction.
Proof by Contradiction.

Date: 2004-10-11 07:49 am (UTC)
From: [identity profile] rjmccall.livejournal.com
Nope. No amount of object casting will make, say, (float) ThomasPyncheon any less stupid.

Date: 2004-10-11 09:05 am (UTC)
ikeepaleopard: (Default)
From: [personal profile] ikeepaleopard
IEEE Thomas Pynchon, author of The Crying of Lot 49.00000001247?

Date: 2004-10-11 09:58 am (UTC)
From: [identity profile] rjmccall.livejournal.com
"d(God,Chance)< 2-149"
-- IEEE Thomas Pynchon

Date: 2004-10-13 03:59 pm (UTC)
From: [identity profile] gustavolacerda.livejournal.com
Thanks for reminding me! I just reached and grabbed this book without getting up from my chair. Which I really should do, since I'm finally doing a class on type theory, lambda calculus, etc.. and now I guess I have a better chance of understanding it.

Date: 2004-10-14 12:58 am (UTC)
From: [identity profile] gustavolacerda.livejournal.com
Indeed, we never met, AFAIK.

Profile

tiedyedave: (Default)
tiedyedave

April 2017

S M T W T F S
      1
2345678
9101112131415
1617 1819202122
23242526272829
30      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 26th, 2026 08:12 am
Powered by Dreamwidth Studios