Giter VIP home page Giter VIP logo

vice.vim's Introduction

Features

Inheritance

" vice.vim needs to know the SID of where the methods are defined.
function! s:SID()
    return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
endfunction

" 'generate_stub' is defaultly 0 for some reasons.
" you can omit the vice#class()'s 3rd argument
" if you like default one.
let s:VICE_OPTIONS = {'generate_stub': 1}


" Trait

let s:Printable = vice#trait('Printable', s:SID(), s:VICE_OPTIONS)

function! {s:Printable.method('print')}(self)
    echon a:self.message()
endfunction

function! {s:Printable.method('say')}(self)
    echo a:self.message()
endfunction

function! s:Printable.requires()
    return ['message']
endfunction


let s:Foo = vice#class('Foo', s:SID(), s:VICE_OPTIONS)
call s:Foo.with(s:Printable)

function! {s:Foo.method('message')}(self)
    return 'foo'
endfunction


let s:Bar = vice#class('Bar', s:SID(), s:VICE_OPTIONS)
call s:Bar.with(s:Printable)

function! {s:Bar.method('message')}(self)
    return 'bar'
endfunction


echon "--- Foo ---\n"

let foo = s:Foo.new()
" "foo"
call foo.print()
" "foo" with newline
call foo.say()

echon "\n"
echon "--- Bar ---\n"

let bar = s:Bar.new()
" "bar"
call bar.print()
" "bar" with newline
call bar.say()

Trait (Perl's role-like feature)

  • Trait can provide some methods
  • Trait can require some methods to implement

TODO

Type constraints

let s:class = vice#new('Klass')
let meta = s:class._meta

" Create Pair type (local to s:buffer_string object).
function! meta.subtype('Pair', 'List').where(Value)
    return len(a:Value) == 2
endfunction

" Create Pair type (local to s:buffer_string object).
function! meta.subtype('Pair', 'List').define()
    function self.where(Value)
        return len(a:Value) == 2
    endfunction
endfunction
  • .where()
  • when it should be called?
    • How do other languages' system do that?
    • it should be called when assigning a value.

etc.

  • Moose(Perl)'s before(), after()
    • override (or more like Aspect-Oriented?)

vice.vim's People

Contributors

tyru avatar

Stargazers

soh335 avatar thinca avatar mattn avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.