[Python-ideas] Improving the expressivity of function annotations

Michael Foord fuzzyman at gmail.com
Mon Apr 4 21:47:45 CEST 2011


On 4 April 2011 20:30, Masklinn <masklinn at masklinn.net> wrote:

> On 2011-04-04, at 21:05 , Michael Foord wrote:
> > On 4 April 2011 20:04, Masklinn <masklinn at masklinn.net> wrote:
> >> On 2011-04-04, at 20:47 , Michael Foord wrote:
> >>> It's a standard term for languages like C# and Java, but if you don't
> use
> >>> these languages there is no reason you should know it. Generics is a
> >>> solution (hack - but still an elegant hack) that allows you to write
> >>> "generic" containers and functions that can work with any types whilst
> >> still
> >>> being type safe.
> >>
> >> Why do you find generics to be a hack?
> >>
> > Because with a good dynamic type system they are completely unnecessary.
>
> If you go that way, types themselves are unnecessary "and therefore hacks",
> static or not.
>
> I don't think that makes much sense, though I can see you were probably
> replying in jest I was interested in the answer.


I wasn't entirely joking, and no a dynamic type system doesn't make types
themselves redundant - just the declaration of them all over the place (and
often multiple times for the same use in languages like Java and C#).
Generics are a hack within the language syntax to tell the compiler that
different types *might* be used (and allow you to refer to these types in
your implementation without knowing what they will be), whereas a smarter
compiler could deduce this for itself anyway.

All the best,

Michael

-- 

http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110404/7147d94a/attachment.html>


More information about the Python-ideas mailing list