Hi everyone, I'm trying to discover a way to load Fennel functions into
a REPL which reference global symbols provided only at runtime. For
example, the built-in functions provided by the TIC-80 environment.
Currently, if you try to load a Fennel function 'A' which calls a TIC-80
function 'B', the compiler will complain that 'B' is nowhere to be seen,
and thus 'A' can't be loaded.
While that's normally desirable behaviour, it would be convenient if
there were a way to tell the compiler to "trust me" or otherwise
overlook the issue. At the moment, the following ideas come to mind:
1. Invoke some incantation involving _G.
2. Mock out a second file that contains all the TIC-80 functions I want
as stubs, import that during development, but ignore it at runtime
(using a macro somehow?).
3. Implement a more explicit mechanism for "symbol trust".
Cheers, please let me know your thoughts.
Colin
Colin Woodbury <colin@fosskers.ca> writes:
> Hi everyone, I'm trying to discover a way to load Fennel functions> into a REPL which reference global symbols provided only at> runtime. For example, the built-in functions provided by the TIC-80> environment. Currently, if you try to load a Fennel function 'A' which> calls a TIC-80 function 'B', the compiler will complain that 'B' is> nowhere to be seen, and thus 'A' can't be loaded.>> While that's normally desirable behaviour, it would be convenient if> there were a way to tell the compiler to "trust me" or otherwise> overlook the issue.
If you just to disable all globals checking for a given repl session you
can use this flag when launching the repl: --globals "*"
If you just want to allow globals which are actually part of TIC-80, you
could add them to the --globals list when starting up the repl, but
that's going to be a very long list leading to an awkward repl
invocation. To do it after the repl loads you'd have to call the
`global` special which adds it to the allowlist. Maybe create a file with:
(global (line btnp btn ...) nil)
But you'd have to construct that form yourself.
Hope that makes sense.
-Phil
On 8/29/23 00:50, Phil Hagelberg wrote:
> If you just to disable all globals checking for a given repl session you> can use this flag when launching the repl: --globals "*"> > If you just want to allow globals which are actually part of TIC-80, you> could add them to the --globals list when starting up the repl, but> that's going to be a very long list leading to an awkward repl> invocation. To do it after the repl loads you'd have to call the> `global` special which adds it to the allowlist. Maybe create a file with:> > (global (line btnp btn ...) nil)> > But you'd have to construct that form yourself.> > Hope that makes sense.> > -Phil
Thanks Phil I'll play around with these options.