This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iex(6)> defmodule Test do | |
...(6)> defmacrop foo() do | |
...(6)> quote location: [line: 54], do: __ENV__.line | |
...(6)> end | |
...(6)> def test, do: foo | |
...(6)> end | |
iex:6: redefining module Test | |
{:module,Test,<<70,79,82,49,0,0,5,52,66,69,65,77,65,116,111,109,0,0,0,146,0,0,0,16,11,69,108,105,120,105,114,45,84,101,115,116,8,95,95,105,110,102,111,95,95,4,100,111,99,115,...>>,{:test,0}} | |
iex(7)> Test.test | |
10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Instrument do | |
@zero :decimal_conv.number("0") | |
@struct symbol: nil, name: "", value: @zero | |
defstruct @struct | |
@keys Enum.sort(@struct |> Map.keys |> List.delete(:__struct__)) | |
for k <- @keys do | |
def __atomize__({unquote(Atom.to_string(k)), v}, acc) do | |
Dict.put(acc, unquote(k), v) | |
end | |
def __atomize__({unquote(k), v}, acc) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def benchmark(f, args \\ [], min_duration \\ @default_duration) | |
def benchmark(f, args, min_duration) when is_list(f) and is_list(args) do | |
Enum.map(f, fn(fp) -> benchmark(fp, args, min_duration) end) | |
end | |
def benchmark(f, args, min_duration) when is_function(f) do | |
IO.inspect fp | |
results = do_benchmark(fp, args, min_duration) | |
IO.puts results | |
results | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Test do | |
defstruct foo: nil, bar: nil | |
for x <- @keys do # <-------------------------- HOW ???? | |
def parse(unquote(x)), do: something(x) | |
def parse(unquote(Atom.to_string(x))), do: something(x) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat apps/bexng/mix.exs | |
defmodule Bexng.Mixfile do | |
use Bexng.Project | |
def project do | |
[ app: :bexng, | |
version: "0.0.1", | |
elixir: ">= 0.14.3-dev", | |
deps: deps ] | |
end |
NewerOlder