<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 31, 2014 at 12:20 PM, zxq9 <span dir="ltr"><<a href="mailto:zxq9@zxq9.com" target="_blank">zxq9@zxq9.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
</span>In a duck typed language like Python we can treat anything as some type if it<br>
implements the basic methods expected of that type. An outside process doesn't<br>
need to care (sure we could introspect, but needing to is usually regarded as<br>
a sign of using the wrong tool).<br>
<br>
Erlang processes can be thought of the same way if we accept that in Erlang<br>
"process" means something much closer to what languages like Python mean by<br>
"object" than is commonly imagined. If I have a game character process it<br>
might have an AI controller, or it might have a player controller. The<br>
character process doesn't need to know or care, and we could actively swap out<br>
AI for player control on the fly and the character process wouldn't care, so<br>
long as all controllers, regardless of subtype (if we decide to use this term<br>
"type"), adhere to the "controller" protocol.<br></blockquote><div><br>Yes, this is exactly the sort of abstraction I'm looking for. The main questions I have right now are (1) where are the real-life examples of such protocols, and (2) what is the most useful enforcement mechanism? A type system would probably be the most familiar to programmers, but it's not necessarily the most practical. Question 2 is really a research question, and the answer to question 1 should help me solve question 2.<br><br>I haven't had a chance yet to look into the examples already mentioned on this thread, but hopefully there are examples there or in other programs I'm examining (e.g. ejabberd probably has several instances of this kind of problem).<br><br></div><div>I agree that behaviors might be a good place to look. This does seem to be the closest thing Erlang has to built-in protocol specifications, so maybe I can extend those in an interesting way.<br></div><div><br></div><div>Sorry for the late response; been a busy few days.<br></div></div></div></div>