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

Richard A. O'Keefe ok@REDACTED
Mon Oct 3 02:03:03 CEST 2016



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.





More information about the erlang-questions mailing list