[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is it time to remove dofile/loadfile? (was: Can a Lua module find out whether it is being required or dofiled?)
- From: Patrick Donnelly <batrick@...>
- Date: Fri, 25 Sep 2015 10:35:45 -0400
On Fri, Sep 25, 2015 at 1:46 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2015-09-25 4:20 GMT+02:00 Patrick Donnelly <batrick@batbytes.com>:
>> Since recently Lua has been trying to slim down (e.g. removing certain
>> math functions), perhaps it's time to remove dofile/loadfile, as they
>> can be trivially replaced with intuitive one-liners (using io.lines
>> features available since Lua 5.2):
>
> ALERT! Intuitive one-liner follows!
>
>> assert(load(io.lines(f, 4096), "@"..f))
>
> Careful here, Patrick! This list has in the past shown some
> inability to understand sarcasm!
Hmm, I wasn't trying to be sarcastic. :)
[I also noticed that unfortunately the loadfile one-liner isn't quite
right since it should not throw errors. Also, io.lines does not open
the file with the binary option...]
--
Patrick Donnelly