Skip to content

CodeDoes/nim-extensions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 oop_macro
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 oop_macro.nim

About

Extensions for the nim programming language.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Nim 100.0%