Extensions for the nim programming language.
Find a file
Joey Yakimowich-Payne eb185fa34f Remove old comment
2018-06-21 19:01:34 +09:00
src/extensions Remove old comment 2018-06-21 19:01:34 +09:00
tests Cleanup a bit 2018-06-21 18:43:28 +09:00
extensions.nimble Fix module naming 2018-06-21 18:33:19 +09:00
LICENSE Initial commit 2015-02-02 14:15:08 +13:00
README.md Cleanup a bit 2018-06-21 18:43:28 +09:00

nim-extensions

Extensions for the Nim programming language.

These extensions aim to improve the usability of Nim in practical applications.

Extensions so far include:

OOP macro

This module was modified from the OOP section on the excellent website http://nim-by-example.github.io/

usage:

import extensions/oop
class BaseObject: # inherits from RootObj
  # attributes/properties
  var
    x: int
    y: float
    
  method override_me(argx: float): int=
    result = int(argx) + self.x
    
class ClassName of BaseObject:
    method method_name(arg1: int, arg2: float=0.3): float=
      ## do stuff here
      result = arg2
      
    method override_me(argx: float): int=
      result = int(self.y) + int(argx) + self.x

There's also an example in the code that demonstrates the inheritance that can be run by executing:

nim c -r tests/test1.nim