saulpw / aipl

Array-Inspired Pipeline Language
MIT License
119 stars 7 forks source link

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

Closed dovinmu closed 1 year ago

dovinmu commented 1 year ago
!!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

dovinmu commented 1 year ago

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.

anjakefala commented 1 year ago

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.

anjakefala commented 1 year ago

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

This is a fun bug!

saulpw commented 1 year ago

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

saulpw commented 1 year ago

The order should be correct now!