« Return to Thread: future hangs

Re: future hangs

by Dimitris Andreou :: Rate this Message:

Reply to Author | View in Thread

But the problem isn't the constructor, it's the class initialization.

2009/7/8 Marcus Downing <marcus@...>

Is removing Application sufficient? The idiom that Application embodies is
bound to happen again in other people's code. Shouldn't either the creation
or accessing of the future throw an exception, if called from within a
constructor?



Ricky Clarkson wrote:
>
> Yet again, "let's remove Application".
>
> 2009/7/8 Detering Dirk <Dirk.Detering@...>:
>> Nice subject ...
>>
>>> This simple application hangs at "println(s())". Apparently,
>>> the mistake is so simple that I cannot find it... what am I
>>> doing wrong? Defining getData and printing s() in the
>>> interactive scala shell works just fine. Thanks!
>>>
>>> object Test extends Application {
>>>
>>>     val s = future(getData("AAPL\n"))
>>>     val t = getData("INTC\n")
>>>     println(t) // that's fine
>>>     println(s()) // hangs here
>>
>> Well, the println(s()) will first wait for the result of s,
>> but -due to the definition of s- that doesn't come now, but
>> in future.
>>
>> Due to the functional aspect, this is true for every point in time.
>>
>> (I would recommend renaming the val s into val godot,
>> and then putting the println(godot()) into a method called
>> "mañana"...).
>>
>>
>> Ðet
>>
>>
>> PS: No, I'm NOT stressed, Mum!!!!
>>
>
>
>
> --
> Ricky Clarkson
> Java Programmer, AD Holdings
> +44 1565 770804
> Skype: ricky_clarkson
> Google Talk: ricky.clarkson@...
>
>

--
View this message in context: http://www.nabble.com/future-hangs-tp24383831p24390827.html
Sent from the Scala - User mailing list archive at Nabble.com.


 « Return to Thread: future hangs