Neat!<br><br>Now when on the topic, some thoughts on what would be a next level in this, generally:<div><br><div>A nice way to deliver generics would be to make it control flow analysis-optimized at the level of the module system/code expander/expanded code.<div>

<br></div><div>CFA2 might be something, Dimitris Vardoulakis' thesis may tell if it delivers for call/cc, and possibly Matt Might <a href="http://matt.might.net/">http://matt.might.net/</a> has something to say on the topic, search for abstract interpreter. (<a href="http://brendaneich.com/2010/08/static-analysis-ftw/">ref</a> <a href="http://matt.might.net/articles/implementation-of-kcfa-and-0cfa/">ref</a>)<br>

<div><br></div><div>As long as that works well enough to optimize ~80-95% of uses to ordinary procedure calls you've got a generics system that really delivers for most purposes. Of course without that delivers for lots of purposes too.</div>

<div><br></div><div>Feel free to share any reflections.</div><div><br></div><div>Brgds<br><br><div class="gmail_quote">2013/4/22 Jason Felice <span dir="ltr"><<a href="mailto:jason.m.felice@gmail.com" target="_blank">jason.m.felice@gmail.com</a>></span><br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Clearly, there could be more features and it could be more efficient, but in terms of producing the simplest thing that works for me, I'm really happy with this:</div>


<div><br></div><a href="https://gist.github.com/eraserhd/5435505" target="_blank">https://gist.github.com/eraserhd/5435505</a><br>
<div><br></div><div>Usage:</div><div><br></div><div>(define-generic (length object))</div><div><br></div><div>(add-method (length (vector? v))</div><div>  (vector-length s))</div><div>
(add-method (length (string? s))</div><div>  (string-length s))</div><div>(add-method (length (list? l))</div><div>  (##length l))</div><div><br></div><div>(length "hello") => 5</div>
<div>(length '(1 2 3)) => 3</div><div>(length '#(a b)) => 2</div><div><br></div></div>
<br>_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca" target="_blank">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
<br></blockquote></div><br>
</div></div></div></div>