So I've been busy trying to tidy up mumble lang. Making some progress I suppose.
As part of that I recently tried to split the project up into multiple files.
One class per file. Logical I thought. But hell no! Once you start importing the other files
you need you rapidly run into 'circular imports', and python says 'fuck you'.
Maybe there is a nice way to keep separate classes in separate files, and avoid circular imports, but Dr Google didn't help.
OK, fine I thought. Some of these classes are logically similar, so just merge them in to larger files, which did reduce the problem.
So I now have:
objects.py with kets, superpositions, sequences, stored_rules, memoizing_rules
sigmoids.py with a bunch of sigmoids
context.py with NewContext and ContextList
processor.py with parsing/compiling code.
functions.py with our function operators.
console.py with our console interface to mumble lang.
But fuck me again! It still doesn't work.
Well, NewContext.load('sw-file') needs a function from the processor to parse and load a sw file, while processer.py needs ContextList from context.py. So circular reference again.
How do I fix?
thought 1) merge context.py and processor.py into one file. I find that a little unpleasant. They are mostly unrelated, but my code is ugly and hackish, so maybe it doesn't matter?
thought 2) somehow make context = ContextList('the context') a global, so processor.py doesn't need to import context.py. Would that work?
thought 2b) somehow make processor.py independent of context. I don't know how though ....
Also, I may run into further trouble, since processor.py needs access to the classes in objects.py, and stored_rules and memoizing_rules need access to extract_compound_sequence() from processor.py. Is my only option to merge objects.py, context.py and processor.py into one mega file?
It doesn't help its been 40C here for a few days, and I haven't been sleeping well. Thankfully it is cooler today.
Like I said, I fail at python....