<div dir="ltr">Been a couple of decades since I did any Erlang coding from scratch and it seems to have improved significantly (didn't have proper strings back then for example). I have a little hobby project I'm using to get myself up to snuff so I can do some more serious work for an upcoming project. Would appreciate some feedback regarding a few issues/questions. The code can be found at <a href="https://github.com/scherrey/dnderl">https://github.com/scherrey/dnderl</a> . <br><br>If you've ever played Advanced Dungeons & Dragons you'll recognize that this is a simple implementation of the THAC0 (to-hit armour class 0) concept from the original combat tables in the Dungeon Masters Guide. So '<span style="color:rgb(0,0,0)"><font face="monospace">combat:thac0(fighter, 5, 2).'</font><font face="arial, sans-serif"> would correctly tell you that your 5th level fighter needs to roll a 14 or higher on a 20-sided die to hit an armour class 2 opponent whereas </font></span>'<span style="color:rgb(0,0,0)"><font face="monospace">combat:thac0(thief, 5, 2).'</font><font face="arial, sans-serif"> would tell you that a similar level thief requires a roll of 17 or better. Here are my questions:</font></span><div><font color="#000000" face="arial, sans-serif"><br></font><div>1) My top level module is combat.erl ( <a href="https://github.com/scherrey/dnderl/blob/master/combat.erl">https://github.com/scherrey/dnderl/blob/master/combat.erl</a> ). All it really does is introduce the class atom type and re-export combattables:basetohit/3 (albeit under a different name, thac0/3). Is it necessary to create a forwarding function like thac0/3 like I'm doing when I'd really just prefer to establish thac0/3 in the combattables module and re-export it from combat.erl? (Don't read anything into the different names - I just decided to rename it in the top level module because I liked it better and would be happy to use that same name throughout.) Attempting to re-export a function declared in another module gives me an error.<br><br><br>2) In combattables.erl ( <a href="https://github.com/scherrey/dnderl/blob/master/combattables.erl">https://github.com/scherrey/dnderl/blob/master/combattables.erl</a> ) I put monster_offset/1 as its own function because I couldn't figure out syntax for how to get the result of the if statement as an intermediate variable which I would have put inside the last basetohit/3 implementation. I tried several things but nothing that seemed correct to me would compile so I had to break it out into its own function. I feel like I'm missing something obvious but perhaps it's simply not allowed?</div><div><br></div><div><br></div><div>3) Is the way I've overloaded basetohit/3 with guards depending on which class is passed in the preferred idiomatic way to implement such a construct in Erlang? I thought of trying 'case' or 'if' but this seemed "cleanest" to me. I generally avoid if statements whenever possible in my other programming languages like C++ & Python. Appreciate any insights for such circumstances.</div><div><br></div><div><br></div><div>4) Is there no such thing as a module scope for a variable in Erlang? In combattables.erl I have 4 functions that return tuples representing the combat tables for each class. My initial thought was that they would be variables that could be referenced by any function in the module but that doesn't seem to work. The tuples in this case are constant lookup tables not to be updated. Am I doing this in the "correct" idiomatic manner for Erlang?</div><div><br></div><div><br></div><div>thanks & best regards,</div><div><br></div><div> -- Ben Scherrey</div></div></div>