lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


However, I think the arg[0] 'trick' does not work with redirection:

lua: stdin:1: attempt to index global 'arg' (a nil value)
stack traceback:
       stdin:1: in main chunk
       [C]: in ?

----
My thoughts so far (based on what has been said by various people, not you -- so do not take this as a personal response):

Trying to keep things lean and slim is great (from a philosophical point of view) just as long as the end result still remains functional.

But what constitutes something functional?

One could argue that if I can write a function that emulates the needed behavior then this is functional, but is this enough to prevent the addition of some feature? Because if it is, one could argue then, that removing FOR and WHILE constructs for example (for the benefit of keeping things lean and slim) and emulating them with IFs and GOTOs is still functional, so why not do it?

Just the number of responses on this thread alone with the different proposed methods that some work partially or some not at all, to me at least, shows the need for built-in support for this.

Finally, a side note but on a similar philosophical point about what to add/remove from the math library, and all this talk about what functions should stay in or out, there is again (in my very subjective personal view, as always) a simple judge to decide. Take the cheapest scientific calc on the market today and see what it offers. That should be the minimum to include. Or else, you can't use Lua as calculator!!!

Thanks to all for listening.

-----Original Message----- From: steve donovan
Sent: Monday, April 07, 2014 12:52 PM
To: Lua mailing list
Subject: Re: Suggestion for Lua 5.3.0 -- require search paths

On Mon, Apr 7, 2014 at 11:46 AM, Chris Emerson
<chris-lua@mail.nosreme.org> wrote:
source, parse it/alter to get the path (possibly handling different filesystem types - Unix, case-insensitive Windows, etc.), in every Lua script. By its
nature, you can't just pop it into a module you require().

I haven't had any problems with pl.app.require_here

https://github.com/stevedonovan/Penlight/blob/master/lua/pl/app.lua#L26

which uses the arg[0] trick.  Just needs a single line to be added to
the designated "main script"

require 'pl.app'.require_here()
...'local requires'
...

Works on every platform I've tested on, but I'd appreciate if anyone
could find a hole in this scheme....