[erlang-questions] Newbie question: function include/1 undefined

Donald Steven <>
Mon Oct 3 02:31:57 CEST 2016


Thanks.  I'll have another look.

On 10/2/2016 8:03 PM, Richard A. O'Keefe wrote:
>
>
> On 3/10/16 12:37 PM, Donald Steven wrote:
>> Thanks Richard.  I had (alas) come to that conclusion.
>>
>> In c (or m4 or the like), I can include blocks of text or code quite
>> freely.
>
> I used to maintain pdm4.
>
>> In this case, primarily as a matter of aesthetics, I wanted to
>> off load some repetitive initializations to a file which could be
>> included at the appropriate point, with a neat % comment on the side to
>> keep my head straight.
>
> Colour me stupid, but I don't see why you can't have
>
>    % biginit.hrl
>
>    biginit(Arguments...) ->
>       big,
>       ugly,
>       block.
>
>
>    % main.erl
>    ...
>    -include('biginit.erl').
>
>    main(...) ->
>       biginit(...),
>       rest of main.
>
> OK, so it's *two* lines instead of one line, but is that a problem?
>
> Failing that, what stops biginit being a single big ugly macro?
> Again, at the point of use there would be two lines, not one.
>
> I'm trying to think of anything I might want to include in the
> body of a function that couldn't be in another function, and failing.
>
>


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the erlang-questions mailing list