Primus2Falcraft: New Data Type (structure [typed])

IMPORTANT!

This code is obsolete and has been moved to a new project, asherwunk/phabstractic.  For more information, please see the current blog post about it.

Primus/Falcraft now has a ‘C’ like structure common abstraction class in Data\Types

Structures

This data structure mimics the C struct, sort of. A structure has specific fields to be taken care of or filled, some or all of these fields may have restrictions placed upon them. An object that falls under a particular genus may need to implement a specific interface, but contain modifiable members that need to be accessed generically.

This enables a basic object to have properties that may or may not have restrictions placed upon them. If all the structure fields remain the same, another structure object (or otherwise) can be substituted in place. This is a form of data structure polymorphism.

As we can see in construction, restricted members are passed in an array form, resulting in Tagged Union fields in the structure:

Once a structure is constructed, it’s fields are set in stone. Their field names and restrictions cannot be altered. In order to determine the case-sensitivity of a field name there is a denormalize function available:

NOTE: This is a private function within structure so that it can take external names and reference them correctly while still retaining field name case-sensitivity

Because the structure class also implements array functions, it can also be accessed as an array. This functionality basically binds to the built in public member functions, though removes one layer of exception handling.

Conclusion

In an artificial intelligence system there may be different subjects that share or have common properties. This functionality helps maintain and encapsulate not only data, but what types of data and what fields they have. This allows for a sort of data type polymorphism that could be advantageous to a heterogenous artificial intelligence system.

photo credit: Abstract Photo Walk at Hackfall via photopin (license)

Liked it? Take a second to support kadar on Patreon!

kadar

I'm just a wunk, trying to enjoy life. I am a cofounder of http//originalpursuitssoc.com/ and I like computers, code, creativity, and friends.

You may also like...

Leave a Reply

%d bloggers like this: