Better HN
topnewbestaskshowjobs
Log inSign up

throw_again99

5 karma · joined Dec 15, 2016 (9y ago) · 2 submissions

Submissions

comment 9y ago · link · parent

This is rather nice. You get a lot of convenience for that one type annotation!

comment 9y ago · link · parent

Hi, thanks. Primarily I wondered about actual mixing of ADTs and objects, which is limited even in OCaml, see e.g.:

http://caml.inria.fr/pub/ml-archives/caml-list/2003/06/bed28...

But does Pyret always translate an ADT to a class hierarchy behind the scenes? This example sure looks like it does:

  data Animal:
    | elephant(name, weight)
    | tiger(name, stripes)
    | horse(name, races-won)
    ...
  end

  fun animal-name(a :: Animal):
    a.name
  end