[p-dev] plasma talk
Paul Bone
paul at bone.id.au
Thu May 4 14:52:19 AEST 2017
On Thu, May 04, 2017 at 12:29:13PM +1000, Robert Smart wrote:
> Hi Paul,
>
> A good talk as always.
Thank you :D
> One point: You talk of adopting the common convention of [X] for a list of
> X. But experience shows that later on you may want to have some notation
> for a List of Types, even though a List of Types can't exist at run time.
> For example if you add tuples to the language then what is the type of the
> tuple (3,"xyz",5.4). It is natural for this to be Tuple[Int,String,Float]
> where Tuple is a compile time procedure that takes a list of Types and
> returns a type.
The compile time "list of types" doesn't need to have anything to do with
lists themselves.
I've used Haskell where [a] means a list of a, and Mercury where list(A)
means a list of A. I generally prefer the Haskell style, since it matches
with the syntax used in the (term) language itself (except that it doesn't
in Haskell because [] is the empty list, : is the cons list and [1, 2, 3] is
a list of 3 items, it's already inconsistent).
So I intend to adopt the more consistent Prolog syntax for lists. [] is the
empty list, [head | tail] is cons, and [1, 2, 3] is a list of 3 items. And
that the type of a list can be written as [a] (meaning a list of a).
However I also intend to go further and have a convenient syntax for
arrays and dictionaries. Arrays are [: 1, 2, 3 :] and their type is [:a:].
Dictionaries are {: :} or { }, I'm not yet sure how I'll separate fields
from values, eg = or : or => etc, and so on.
Tuples are an interesting thing, I'm working on a draft of their syntax at
the moment. But I don't call them tuples, and they're not really tuples,
they're more like ad-hoc anonymous types, because they can have fields.
I'll post something on the mailing lists when this is done. It'll probably
look like _(3, "xyz", 5.4) whose type could (not will) be
_(field1 : Int, field2 : String, field3 : Float)
Cheers.
--
Paul Bone
http://paul.bone.id.au
More information about the dev
mailing list