3.00
9 comments
Created by mumble 3 months, 1 week ago
[ 3.00 | 0.00 ] [#2997]

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.
Why?
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....

-mumble


[ Reply ]

1.00
Created by kr5dit 3 months, 1 week ago
[ 1.00 | 0.00 ] [#14070]

If you have circular dependencies between two modules it means there's a third 'base' module that you should be able to refactor out of them that they both depend on.

It's just a matter of refactoring.


[ Parent | Reply ]


0.00
Created by mumble 3 months, 1 week ago
[ 0.00 | 0.00 ] [#14071]

I was hoping you would reply. I tried to explain the structure of the code in my post.
So yeah, ket's and superpositions have the same structure, and NewContext, and ContextList do too.
But the processor and the context class have essentially nothing in common.
Except, the context class is where the code learns knowledge, and the processor is where we parse our learn rules. So they are linked.
Anyway, I've been thinking, and seems to me the only solution is to put it objects.py, context.py and processor.py in one big file.


[ Parent | Reply ]


0.00
Created by kr5dit 3 months, 1 week ago
[ 0.00 | 0.00 ] [#14075]

Anyway, I've been thinking, and seems to me the only solution is to put it objects.py, context.py and processor.py in one big file.

Ugggh...

There have to be functions in processor.py that context.py uses, and functions in context.py that processor.py uses... You just have to move these to base(something?).py...

Surely.


[ Parent | Reply ]


0.00
Created by United_Fools 3 months, 1 week ago
[ 0.00 | 0.00 ] [#14067]

python sucks. try Perl


[ Parent | Reply ]


0.00
Created by Mike_Crawford 3 months, 1 week ago
[ 0.00 | 0.00 ] [#14060]

Where did you post The diaries? I want to recover a specific one


[ Parent | Reply ]


0.00
Created by mumble 3 months, 1 week ago
[ 0.00 | 0.00 ] [#14065]

any luck finding the one you were after?


[ Parent | Reply ]


0.00
Created by Mike_Crawford 3 months, 1 week ago
[ 0.00 | 0.00 ] [#14091]

My Bad. I didn't see your response until just now.

I have a long commute so I don't have much free time during the week. I'll download one of the zips on Friday. I remember some uncommon key words so it shouldn't be hard to find(1).

I'm pretty sure its the longest diary ever published at Kuro5hin. I stayed up all night to write it when my Adsense check was late at the same time as Bonita running out of money during a school trip to Spain.

Happily, the check arrived the morning after I wrote it.


[ Parent | Reply ]


0.00


0.00
Created by anonymous 3 months, 1 week ago
[ 0.00 | 0.00 ] [#14054]

At least you tried!

Get that FreePascal or whatever free version of Pascal all of the cool kids use and try that:
http://pirate.shu.edu/~wachsmut/Teaching/CSAS1111/Notes-Pascal/pascal1.html

Or try that FreeBASIC it's the shit!

https://www.freebasic.net/


[ Parent | Reply ]