[erlang-questions] is there something like #line

Matej Kosik <>
Fri Jun 1 16:07:41 CEST 2007


Bjorn Gustavsson wrote:
> Use
> 
> -file(Filename, Line).
> 
> Example from erl_parse.erl:
> 
> -file("erl_parse.yrl", 418).

Thank you to all. This directive is useful. However, slight problem with Erlang is, that directives cannot be inserted at any place (for example between two clauses of the same function). Although normally it is desirable to have all function clauses in the same "web chunk", in case of

	-handle_call
	-handle_info
	-handle_cast

I often wanted to deal with each such clause separately (put it in a separate "chunk"). I am new to Erlang, so I do not see the whole picture, but I did not understand the reason why

- every but last function clause must be ended by

	;

  (semicolon)

- the last function clause must be ended by

	.

  (full stop)
- Why not simply require only full stops.
- Why must all function clauses belonging to the same function must kept together
  (this makes sense with normal function but with things like `handle_call', and `handle_cast' it is restricting)

This makes Erlang WEB-unfriednly.

I have solved the original problem with a small hacky script that translates thinks like

	ping.erl:12: syntax error before: '-'
	ping.erl:6: function start_link/0 undefined

to

	ping.nw:79: syntax error before: '-'
	ping.nw:196: function start_link/0 undefined

(semireliable). It is not a good solution but works most of the time.

> 
> /Bjorn
> 
> Matej Kosik <> writes:
> 
>> * PGP Signed: 05/27/2007 at 03:58:14 PM
>> Hello,
>>
>> Some languages provide mechanisms for "redefining" the current filename and line number. This is done via #line directive. It is not very useful if one writes the code in Erlang, but it is useful when the Erlang code is generated from some other file. For example from a noweb file. I can tangle the actual code so that before each code chunk will be placed correct
>>
>> 	# line <line> <filename>
>>
>> command. This way it is possible to influence the compiler error messages and warnings so that they refer to the original file (and line number) rather than to the line number in the generated file.
>>
>> Is there a similar directive in Erlang? I have tried to google it out, but with little luck. In `Erlang Reference Manual', section 7.2 there I see two interesting macros:
>>
>> 	?FILE.
>> 	    The file name of the current module. 
>> 	?LINE.
>> 	    The current line number.
>>
>> Unfortunatelly, when I tried to redefine it, the compiler rejected such redefinitions. Any hint is appreciated.
>>
>> PS: I am still not 100% sure that using noweb with Erlang is a good idea. But I have used noweb elsewhere (with C and with Pict) so in my current interesting Erlang-task I decided to try it too.
>>
>> Regards
>> -- 
>> Matej Kosik
>>
>> * Matej Kosik <>
>> * 0xF248FE18 (L)
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://www.erlang.org/mailman/listinfo/erlang-questions
> 

Regards
-- 
Matej Kosik

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070601/07550855/attachment.bin>


More information about the erlang-questions mailing list