[erlang-questions] Erlang 19 callbacks aren't attributes?

Kostis Sagonas kostis@REDACTED
Wed Jan 25 11:57:12 CET 2017


On 01/25/2017 11:22 AM, Alex S. wrote:
>> 25 янв. 2017 г., в 13:00, Richard Carlsson <carlsson.richard@REDACTED> написал(а):
>>
>> There are some distinctions that have not been well documented. I'll try to clarify them based on how things actually work. ... <SNIP> ...
>> These distinctions have not been properly documented, but have been intuitively followed by the people working on the language and compiler. In some cases, the lines are blurred. For example, one could easily argue that '-behaviour(Name).'  was just another wild attribute which only had a meaning to the current version of the compiler, and not part of the language proper. On the other hand, since the -callback declarations were introduced, it's pretty clear that behaviours are a language feature.
>>
>> Along these lines, I think that e.g. the type declarations of a module should be included in Beam files as standard chunks, so you don't need to extract them from the "abstract format" debug information, if present, but that's another can of pull requests.
> Along those exact lines, I argue that -callback attributes are nothing more than a preprocessor directive that gets transformed into behaviour_info/1 function, and therefore has no place in the standard chunks.

You are simply wrong.  For starters, -callback attributes are NOT 
related to the Erlang preprocessor (epp); the mechanism that creates the 
behaviour_info/1 function is in sys_pre_expand, which is part of the 
compiler.  More importantly, callbacks are manipulated by other tools 
(e.g. dialyzer, also meck?), so clearly they _are_ "more than a 
preprocessor directive", even if this manipulation happens via the 
abstract code currently.


But I think that the main problem with your mail (and my reply above!) 
is that it might unfocus the discussion about what is an attribute and 
what isn't.  Richard Carlsson has written a wonderful mail which 
explains why certain things are the way they are, but also brings up two 
important (IMO) points that should not be lost:

  1. "These distinctions have not been properly documented..."
	I think they should be.

  2. Certain declarations need not be extracted from the "abstract 
format" debug information but should be included in Beam files as 
standard chunks.
	FWIW, I agree.

Kostis



More information about the erlang-questions mailing list