[erlang-questions] Why we need a -module() attribute?

Fred Hebert mononcqc@REDACTED
Mon Feb 22 04:04:08 CET 2016


On 02/21, Steve Vinoski wrote:
>
>If having an optional -module attribute is that important to you, write a
>pull request.
>

I have written a program that does what is required and can be quite 
simply added to a tool such as erlang.mk.

 $ awk 'NR==1 {x=FILENAME; gsub(/^.+\//, "", x); gsub(/\.erl$/, "", x); print "-module("x").\n" $0; next } !/^-module(.*).$/ {print}' $FILENAME

If someone feels they would benefit from filenames taking over the 
module names, this script will fully edit out an existing 
`-module(name).` line and instead replace it taken from one using the 
filename.

I hope this helps, please refine as you see fit, I'm releasing this as 
public domain.



More information about the erlang-questions mailing list