[erlang-questions] Couple of questions ...

James Churchman jameschurchman@REDACTED
Tue Apr 12 00:27:02 CEST 2011


> Unused function warning : 


As a dirty hack, you could export the function that it's complaining about. That will solve the problem.

The other option I can think of is to make a parse transform that removes the function. You could set an attribute like -remove([{  data_conn_make_inet_link,4  }), read it in a config file, hard code the fun/arity into the PT etc.. and then filter the AST before it gets parsed into the config file so thats its removed before the final compile. I assume that will remove the warning. I could code it for you if you like..

> "void" 

As far as my understanding, just placing 'ok' atom at the end of the function it the standard. I think that the overhead of doing this is so minuscule you will never notice. Altho having a void may sound a neat idea it would break erlang. Erlang always has defined behaviour under all circumstances, with this "void" under a buggy piece of code, that accidentally sets a var from your void function, there would either need to be a new type of error thrown, or worse still erlang would behave in an unpredictable manor. Erlang is designed to have predictable behaviour even under faulty erlang code :-)


James


On 11 Apr 2011, at 23:09, Mike Oxford wrote:

> Unused function warning
> =====================================
> data_conn_make_inet_link(SrcIP, SrcPort, DstIP, DstPort) ->
>     #inet_link{ src=#inet_src{ip=SrcIP, port=SrcPort}, dst=#inet_dst{ip=DstIP, port=DstPort}}.
> 
> I want to put this in a "common header," but not every single file which uses the header will use 
> this particular call.
> 
> It's old getting spammed with warnings about this.
> It's poor to have to turn off warnings at a global level.
> 
> May I propose prepending something to suppress warning about it not being used?  Maybe 
> using a leading "-"?    or %ifdef/#ifdef#pragma-style preprocessor controls?  -quiet-include("file"). ?
> 
> -method()->  %% ignore "unused" warnings
> 
> I see some discussion of this back around 2008, but I don't see any traction on it since.  Anyone
> know if this was ever implemented in any form?
> 
> 
> 
> "void" 
> =====================================
> If I do not care about the return value of a method, can I do something to tell that to the compiler?
> No reason to allocate return storage on the frame if I don't care about it anyway?  Or is this too trivial
> in the scope of "Erlang copies everything everywhere" to be of consideration?
> 
> _method()->  %% don't allocate storage or worry about returns
> 
> 
> Thanks!
> 
> -mox
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list