> var five:Int=5;
> val i = new Cell (five);

I was using precisely that idiom until I realized that new
Cell[Int](5) also worked; is there a known limitation to that
workaround that I haven't hit yet?

 - Rob

On Wed, Feb 9, 2011 at 9:41 AM, Vijay Saraswat <vi...@saraswat.org> wrote:
> On 2/8/2011 7:56 AM, Robert J. Simmons wrote:
>> Casting doesn't seem to interact with type inference in the way I'd
>> expect it to. I am allowed to write this:
>>
>> public class Foo { val i = new Cell(5); }
>>
>> However, this is probably not what I want, though, because the type of
>> i is Cell[Int{self==5}], not Cell[Int]. This, on the other hand, does
>> what I expect (defining a static type IntCell = Cell[Int] also works).
>>
>> public class Foo { val i = new Cell[Int](5); }
>>
>> What confuses me is that I'm also unable to cast an Int{self == 5} to
>> an Int to get the same result:
>>
>> // Same as the first example, not the second; i has type Cell[Int{self==5}].
>> public class Foo { val i = new Cell(5 as Int); }
>>
>> Is this a bug, or is this the expected behavior for a reason I do not
>> understand?
>>
> Hi Robert --
>
> Correct. In SVN head and recent prior releases, e as T adds the clause
> T{self==x} if e can be established to be an immutable variable x.
>
> This is not turning out as well as I thought, mainly for the issue you
> raise. So likely this will be changed shortly so that casting e as T
> will yield an expression of type T.
>
> There is some thought to having an (e has T) where the type remains the
> static type S of e, but a check is made that S <: T.
>
> In the meantime you can work around this with the very ugly idiom:
>
> var five:Int=5;
> val i = new Cell (five);
>
> Best,
> Vijay
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>



-- 
Robert J. Simmons
simrob.com
gps.simrob.com
rjsim...@cs.cmu.edu
robsimm...@gmail.com
Cell: 404-273-6890

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to