Commit Graph
279 Commits
Author SHA1 Message Date
José Valim 674f4a2cb3 Do not erase elixir_compiler_pid 2014-01-22 10:47:17 +01:00
José Valim f671e1204c Change precedence of <- to be the same as other generators 2014-01-16 20:08:55 +01:00
José Valim 5a2e838def Deprecate <-/2 in favor of send/2 2014-01-14 18:27:41 +01:00
José Valim 53b68887b6 Invert the precedence of | and when
Although this adds some drawbacks when it comes to typespecs,
it prepares us for when we have named patterns.
2014-01-11 16:52:46 +01:00
José Valim 1d13d189c1 Document that ^ always points to the previous value 2014-01-09 16:22:33 +01:00
José Valim 7fcdecde95 Turn off dependency tracking for compilation on release, closes #1982 2014-01-09 15:50:48 +01:00
John Warwick 9fcab6e881 Fixing doc typos in Kernel.Typespec 2014-01-07 23:13:56 -05:00
Eric Meadows-Jonsson 4be1501f57 Annotated types should not be in guard vars 2014-01-07 22:10:47 +01:00
José Valim 27467bdb67 Fix spelling of overridden 2014-01-05 12:28:11 +01:00
José Valim 79faa1f706 Do not export case and receive vars 2014-01-04 10:45:13 +01:00
José Valim 2a6940014a Move environment cache to locals tracker, which is per module 2014-01-02 20:44:32 +01:00
José + Eric 2a1941112e Cache the environment for function definition
This speeds up compilation and reduces memory consumption. For
example, Ecto test suite consumes consistently 30% less memory
and loads 20% faster.
2014-01-02 18:10:59 +01:00
José Valim 5e2ea082d1 Deprecate __FILE__ in favor of __DIR__ or __ENV__.file 2014-01-02 18:10:59 +01:00
Eric Meadows-Jonsson 62eeb97eb8 Improve typespec docs 2014-01-02 14:35:54 +01:00
Eric Meadows-Jonsson 0a24252fca Properly handle tuples in typespecs 2014-01-02 14:35:54 +01:00
José Valim bb7b990055 Remove trailing whitespace 2013-12-31 17:38:51 +01:00
José Valim 0aee0805a9 Merge pull request #1933 from Enders/elixirc_patterns
Elixirc: fail when one of the provided file pattern is missing
2013-12-31 08:33:15 -08:00
José Valim d769f8f35e Improve docs for case, try, receive and ^ 2013-12-31 17:01:17 +01:00
José Valim 40d383faae Merge pull request #1973 from elixir-lang/jv-exp
Split elixir expansion from translation in the compiler
2013-12-30 03:51:41 -08:00
José Valim f8b019c7c8 Move to the new expansion on the front-end 2013-12-28 23:14:55 +01:00
José Valim 51aef55c83 Change how -> is represented in the AST
The previous representation was very hard to compose
and very often required the AST nodes to be created
manually.

The current approach is easier to compose because
the node is represented as any other operator as long
as it is wrapped in parentheses.

For example, imagine we have pairs of patterns and
the code to be executed for that pattern, and we want
to inject them into a case. It can now be writen as:

    pairs = Enum.map pairs, fn { pattern, expr } ->
      quote do: (unquote(pattern) -> unquote(expr))
    end

    quote do
      case unquote(condition), do: unquote(pairs)
    end

Compare to the previous implementation:

    pairs = Enum.map pairs, fn { pattern, expr } ->
      { [pattern], [], expr }
    end

    pairs = { :->, [], pairs }

    quote do
      case unquote(condition), do: unquote(pairs)
    end
2013-12-23 16:10:33 +01:00
José Valim e98f3eae10 Use spawn_monitor instead of spawn_link to avoid EXIT
messages leaking into the mailbox.
2013-12-23 11:30:32 +01:00
José Valim c7af8bc2cc Improve compilation times and memory consumption
This commit includes three changes:

1. Previously, the parallel compiler released at once all processes
   depending on a particular module. This commit ensures they are
   released according to the number of cores available. This ensures
   we have fewer modules being compiled at once

2. Garbage collect the current process every time we are waiting
   for another module to be compiled

3. Do not compile a module for files that simply define modules
2013-12-21 20:06:50 +01:00
Eric Meadows-Jonsson 349873ab63 Handle unary ops when converting typespec to ast 2013-12-20 14:01:50 +01:00
Eric Meadows-Jonsson 66dd76e42b Fix quote docs
Closes #1949.
2013-12-20 01:02:57 +01:00
José Valim 6d3624147e Release v0.12.0 2013-12-15 23:01:14 +01:00
Guillaume Grenet 3687b0f104 CLI/compile: fail when some patterns aren't matched 2013-12-14 18:37:35 +08:00
Eric Meadows-Jonsson 9bedb0faaf Change typespec guards to keyword list
Previous syntax:
@spec fun(a) :: b when is_var(a) and is_subtype(b, [a])
New syntax:
@spec fun(a) :: b when a: var, b: [a]
2013-12-13 13:12:57 +01:00
José Valim f62c26b9b6 Ensure record aliases in the same quote can be accessed, closes #1915
This commit also simplifies macro expansion for both imports and aliases
to always give higher preference to the macro environment rather than
the caller one, if such is available. The deal is to simplify both the
code and understanding of how macros work.
2013-12-07 20:01:11 +01:00
José Valim 1fbb6871a0 Add more hygiene examples 2013-12-02 06:53:44 +01:00
José Valim 9ee79a16bb Deprecate Macro.extract_args/1 2013-11-29 23:24:44 +01:00
Eric Meadows-Jonsson ffb2258bb1 @type and friends support unquote fragments 2013-11-28 23:01:00 +01:00
José Valim 09869ec135 Improve typespecs when formatted as strings 2013-11-26 09:15:39 +01:00
José Valim 043edd4990 location: :keep only affect function definitions
This commit changes how metadata is stored once location: :keep
is used and also removes the __scope__ special form.

Closes #1877
2013-11-25 11:35:00 +01:00
José Valim f98cda71c0 Implement var! and alias! in Elixir 2013-11-23 10:54:40 +01:00
José Valim b28c95d31a Move case/try/receive to special forms 2013-11-23 10:35:10 +01:00
José Valim de3c0f639a Move more operators to Kernel 2013-11-22 13:44:37 +01:00
José Valim 260be7c8ea Start porting elixir_macros to pure elixir 2013-11-22 12:55:51 +01:00
Eric Meadows-Jonsson f125d19854 Move typespec guards to end of spec
Moves precedence of `when` to be lower than `::`.
2013-11-11 10:08:24 +01:00
Eric Meadows-Jonsson 1ce2e24f5d Add is_var/1 for use in typespec guards
Allows you to specify a variable without any type contraints.
2013-11-11 10:08:24 +01:00
josephwilk d3a526ebf0 Improving docs on var!
Remove implementation details about variable name.
Try and make it clear it is just unquoting a var.
2013-11-06 18:25:04 +01:00
José Valim 4eb9cd3f59 Improve docs and error messages 2013-11-06 12:31:55 +01:00
José Valim dcf6ca1003 Ensure LexicalTracker doesn't fail accross lexical contexts 2013-11-03 18:02:03 +01:00
Samuel Tonini 427e5ed712 use a separat compilation status per parallel compilation 2013-11-03 16:52:56 +01:00
José Valim d334c1d6e4 Add tests for LexicalTracker 2013-11-01 16:03:13 +01:00
José Valim d856e667b9 Add warnings for unused aliases 2013-11-01 16:03:12 +01:00
José Valim 3c151d5357 Add Kernel.LexicalTracker 2013-11-01 16:03:12 +01:00
José Valim 9897b894be Deprecate x in y inside matches 2013-10-31 11:36:05 +01:00
José Valim f1e2fcf9f9 Same module variables must be explicitly shared
Prior to this commit, the following code would work:

    defmodule Hello do
      defmacro write do
        quote do
          a = 1
        end
      end

      defmacro read do
        quote do
          a
        end
      end
    end

    require Hello
    Hello.write
    Hello.read

Although this is convenient, it has many issues:

1. It is not clear at any point the intent of sharing the variables
   in between the macros

2. Whenever macros from the same module are nested, there is a chance
   a variable used before and after the nesting to be overriden

We address this issue by only allowing variables explicitly marked
with var! to be shared. Here is how the example above should be updated:

    defmodule Hello do
      defmacro write do
        quote do
          var!(a, Hello) = 1
        end
      end

      defmacro read do
        quote do
          var!(a, Hello)
        end
      end
    end

    require Hello
    Hello.write
    Hello.read
2013-10-30 16:15:19 +01:00
José Valim 992ac67512 Improve coverage for location: :keep 2013-10-30 16:15:19 +01:00