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

Re: Adding linear interpolation to an array

Thread Previous | Thread Next
Thomas Sandlaß
March 8, 2005 01:19
Re: Adding linear interpolation to an array
Message ID:
Dave Whipp wrote:
> I don't see why I need the conditional there. If I'm going to copy the 
> array, I might as well declare up front the that darget does 
> LinearInterpolation:
> sub foo (Num @raw_in)
> {
>    my Num @in does LinearInterpolation = @raw_in;
>    ...
> }

This depends on how initialization works. For the above to work
the 'Array of Num does LinearInterpolation' needs a constructor
that takes a plain 'Array of Num' as parameter. I think that exists
but Aldo just wanted to avoid the dought.

> Or perhaps even
> sub foo (Num @in is copy does LinearInterpolation)
> {
>    ...
> }

This is my big questionmark on roles: is the above a contraint
or merely a directive. In the former case only Arrays of Num that
do LinearInterpolation are allowed, in the latter case every
Array of Num that is used as argument gets the role attached while
it lingers in foo. I just realized there's a trait_auxiliary:shall
mentioned in A12 which I've not seen in action somewhere. This could
be the second meaning and roles in signatures describe what is *done*
to the arguments not what they shall be able to do.

I still wonder how the type system really works...
TSa (Thomas Sandlaß)

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