~technomancy/fennel

2 2

How can missing global symbols be handled in certain environments?

Details
Message ID
<a095a4c4-85bb-4bec-af92-8219001af66d@fosskers.ca>
DKIM signature
pass
Download raw message
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
Details
Message ID
<87y1hvxiuk.fsf@hagelb.org>
In-Reply-To
<a095a4c4-85bb-4bec-af92-8219001af66d@fosskers.ca> (view parent)
DKIM signature
pass
Download raw message
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
Details
Message ID
<1fe383aa-5c59-4ad6-b9cf-a88a7139a088@fosskers.ca>
In-Reply-To
<87y1hvxiuk.fsf@hagelb.org> (view parent)
DKIM signature
pass
Download raw message
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.
Reply to thread Export thread (mbox)