R13B02-1: a patch for omitting a warning on {foo, bar}:fun(args) calls

View: New views
2 Messages — Rating Filter:   Alert me  

R13B02-1: a patch for omitting a warning on {foo, bar}:fun(args) calls

by Yurii Rashkovskii :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Currently erlc will spit a warning on this kind of constructs:

{db, "localhost"}:connect()

as opposed to

DB = {db, "localhost"},
DB:connect()

The warning will look like:

Warning: invalid module and/or function name; this call will always fail

which is misleading, because this call will not fail (provided modules  
are in place and such)

Here is a proposed solution to the problem:

http://github.com/yrashk/erlang/commit/cda6f1727965e6794aa088a200bf6c37c4586958

I am not sure it is perfect (hey, I am not an erlang compiler hacker,  
as of yet), but it proved to work quite well for me.

Any chance it can make it to the mainstream in some way?

Thanks,
Yurii.

________________________________________________________________
erlang-patches mailing list. See http://www.erlang.org/faq.html
erlang-patches (at) erlang.org


Parent Message unknown Re: R13B02-1: a patch for omitting a warning on {foo, bar}:fun(args) calls

by Yurii Rashkovskii :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 19-Oct-09, at 7:47 AM, Richard Carlsson wrote:

> Yurii Rashkovskii wrote:
>> Currently erlc will spit a warning on this kind of constructs:
>>
>> {db, "localhost"}:connect()
>>
>> as opposed to
>>
>> DB = {db, "localhost"},
>> DB:connect()
>>
>> The warning will look like:
>>
>> Warning: invalid module and/or function name; this call will always  
>> fail
>>
>> which is misleading, because this call will not fail (provided  
>> modules
>> are in place and such)
>
> When you write code like the above, you are depending on how the  
> current
> implementation of parameterized modules works. Don't do that.

I am pretty much aware of this mantra, thanks.

In fact, I seldom use parametrized modules per se, I am just utilizing  
Erlang's capability to treat tuples as modules in another approach to  
parametrized modules I built for myself.

Yurii.

________________________________________________________________
erlang-patches mailing list. See http://www.erlang.org/faq.html
erlang-patches (at) erlang.org