1# Most of this code is taken from the official Elixir documentation. 2# With comments and modifications 3# by Ivan Gonzalez Polanco <ivan14polanco@gmail.com> 4# 5# This code doesn't compile, since it's supposed to test de ctags elixir 6# parser, not the elixir elixir parser. 7 8# 9# d delegates (defdelegate ...) 10# 11defmodule MyList do 12 defdelegate reverse(list), to: Enum 13 defdelegate other_reverse(list), to: Enum, as: :reverse 14end 15 16# 17# p protocols (defprotocol ...) 18# 19defprotocol Size do 20 @doc "Calculates the size (and not the length!) of a data structure" 21 def size(data) 22end 23 24# 25# g guards (defguard ...) 26# 27defmodule Integer.MyGuards do 28 defguard is_even(value) when is_integer(value) and rem(value, 2) == 0 29 defguardp is_odd(value) when is_integer(value) and rem(value, 2) != 0 30end 31 32# 33# i implementations (defimpl ...) 34# 35defimpl Size, for: BitString do 36 def size(binary), do: byte_size(binary) 37end 38