On Tue, 2 Jun 2015, Brad Chamberlain wrote:

> I believe this ought to work and am _slightly_ surprised it does not. That 
> said, as I've mentioned on another thread recently, our wildcard formal 
> argument pattern matching support is a bit piecemeal at present and needs to 
> be beefed up, so I'd guess that's what you're hitting.  A wildcard-free way 
> to handle this case _may_ be (sorry I don't have time to test):
>
>       proc testOfTuple(b ...): real(numBits(b(3).type))
>
> Ugly, though...  For this reason, I might tend to use the more type-inferred 
> version and create 'chpldoc' comments to describe what's expected (but there 
> are good reasons to want the more explicitly typed form as well, so I'm not 
> suggesting that's a solution for all cases).

As you suggest, ....

proc testOfTuple(t) : real(numBits(t(3).type))
{
        param w = numBits(t(3).type); // inherit type from numBits
        var s, e : int(16);
        var m : int(w);

        (s, e, m) = t;

        return (e * m):real(w);
}

writeln(testOfTuple((0:int(16), 10:int(16), 15:int(32))))

It works.

That will do me for now.

- Damian

Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer

------------------------------------------------------------------------------
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to