Change the way that foreign import "string"
works
#47
Labels
improvement
Improves the way that an existing feature works, in a backwards-compatible way.
Milestone
Instead of passing the string to
require
without any processing, we should:huck
foreign import path/init.lua
, check each of the given Lua files to see if the end of their filepath matches the given path afterforeign import
loadfile
(?) in the generated codeQuestions:
loadfile
, there's no way to import a Lua module written in C. This is a significant loss.package.path
orpackage.cpath
as appropriate, including compiled Huck modules; and just give the module name torequire
everywhere. That is, for a Lua module from filefoobar.lua
, the module name isfoobar
; for a module compiled frombaz.c
, the module name isbaz
; and for a Huck module, the module name is defined at the top of its source, e.g.module Quux;
has module nameQuux
. Thus, ifrequire
is given the module namerequire("Quux")
, then it should find the compiled Huckmodule Quux;
.require("Foo.Bar")
to search for a Huckmodule Foo.Bar;
will look in the filepathsFoo/Bar.lua
andFoo/Bar/init.lua
by default. This will have to be expected as default behaviour, and should be documented so that environments with differentsearchers
can adjust accordingly.require
, instead ofloadfile
?After the above thoughts, closing in favour of #48.
The text was updated successfully, but these errors were encountered: