Skip to content

Instantly share code, notes, and snippets.

View josevalim's full-sized avatar

José Valim josevalim

View GitHub Profile
defmodule OhMy do
@moduledoc false
def undefined_function(module, fun, args) do
:io.format("~p~n", [[module, fun, args]])
:error_handler.undefined_function(module, fun, args)
end
def undefined_lambda(module, fun, args) do
:io.format("~p~n", [[module, fun, args]])
defp escape({ left, meta, right }) do
{ '{}', meta, [escape(left), meta, escape(right)] }
end
defp escape({ left, right }) do
{ escape(left), escape(right) }
end
defp escape(list) when is_list(list) do
Enum.map(list, escape(&1))
ExUnit.start
defmodule Hello do
@doc """
Hello world.
## Examples
iex> 1 + 2
3
def zip(a, b) do
list = to_list(a)
throw do
{ zipped, rest } = Reducers.reduce(b, { [], list }, fn
entry, { acc, [h|t] } -> { [{entry, h}|acc], t }
entry, { acc, [] } -> throw { :enum_zip, acc }
end)
:lists.foldl(fn(x, acc) ->

About you:

  • Name
  • University (current enrollment)
  • Short bio (overview of your background)
  • Phone number
  • Address
  • Timezone
  • IRC nick
  • Join the mailing list (send a quick introduction e-mail) and IRC channel (links at http://beamcommunity.github.io/)

Flaws in unquote fragments

A couple weeks ago, we have pushed support to unquote fragments:

Enum.each [a: 1, b: 2], fn { k, v } ->
  def map(unquote(k)), do: unquote(v)
end

Although it provide a nice way to dynamically define functions, after discussing with developers and extending Elixir to rely more on it, some flaws became aparent.

# rackup -s thin
require 'thin'
run proc { |env|
body = Enumerator.new do |socket|
5.times do
socket << "Hello"
puts "Hello"
sleep 1
end
class MyApp < Rails::Application
routes.append do
match "*", to: "controller#action"
end
end
# This allows developers to pass an Active Model object
# to within, check and uncheck. This is very useful when
# used with `content_tag_for` since `content_tag_for`
# generates an unique dom id for each object. With this
# module, we can write:
#
# within comment do
# click_link "Destroy"
# end
#
Expected:
[
[{"a","b"},{"c","d"}],
[{"a1","b1"},{"c1","d1"}],
[{"a2","b2"},{"c2","d2"}]
]
Actual: