View Single Post
Old 10-08-2022, 05:00 AM   #6
un_pogaz
Chalut o/
un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.
 
un_pogaz's Avatar
 
Posts: 447
Karma: 678910
Join Date: Dec 2017
Device: Kobo
Quote:
Originally Posted by capink View Post
I think this would be more clear if illustrated with pseudo code.

Also, feedback from others would help crystallize this whole thing even more.
I agree. As for pydef it's clear, it's a locally defined function as it already exists in python.
But for the class... I have a hard time seeing how we go from that:
Code:
class x(object):
    def do_it(mi, locals_dict, a, b, ...)
        python code goes here
        the code must return a string or None
to this:
Code:
    python_functions['x'].do_it(mi, locals, a, b, c)


Quote:
Originally Posted by capink View Post
I was thinking about a completely seprate mode that would start with a keyword like python: as opposed to program:. But your idea has its merits because it allows mixing both modes.
Wow, that could be very powerful indeed. But it would be necessary to define its "main function" as well as its arguments, a bit like it is the case for template functions. This would allow to create "template function for single use".
Code:
python:
def main(mi):
    ...
    your python code
    ...
Note that since python accepts local definitions, we can all write in main()

...

Thinking about it, I'm not sure that python: is really useful if you add the pydef.

We just have to define:
Code:
program:
pydef __main__(mi) # start your python code
    ...
    your python code
    ...
fedyp # end your python code
main() # run your python code
And now we have our complete python implementation. We just have to define/documente that the function __main__(*args) <> main() are special functions where main() without arguments calls __main__(*args) with the arguments related to the book.

Last edited by un_pogaz; 10-08-2022 at 05:07 AM.
un_pogaz is offline   Reply With Quote