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."

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

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 10:40 am
Powered by Dreamwidth Studios