Yieldable require

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Yieldable require

Daurnimator
I encountered a situation where an asynchronous 'require' was desired;
here is a patch to allow require to yield:
https://github.com/lua/lua/compare/master...daurnimator:yieldable-require

Reply | Threaded
Open this post in threaded view
|

Re: Yieldable require

Pierre-Yves Gérardy
For Lua 5.1 and 5.2, https://github.com/pygy/require.lua does the same
in plain Lua, no patch required.

    require = require'require'.require

and you're ready to go

I haven't kept up with Lua 5.3 though, and I don't know if the
`require()` differs from v5.2.

if it doesn't replace the line above with (in Lua 5.3)

    require = require('require').require52


—Pierre-Yves


On Mon, May 15, 2017 at 4:13 PM, Daurnimator <[hidden email]> wrote:
> I encountered a situation where an asynchronous 'require' was desired;
> here is a patch to allow require to yield:
> https://github.com/lua/lua/compare/master...daurnimator:yieldable-require
>

Reply | Threaded
Open this post in threaded view
|

Re: Yieldable require

Daurnimator
On 19 May 2017 at 02:47, Pierre-Yves Gérardy <[hidden email]> wrote:

> For Lua 5.1 and 5.2, https://github.com/pygy/require.lua does the same
> in plain Lua, no patch required.
>
>     require = require'require'.require
>
> and you're ready to go
>
> I haven't kept up with Lua 5.3 though, and I don't know if the
> `require()` differs from v5.2.
>
> if it doesn't replace the line above with (in Lua 5.3)
>
>     require = require('require').require52
>
>
> —Pierre-Yves

Thanks for the link. Good to see someone has made it available for 5.1 and 5.2.

I wrote mine in C to echo the same thing I wrote in JS. See
https://github.com/fengari-lua/fengari/pull/51/files
But I'm also hoping that Roberto may consider adding something similar
in the next major lua release.

Reply | Threaded
Open this post in threaded view
|

Re: Yieldable require

Soni L.


On 2017-05-18 10:20 PM, Daurnimator wrote:

> On 19 May 2017 at 02:47, Pierre-Yves Gérardy <[hidden email]> wrote:
>> For Lua 5.1 and 5.2, https://github.com/pygy/require.lua does the same
>> in plain Lua, no patch required.
>>
>>      require = require'require'.require
>>
>> and you're ready to go
>>
>> I haven't kept up with Lua 5.3 though, and I don't know if the
>> `require()` differs from v5.2.
>>
>> if it doesn't replace the line above with (in Lua 5.3)
>>
>>      require = require('require').require52
>>
>>
>> —Pierre-Yves
> Thanks for the link. Good to see someone has made it available for 5.1 and 5.2.
>
> I wrote mine in C to echo the same thing I wrote in JS. See
> https://github.com/fengari-lua/fengari/pull/51/files
> But I'm also hoping that Roberto may consider adding something similar
> in the next major lua release.
>

I'd rather have yieldable string.gsub personally.

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.