Skip to content

Instantly share code, notes, and snippets.

@dahu
Created October 23, 2015 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dahu/8324d9a46d3c91592c66 to your computer and use it in GitHub Desktop.
Save dahu/8324d9a46d3c91592c66 to your computer and use it in GitHub Desktop.
Messing with interfaces in VimL
" Messing with interfaces
" Barry Arthur, Oct 2015
function! Foo()
let obj = {}
func obj.register(a, b)
echo string(a:a) . ' and ' . string(a:b)
endfunc
return obj
endfunction
let x = Foo()
function! Bar(x)
let obj = {}
let obj.z = a:x
func obj.doit(a, b)
call call(self.z.register, [a:a, a:b], self)
endfunc
return obj
endfunction
let y = Bar(x)
call y.doit({'i' : 1}, {'j' : 2})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment