develooper Front page | perl.perl6.language | Postings from May 2005

Strongly typed containers?

Thread Next
From:
Yuval Kogman
Date:
May 30, 2005 07:11
Subject:
Strongly typed containers?
Message ID:
20050530141111.GA2847@woobling.org
We already have the Set class, how do we say what it contains?

class Set {
	has $.type;

	submethod BUILD {
		# get something into $.type, using 'of' handler
	}

	method members returns $.type () { ... }
}

my Set of Int $s = Set.new; # is this how you call it?

Or do we say

class Set is Container { # magical?
	method members returns returns ... # some facility by Container?
}

Even if the way to implement this is as thin as C++ templates, that
is, we'll have to define a container of some type, and define the
type as a complex thing, instead of defining a container of complex
things, it's still better than nothing.

This brings me to another issue - can I say what type the elements
of a list has, without putting it into a typed array?

-- 
 ()  Yuval Kogman <nothingmuch@woobling.org> 0xEBD27418  perl hacker &
 /\  kung foo master: /me whallops greyface with a fnord: neeyah!!!!!!!


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About