Newsgroups: comp.lang.dylan
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!hookup!swrinde!howland.reston.ans.net!ix.netcom.com!netcom.com!demars
From: demars@netcom.com (Dennis C. De Mars)
Subject: Re: Type Specifyer Question
Message-ID: <demarsD3745n.L39@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <D36Ht1.ECI@undergrad.math.uwaterloo.ca>
Date: Mon, 30 Jan 1995 01:58:35 GMT
Lines: 26

rjkroege@cappuccino.UWaterloo.CA (Rob Kroeger) writes:

>I'm wondering how to specify that an array should contain members of
>only one type.  The following slightly dopey example should give you 
>the idea:

>define class <transform-matrix> ( <object> )
>	slot whatever;
>	slot matrix :: <array>;
>end class

>Now matrix isn't just any array.  It's a 4 by 4 matrix of floats and I
>want to require that.  So how can I?

I believe that you can do this with a limited type. This is described in
"Dylan Design Note #6" but it is not in the interim manual for some reason
(maybe they hadn't finalized the syntax yet). Anyhow, the type you need
would be returned by the expression:

(limited <array> of: <float>)

There doesn't seem to be a way to constrain the dimensions of the array,
only the total size. You could define your own type that defines an
array with a particular set of dimensions, though.

- Dennis D.
