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

Strongly typed containers?

Thread Next
Yuval Kogman
May 30, 2005 07:11
Strongly typed containers?
Message ID:
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 =; # 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 <> 0xEBD27418  perl hacker &
 /\  kung foo master: /me whallops greyface with a fnord: neeyah!!!!!!!

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About