<div>Thank you for all input in this matter. I mean both regarding -extends and $handle_undefined_function.</div><div> </div><div>I think it is place for some clarifications which will have implications on earlier statements in this thread.</div>
<div> </div><div>On October 19:th a decision from the OTP Technical Board (a fora internal to the</div><div>OTP development team at Ericsson) regarding parameterized types was announced.</div><div> </div><div>The announcement looked like this:</div>
<div><strong>Issue 4 - What to do with unsupported feature 'parameterized modules'.</strong><p>- The board acknowledges that a lot of software relies on this feature although it's always been experimental. The current form of the implementation is not acceptable and the parameterized modules as such has never been accepted as a feature in the language. The feature is also not compatible with for example module-fun's and is not fully integrated with the rest of the tools in OTP.</p>
<p> To allow for source code compatibility, the board decides to only remove the syntactic support for parameterized modules. This means:</p><p> * Apply with tuple modules will be retained, supported and properly documented.</p>
<p> * Error handler functionality that today supports inheritance will be slightly generalized, so that parameterized modules can contain stubs to facilitate inheritance. The functionality in the error handler will be documented.</p>
<p> * The parser will accept the syntax for implementation of parameterized modules, but if the parameterized modules are not handled by a parse_transform, an error message will be generated at a later stage (this concerns the implementation of the modules themselves only).</p>
<p> * A parse_transform handling source code implementing a parameterized module will be published in the public domain, free to use and include in any package needing it. It will however not be part of OTP. As it uses supported and documented functionality, it will however be expected to work for forthcoming releases as well, or at least to be possible to adopt to forthcoming releases.</p>
<p> As apply with tuple modules is retained, calls to parameterized modules will remain as they look today. Only the implementation of the parameterized modules themselves need to apply a parse transform to allow for the "unsupported" syntax extensions. Calling a function in an instance of a parameterized module from an evaluator (e.g. the shell) will also work as before.</p>
<p> </p><p>As I remember it we got mainly positive reactions regarding this decision and now we have implemented it exactly as said and it will be released in R16A (beta release on January 30:th) and R16B (product release on Feb 27:th).</p>
<p>In short the previously undocumented support for parameterized modules is removed from the OTP distribution and is replaced with a parse transform which we will provide as a separate project at Github. We do this to make the transition smooth for projects having used the parameteized modules feature. We will not continue to support or enhance that parse transform in the future (it is up to the users interested in the feature to do that).</p>
<p>Some of the comments in this thread are related to how parmaterized modules and <br>'-extends' in particular could be improved, changed etc. and it is perfectly ok to do that, but it is not part of Erlang/OTP any more. </p>
<p>As a consequence of removing parameterized modules from OTP we have changed the error_handler by removing a built in knowledge about parameterized modules and by adding a more general and useful functionality, the $handle_undefined_function feature.</p>
<p>This feature is useful in a number of situations where one was earlier forced to modify the global error_handler:</p><p>- Can support the parse-transform for parameterized modules (the -extends attribute)</p><p>- Can be used to safely (or more safely than before) implement various "mocking" functionality for testing purposes</p>
<p>- Can be used to interface external generic RPC interfaces like the android case.</p><p>It will be documented in the error_handler module together with a fat warning that you should not use this in normal production code etc. The error_handler module is hardly something that the average or novice programmer will stumble into and immediately use features from.</p>
<p>So in summary we have done what we promised to do:</p><p>- taken parmeterized modules out of Erlang/OTP (offering a parse_transform instead)</p><p>- removed knowledge about parameterized modules from error_handler and added a more generic and safe way for extending the error_handler per module instead.</p>
<p> </p><p>/Regards Kenneth, Erlang/OTP Ericsson</p><p> </p><p> </p></div><div> </div><div><br><br> </div><div class="gmail_quote">On Wed, Jan 23, 2013 at 5:01 AM, Richard O'Keefe <span dir="ltr"><<a href="mailto:ok@cs.otago.ac.nz" target="_blank">ok@cs.otago.ac.nz</a>></span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
<div><br>
On 23/01/2013, at 7:30 AM, Evan Miller wrote:<br>
><br>
> Most people on this list seem to care about "big-scale" issues like<br>
> reliability, predictability, processing kajillions of commercial<br>
> transactions, and so forth. I happen to care a lot more about<br>
> "small-scale" issues -- in particular, the programming experience of<br>
> one person just trying to get something to work for the first time and<br>
> having the code look nice.<br>
<br>
</div>I care a heck of a lot about small scale usability issues,<br>
and that's precisely why I DISLIKE pmods -extends and so on.<br>
Because I have learned from painful experience that reliability<br>
and predictability ARE small scale usability issues.<br>
<br>
The fact that -extends as currently conceived destroys our<br>
ability to know what a module exports, well, words fail me.<br>
It's such a *TERRIBLE* thing to do to plain simple-minded<br>
programmers like me that it makes me want to smash things in<br>
anger. I make mistakes *all the time*, and not being able to<br>
ask "have I actually defined everything that is either called<br>
or exported" any more, well, how does THAT help me?<br>
<br>
Let's face it, I can get pretty close to the effect of<br>
-extends WITHOUT it. I happen to have a small Erlang file<br>
that lets me type<br>
> export_from:module(foobar).<br>
in an Erlang shell and get an export list and a bunch of<br>
glue definitions that I can paste into a source file.<br>
It's careful to exclude module_info/[0,1], and it uses<br>
the io module rather clumsily. And it's under 50 SLOC.<br>
<br>
Writing a parse transform that gets the info from a .beam file<br>
would be harder, but easier for a programmer to use. I'd rather<br>
not do that, because simply saying "re-export EVERYTHING" is too<br>
dangerous.<br>
<br>
-export_from(Module, Functors).<br>
<br>
which I think I first proposed back in about 1996, permits so<br>
much more checking, and makes life SO much nicer for the small-<br>
scale programmer, that the contrast is almost dizzying.<br>
<div><br>
> I think that's ultimately where innovation<br>
> comes from -- one person experimenting around, seeing if things work,<br>
> and not caring whether it's production-ready or fit to be seen by<br>
> anyone.<br>
<br>
</div>Right. And *not* from shoving half-baked ideas out the door<br>
too early. Quintus did that once, and ever since Prolog programmers<br>
have been using an I/O approach that was significantly inefficient and<br>
clumsy compared with what we _could_ have had if the ***** who shoved<br>
it out the door had asked around the company if anyone had a better<br>
idea. The botch even made it into the standard! (Heck, it even got<br>
copied into Erlang...)<br>
<div><br>
> For example, Erlang is missing one feature found in every other<br>
> language that I've used that is missing from Erlang. It's the ability<br>
> to write:<br>
><br>
> Person.name<br>
<br>
</div>That's why Joe Armstrong and I have both proposed essentially the same<br>
data structure (in my case, complete with details of how it can be<br>
implemented and actual measurements from a pilot implementation in a<br>
micro-VM) many years ago.<br>
<br>
However, I would point out that this feature requires EITHER<br>
a static type system (Pascal, C, C++, Oberon, Java, C#, &c)<br>
OR a run-time search to find where the field is.<br>
<div><br>
> Every other language I can think of has something<br>
> like this,<br>
<br>
</div>There are vastly more languages than you appear to be aware of.<br>
The trick is to make something like this<br>
- work EFFICIENTLY<br>
- WITHOUT a strong static type system.<br>
<div><br>
> <a href="http://person.name" target="_blank">person.name</a>(). I wonder how many potential Erlang programmers moved on<br>
> to something else because they couldn't find this very simple language<br>
> construct while they were playing around with Erlang for the first<br>
> time.<br>
<br>
</div>Only the hard-of-thinking who were unwilling to learn a new way to<br>
program.<br>
<div>><br>
> Thanks to Pmods and some code generation, I was able to come up with<br>
> what I felt was acceptable alternative in Erlang: Person:name().<br>
<br>
</div>Did you ever measure how long that took?<br>
Compared with Person#person_name?<br>
Here's a hint: if you are sick of having programs<br>
run too fast, I've some old machines I could sell you.<br>
There are easier ways to go slow than abusing the language.<br>
<br>
Erlang is *NOT* an object oriented language.<br>
That's deliberate: the inventors of Erlang were well aware of OO<br>
and chose not to use it.<br>
<br>
If you try to use Erlang as if it were an object oriented language,<br>
you are wasting your time. F# will do a _much_ better job of<br>
satisfying you, and it's a perfectly fine language available under<br>
Mono as well as .NET.<br>
<div><div><br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br>