Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
majesty2450

SOUL

Recommended Posts

Simple Object (Oriented) Utility Library (SOUL)



Latest Release: 0.3.1
GitHub Wiki: https://github.com/majesty2450/OpenComputers-SOUL/wiki
GitHub Repo: https://github.com/majesty2450/OpenComputers-SOUL
 


SOUL is a library that I created to aid my development of various other libs and programs, it is in a state that I feel lends itself to be shared with the community. There may be issues, but from what I'm doing with it right now it works.
 
Note: It adds a bit of overhead compared to the general imperative approach, but this shouldn't be an issue in most cases.
 
Adds OOP (object oriented programming) functionality in the form of Classes and Mixins:
  • Single Inheritance
  • Multiple Inheritance
  • Constructors
  • Copying
  • Type checking
  • Component checking

Here is a stripped example from one of the included tests:

Example
-- Interface
--
local Tastable = {}

function Tastable:taste ()
    error("Not Implemented!")
end
Tastable.garbage_var = "hello"

-- Base Class
--
local Pizza = Class:extend(Tastable)

function Pizza:__init (name)
    Class.__init(self)
    self.name = name
end

-- Sub Class
--
local CheesePizza = Pizza:extend()

function CheesePizza:__init ()
    Pizza.__init(self, "Cheese")
end

function CheesePizza:taste ()
    print(self.name .. " is good!")
end

-- Results
--
local instance = CheesePizza:new()
local instance2 = Pizza:new()

print("Pizza isa Tastable: ", Pizza:isa(Tastable))
print("Pizza isa CheesePizza: ", Pizza:isa(CheesePizza))
print("CheesePizza isa Tastable: ", CheesePizza:isa(Tastable))
print("CheesePizza isa Pizza: ", CheesePizza:isa(Pizza))

instance:taste()
instance2:taste()


For more information visit the Wiki. The code is also documented and a good guide, it is based on JavaDoc with a few noticeable differences. The actual code should be the final word on anything though and provides the most, it is under 300 lines total with at least half in comments (so more like 150 lines with comfort).

 

Updates:


November 13, 2015

Released version 0.3.1,

  • Incorporated Class:implement into Class:extend
  • Added filters to Mixin:hasa
  • Allowed interface checking in Class:isa

November 10, 2015

Released version 0.3.0.

 

 
Link at top...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.