Call with a tuple as a module succeeds in Erlang 18 RC2

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Call with a tuple as a module succeeds in Erlang 18 RC2

Stavros Aronis
Hello!

It seems that there are some leftovers from the parameterized modules support in the compiler for Erlang 18 RC2 (and also earlier Erlang versions). In the example below, even though the compiler emits warnings when a tuple is used as a module name, the code executes without error.

Requesting HiPE compilation restores the 'correct' behaviour (an error is raised).

Regards,

Stavros

---

$ cat tuple_as_module.erl 
-module(tuple_as_module).

-export([test/0, action/2]).

test() ->
  P = {?MODULE, [1,2,3]},
  {P:action(head),
   P:action(tail)}.

action(head, {?MODULE, List}) ->
  hd(List);
action(tail, {?MODULE, List}) ->
  tl(List).
$ erl
Erlang/OTP 18 [RELEASE CANDIDATE 2] [erts-7.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.0  (abort with ^G)
1> c(tuple_as_module).
tuple_as_module.erl:7: Warning: invalid module and/or function name; this call will always fail
tuple_as_module.erl:8: Warning: invalid module and/or function name; this call will always fail
{ok,tuple_as_module}
2> tuple_as_module:test().
{1,[2,3]}
3> c(tuple_as_module, [native]).
tuple_as_module.erl:7: Warning: invalid module and/or function name; this call will always fail
tuple_as_module.erl:8: Warning: invalid module and/or function name; this call will always fail
{ok,tuple_as_module}
4> tuple_as_module:test().      
** exception error: bad argument

_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs
Reply | Threaded
Open this post in threaded view
|

Re: Call with a tuple as a module succeeds in Erlang 18 RC2

Anthony Ramine-4
Le 27 mai 2015 à 13:40, Stavros Aronis <[hidden email]> a écrit :

> Hello!
>
> It seems that there are some leftovers from the parameterized modules support in the compiler for Erlang 18 RC2 (and also earlier Erlang versions). In the example below, even though the compiler emits warnings when a tuple is used as a module name, the code executes without error.
>
> Requesting HiPE compilation restores the 'correct' behaviour (an error is raised).
>
> Regards,
>
> Stavros

From what I know, the module-as-tuple feature is here to stay and HiPE is wrong to refuse to compile such code.

_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs
Reply | Threaded
Open this post in threaded view
|

Re: Call with a tuple as a module succeeds in Erlang 18 RC2

Fred Hebert-2
On 05/27, Anthony Ramine wrote:
>From what I know, the module-as-tuple feature is here to stay and HiPE
>is wrong to refuse to compile such code.
>

That is correct. See http://www.erlang.org/news/35, issue 4:

>Issue 4 - What to do with unsupported feature 'parameterized modules'.
>
> [...]
>
>To allow for source code compatibility, the board decides to only
>remove the syntactic support for parameterized modules. This means:
>
>* Apply with tuple modules will be retained, supported and properly
>documented.
>
> [...]
>
>* The parser will accept the syntax for implementation of parameterized
>modules, but if the parameterized modules are not handled by a
>parse_transform, an error message will be generated at a later stage
>(this concerns the implementation of the modules themselves only).
>

I kept the relevant sections of the announcement.
_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs
Reply | Threaded
Open this post in threaded view
|

Re: Call with a tuple as a module succeeds in Erlang 18 RC2

Stavros Aronis
Thanks Anthony & Fred!

As far as I can understand from http://www.erlang.org/news/35:

* The compiler warnings are wrong. The calls will succeed, and are expected to do so, since tuples are supported.
* There should be 'proper documentation' about this feature somewhere, but I have failed to find it.
* HiPE is wrong in compiling this into something that returns a 'badarg' error.

It seems, therefore, that this is still a bug report, right?

Stavros

On Wed, May 27, 2015 at 3:07 PM, Fred Hebert <[hidden email]> wrote:
On 05/27, Anthony Ramine wrote:
From what I know, the module-as-tuple feature is here to stay and HiPE is wrong to refuse to compile such code.


That is correct. See http://www.erlang.org/news/35, issue 4:

Issue 4 - What to do with unsupported feature 'parameterized modules'.

[...]

To allow for source code compatibility, the board decides to only remove the syntactic support for parameterized modules. This means:

* Apply with tuple modules will be retained, supported and properly documented.

[...]

* The parser will accept the syntax for implementation of parameterized modules, but if the parameterized modules are not handled by a parse_transform, an error message will be generated at a later stage (this concerns the implementation of the modules themselves only).


I kept the relevant sections of the announcement.


_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs