[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: implementing a future in lua
- From: "V S P" <toreason@...>
- Date: Tue, 30 Dec 2008 02:20:57 -0500
hi,
'Future' construct from Java 5 is similar (but in my opinion inferior)
to 'Deferred' construct in say Python Twisted... If this is where
you are deriving the project from.
My undestanding is that it is particulary used for Asynchronious
communcations.
That is: 'submit' a call, get an immediate return and then when the call
really completes, have the system invoke your callback function.
For that to expose the 'parallelism' there has to be a 'none-blocking
I/O'
API somwhere on the OS level (or a database access done in asynch
manner) --
and none of those are readily available to Lua (but I may be wrong
here).
If it is not to be used for async communications, then
why would that already work with typical callback functions that
lua already supports?
On Tue, 30 Dec 2008 15:07:16 +0800, "李慧霸"
<magazine.lihuiba@163.com> said:
> Hi,
>
> I'm doing research on language constructs. And I'm going
> to implement a Future mechanism in lua (taking lua as a
> testbed). The Future mechanism can be introduced as:
>
> "The construct (future X) immediately returns a future for
> the value of the expression X and concurrently begins evaluating
> X. When the evaluation of X yields a value, that value replaces
> the future. The future is said to be initially undetermined; it
> becomes determined when its value has been computed. An operation
> (such as addition) that needs to know the value of an undetermined
> future will be suspended until the future becomes determined, but
> many operations, such as assignment and parameter passing, do not
> need to know anything about the values of their operands and may
> be performed quite comfortably on undetermined futures. The use of
> futures often exposes surprisingly large amounts of parallelism in
> a program…"
>
> As I'm only a beginer of lua and I'm not familiar with its VM
> implementation, can anyone here give me some advice? Thank you!
> I have read some documents and the source code, and will begin writing.
>
>
> And I wonder whether is there an interest of adding this feature to
> lua. There seems to be little modification to the language itself,
> all that is needed to do lies in the VM and library routines only. So
> the future construt is not likely to break existing code.
>
> --------------
> lihuiba
> 2008-12-27
--
V S P
toreason@fastmail.fm
--
http://www.fastmail.fm - One of many happy users:
http://www.fastmail.fm/docs/quotes.html