<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Feb 23, 2016 at 3:50 PM Richard A. O'Keefe <<a href="mailto:ok@cs.otago.ac.nz" target="_blank">ok@cs.otago.ac.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 24/02/16 8:53 am, Kenneth Lakin wrote:<br>
 > It doesn't seem to be the case. This works just fine for me with<br>
Erlang 18:<br>
> $ ls<br>
> $ mkdir -p dir/with/parents<br>
> $ echo "-module (test).<br>
>> -compile (export_all).<br>
>><br>
>> run() -> ok." > dir/with/parents/test.erl<br>
> $ erlc dir/with/parents/test.erl<br>
> $ ls<br>
> dir  test.beam<br>
> $<br>
There is an important difference.  The OP wanted the equivalent of<br>
   -module(dir_with_parents_test).  Try it and you get<br>
m% erlc dir/with/parents/test.erl<br>
/home/cshome/o/ok/erlang.d/test.beam: Module name<br>
'dir_with_parents_test' does not match file name 'test'<br></blockquote><div><br></div></div><div dir="ltr"><div class="gmail_quote"><div>Indeed. Looking at the docs for erlc and compile, I can see that there's a couple of things that influence this, maybe. The key mystery, for me, is how compile:file/3 determines its product's path. Maybe it uses the File argument, but that isn't 100% clear. </div><div><br></div><div>The error can be suppressed with an option, but it appears that would wreck code loading - maybe moving the file afterwards? There'd be problems with concurrent builds, though, and it doesn't do much for  avoiding an intermediate file.</div><div><br></div><div>There's an option to set the source name, but again, not clear if that's just used by module_info/1 or to construct the output path.</div><div><br></div><div>Finally, I suppose you could use the binary option to produce the module in memory and then write that to a file - would that work, though?</div><div><br></div><div>I guess the point of frustration I come down to is that the file name and the module name don't have to be the same ... except that they do. </div><div><br></div><div>One concrete use case: I've recently split up a gigantic module into several smaller ones, but they all need to share a series of record definitions. I'd love to be able to collect them all into a directory and put the record defs in a .hrl there, and be reasonably sure that the record is only available to those modules.</div><div><br></div><div>Judson</div></div></div></div>