Skip to content

Commit 01cc9ed

Browse files
author
José Valim
committed
Uncomment features related to unquote fragments
1 parent 4096b31 commit 01cc9ed

File tree

4 files changed

+5
-64
lines changed

4 files changed

+5
-64
lines changed

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88
* [Kernel] Improve meta-programming by allowing `unquote` on `def/2`, `defp/2`, `defmacro/2` and `defmacrop/2`
99
* [Kernel] Add support to R16B new functions: `insert_elem/3` and `delete_elem/2`
1010
* [Kernel] Import conflicts are now lazily handled. If two modules import the same functions, it will fail only if the function is invoked
11-
* [Macro] Add `Macro.escape_quoted` to escape quoted expressions
1211
* [Mix] Support `--cover` on mix test and `test_coverage` on Mixfiles
1312
* [Record] Each record now provides `Record.options` with the options supported by its `new` and `update` functions
1413

1514
* bug fix
1615
* [Binary] inspect no longer escapes standalone hash `#`
17-
* [IEx] The h helper can now retrieve docs for special forms
16+
* [IEx] The `h` helper can now retrieve docs for special forms
1817
* [Kernel] Record optimizations were not being triggered in functions inside the record module
1918
* [Kernel] Aliases defined inside macros should be carried over
20-
* [Kernel] Fix a bug where nested records could not use the Match[] syntax
19+
* [Kernel] Fix a bug where nested records could not use the Record[] syntax
2120
* [Path] Fix a bug on `Path.expand` when expanding paths starting with `~`
2221

2322
* deprecations

lib/elixir/lib/kernel.ex

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,47 +1254,6 @@ defmodule Kernel do
12541254
In the example above, we defined a function `sum` that receives
12551255
two arguments and sum them.
12561256
1257-
## Dynamic generation with atoms
1258-
1259-
Elixir follows the same rule as Erlang when it comes to
1260-
function invocations. Calling a function is the same thing
1261-
as "invoking at atom". That said, we could invoke a function
1262-
named sum in these two equivalent ways:
1263-
1264-
sum(1, 2)
1265-
:sum.(1, 2)
1266-
1267-
We can also use the atom format to define functions:
1268-
1269-
defmodule Foo do
1270-
def :sum.(a, b) do
1271-
a + b
1272-
end
1273-
end
1274-
1275-
In general, a developer never needs to use the format above
1276-
except when he wants to dynamically define functions with macros.
1277-
In such scenarios, the name needs to be given dynamically via
1278-
the unquoting mechanism.
1279-
1280-
Imagine a macro that receives keywords and defines a function
1281-
for each entry in the keyword, using the key as function name
1282-
and the value as the value returned by the function:
1283-
1284-
defmacro defkv(keywords) do
1285-
Enum.map keywords, fn {k,v} ->
1286-
quote do
1287-
def unquote(k)() do
1288-
unquote(v)
1289-
end
1290-
end
1291-
end
1292-
end
1293-
1294-
This macro could be invoked as:
1295-
1296-
defkv one: 1, two: 2
1297-
12981257
"""
12991258
defmacro def(name, do: contents)
13001259

lib/elixir/lib/macro.ex

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ defmodule Macro do
4242
4343
extract_args(quote do: foo) == { :foo, [] }
4444
extract_args(quote do: foo()) == { :foo, [] }
45-
extract_args(quote do: :foo.()) == { :foo, [] }
4645
extract_args(quote do: foo(1,2,3)) == { :foo, [1,2,3] }
4746
extract_args(quote do: 1.(1,2,3)) == :error
4847
@@ -53,13 +52,7 @@ defmodule Macro do
5352

5453
@doc """
5554
Recursively escapes a value so it can be inserted
56-
into a syntax tree. This must be used when you have
57-
a value that does not represent an AST and you want
58-
to introduce it inside a quoted expression.
59-
60-
If you have a AST and you want to introduce it inside
61-
a quoted expression in a escaped form, use Macro.escape_quoted
62-
instead.
55+
into a syntax tree.
6356
6457
## Examples
6558
@@ -139,17 +132,7 @@ defmodule Macro do
139132
defp do_splice_join(left, []), do: left
140133
defp do_splice_join(left, right), do: { :++, [], [left, right] }
141134

142-
@doc """
143-
Recursively escapes a AST so it can be inserted into
144-
another tree unmodified. If the given AST has any
145-
call to unquote, they are properly evaluated.
146-
147-
## Examples
148-
149-
iex> Macro.escape_quoted({ :+, [], [1,2] })
150-
{:"{}",[],[:+,[],[1,2]]}
151-
152-
"""
135+
@doc false
153136
def escape_quoted(expr) do
154137
do_escape(expr, true)
155138
end

lib/elixir/src/elixir.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ main(Args) ->
3737
application:start(?MODULE),
3838
'Elixir.Kernel.CLI':main(Args).
3939

40-
% Boot and process given options. Invoked by Elixir's script.
40+
%% Boot and process given options. Invoked by Elixir's script.
4141

4242
start_cli() ->
4343
application:start(?MODULE),

0 commit comments

Comments
 (0)