saulpw/aipl

should python fns / vars be in scope for AIPL ops?

Closed this issue · 5 comments

!!python
@defop('test', 0, 0)
def myfun(aipl, v:str) -> str:
    return 'hi'

!format>myfun
hello

!format
{myfun}
!print

Result:
<function myfun at 0x105d08540>

I think I'd say probably yes, though I'd think that maybe myfun should be overwritten by the !format

I discovered this when I realized that my @ defop function names were preventing me from writing to an AIPL column with the same name. Not sure I'd ever want those function names to be in scope for AIPL, because I just want the op command.

In the initial case !! put it in the global scope, which I believe takes priority over the table-scope. Maybe we want to switch those around.

@ defop function names were preventing me from writing to an AIPL column with the same name

This is a fun bug!

saulpw commented

Ah, yes, we do want to switch those around. I always think the ChainMap list is in reverse order.

saulpw commented

The order should be correct now!