Please be patient. A big problem with development can be burnout. So I am trying to slow down things at the moment. The ideas are easy to sketch, but implementation can take
weeks. Here is the idea again in a nutshell: use ast.parse() and compile(). Or build directly an AST, not using the string detour as in ast.parse(). How long will it take to have a working solution? 11 years ago there was: Pyrolog: Prolog written in Python using PyPy's RPython tool chain https://www.reddit.com/r/prolog/comments/fbuz1/pyrolog_prolog_written_in_python_using_pypys/ RPython is a framework for implementing interpreters and virtual machines for programming languages, especially dynamic languages. https://rpython.readthedocs.io/en/latest/faq.html Currently I am not planning to use RPython, want to to use standard Python AST and compile(). Might have a look at RPython or similar stuff later. Mostowski Collapse schrieb am Sonntag, 19. September 2021 um 22:02:41 UTC+2: > Also I nowhere wrote that I would use doubly-linked list or > a set of objects. The trail is neither, its a single linked list. I > also refer directly to objects, I do not need the trail to refer > > to objects. The Prolog trail is only a logbook. The Prolog trail > has similarity to a database log: > > transaction journal, database log, binary log or audit **trail** > https://en.wikipedia.org/wiki/Transaction_log > > Do you say Python should not be used to implement > such things? In my opinion, Python has a high potential > to implement Prolog, because it has also ast.parse() > > and compile(). But I do not yet have a showcase that uses > these features of Python to compile Prolog. I dont work 24/7 > and I cannot clone myself. Currently the Prolog code is interpreted. > > I have a prototype where Prolog code is compiled into JavaScript, > but I did not yet try this approach with Python. Here you see how > JavaScript closures are generated, a first prototype: > > const alt4 = make_defined([new Clause(1, [0, 0], function( > display, actual, cont) {return(new Compound(".", [new Compound( > "==", [deref(actual.args[0]), "end_of_file"]), new Compound( > ".", [new Compound("$CUT", [deref(display[0])]), cont > ])]))}, 0, undefined), new Clause(1, [0, 0], function( > display, actual, cont) {return(new Compound(".", [new Compound( > "expand_include", [deref(actual.args[0]), deref(actual.args[1] > ), display[0] = new Variable()]), new Compound(".", > [new Compound("handle_term", [deref(display[0])]), new Compound( > ".", ["fail", cont])])]))}, -1, undefined)]); > > add("next_term", 1, new Clause(2, [0], function(display, actual, > cont) {return(new Compound(".", [new Compound("read_term", > [deref(actual.args[0]), display[0] = new Variable(), > new Compound(".", [new Compound("variable_names", [ > display[1] = new Variable()]), "[]"])]), new Compound( > ".", [new Compound(alt4, [deref(display[0]), deref( > display[1])]), cont])]))}, -1, undefined)); > > https://github.com/jburse/dogelog-moon/issues/184 > > Will do the same for Python in the next weeks. Then later this approach > will be combined with a few planned optimizations. So far got a 25% > speed increase for JavaScript with this new compilation scheme, but > > there is no official release out yet, that features this approach. And > there should be much more in it, also for Python. > Mostowski Collapse schrieb am Sonntag, 19. September 2021 um 21:46:20 UTC+2: > > sympy also builds a language on top of Python. > > pandas also builds a language on top of Python. > > > > Is there some pope that says this wouldn't be > > allowed, I dont think so, otherwise sympy, pandas, etc.. > > > > wouldn't exist. I dont understand your argument. > > > > Chris Angelico schrieb: > > > On Mon, Sep 20, 2021 at 3:19 AM Mostowski Collapse <janb...@fastmail.fm> > > > wrote: > > >> > > >> I am refering to: > > >> > > >> Greg Ewing schrieb: > > >> > where [w] is a weak reference object. Then you could periodically > > >> > scan the trail looking for dead weakref objects and remove the > > >> > corresponding [*] node from the list. > > >> > > > >> > You can also attach callbacks to weakref objects that are triggered > > >> > when the referenced object dies. You might be able to make use of > > >> > that to remove items from the trail instead of the periodic scanning. > > >> > > >> Question to Chris Angelico: If I stay with my > > >> sweep_trail(), which is the periodically scanning, > > >> I can use a single linked list. > > >> > > >> On the other hand if I would use the trigger > > >> from Python, I possibly would need a double linked > > >> list, to remove an element. > > >> > > >> Chris Angelico, is there a third option, that I have > > >> overlooked? Single linked list uses less space > > >> than double linked list, this why I go with scan. > > >> > > > > > > I don't know. I don't understand your code well enough to offer advice > > > like that, because *your code is too complicated* and not nearly clear > > > enough. > > > > > > But however it is that you're doing things, the best way is almost > > > always to directly refer to objects. Don't fiddle around with creating > > > your own concept of a doubly-linked list and a set of objects; just > > > refer directly to the objects. Let Python be Python, don't try to > > > build your own language on top of it. > > > > > > ChrisA > > > -- https://mail.python.org/mailman/listinfo/python-list