[erlang-questions] Type Specs Preserved in Beam Code

Kostis Sagonas kostis@REDACTED
Thu Mar 1 22:16:11 CET 2012


On 03/01/12 17:46, Tim Watson wrote:
> Current type specs are only available in beam code if you compile it with debug_info or use the 'abstract_code' parse transform that's floating around on the internet. What are the chances of getting the type spec information preserved in the beam (in a separate chunk) without having to do this?

It would help if you provided some reasons why compiling with 
+debug_info is inconvenient for what you would really like to achieve. 
Recall that the original purpose of BEAM files has been to contain VM 
byte code and the default setting for them has been to be as compact as 
possible, so, naturally, chunks other than the one containing byte code 
have been frowned upon.(*)

However, compiling with +debug_info essentially retains all source in 
the form of abstract code. Having special chunks with portions of the 
information which exists in this abstract code (and I am assuming here 
you want these chunks present by default) does not seem very appealing 
to me.

If there are good reasons to be able to manipulate (the information in) 
the source, a better alternative would be to ask for abstract code to 
always be present in .beam files. (I.e., +debug_info by default and a 
new option like +min_size for environments where the size of beam files 
is a concern.)

Kostis

(*) IMO, this made perfect sense 10+ years ago; not sure this is so 
relevant a reason nowadays.



More information about the erlang-questions mailing list