fjorton-0.1 ----------- description =========== The `fjorton` library is not so serious tool to extend the Python syntax with stack features inspired by the Forth language. By default the Python interpreter drops all the data that is not used in assignments or as function arguments:: c = 5 def f(a, b): ''' This function does almost nothing. The only result may be NameError, if <c> is not defined at the execution time. ''' a b c f(3, 4) The `@fjorton` decorator disassembles the function's bytecode using `byteplay` library and changes it so all such references store variables and objects into the hidden stack. And if the name referenced is callable, it will be called with the stack as the only positional argument. Statements `return` and `return None` are changed to return the stack instead:: from fjorton import fjorton def add(stack): stack.append(stack.pop() + stack.pop()) @fjorton def f(a, b): a b add print(f(2, 2)) # → [4] rationale ========= The library is written just for fun. No, seriously, you should not use it in production. It works yet only for Python2 (Python3 support may be implemented later), it screws the bytecode, it turns debugging into hell, it's not pythonic after all. The only reasons to use it may be just to have some fun or to troll colleagues (though that's a bit late for the 1st April joke, but maybe the next year?) links ===== GitHub: https://github.com/svinota/fjorton Docs: only readme for now … <P><A HREF="https://github.com/svinota/fjorton">Fjorton 0.1</A> — stack programming in Python. (06-Maj-16)</P>
participants (1)
-
Peter V. Saveliev