---------------------------------------- > Date: Mon, 7 Jan 2008 02:27:33 -0800 > From: [EMAIL PROTECTED] > To: [email protected] > Subject: Re: Introducing Cobra > > Gabriel Sechan wrote: >> ---------------------------------------- >> >> Then the type is list. Did you read the part of my argument where I >> differentiated between types (or roles) and language types? It still has a >> type/role, even if the type/role covers a set of language types. >> > If it was a type, then you'd have to decide if you were manipulating a > singly linked list, an xor list, a doubly linked list, a skip list, a > vector, a b-tree, etc. All of which is kind of tedious and besides the > point if all you want to do is know that you need to assign this group > as the list of people with access to account# 47. In that case, the type > of the list is a distraction from the algorithm. More often, you have > situations where thinking about what the type should be causes you to > impose types that aren't really proxies for a role, and so you end up > with less flexible code.
Once again, I don't think you read everything I wrote in this thread. I've very much been talking about roles, and using the word type since I hadn't heard the word role before. Hereafter, I shall be using it. Every variable has a role. However, that role is mapped back into a type, or a set of types. Its a one to many mapping. Declaring a variables type declares its role, because you can use the reverse mapping. This data is extremely useful, IMO the most useful piece of data in the code. >>> This is the problem that type polymorphism, or generics solve. (Templates >>> try to solve it, but don't.) >>> >>> >> Templates solve a subset of it. There's basicly 4 types of polymorphism. >> Templates solve one. Inheretence another. C++ doesn't support the other >> two. Thats by design. I have my issues with template syntax and a few >> features, but lets be fair to them. >> > Oh, it's all about how much you want to abuse your templates. > > I've got three main types of polymorphism in mind: > > 1) Parametric > 2) Subtyping > 3) Ad-hoc > Its more formal than that. I'm on vacation in new orleans, so I don't have my reference library. But if you real C++ templates: The complete Guide (I think you'd love it, btw), it defines 4 types of polymorphism very distinctly. The 4 types are made up on 2 axes. One is when the decision is made (run time, compile time), the other is wether the common interface between the types is defined by an object or by the code (they called this static vs dynamic, and I think I'm doing them a disservice by describ ing it without the book in front of me). Templates are dynamic compile time. Subclassing is static run time. The other two don't exist in C++, although they do in others (Smalltalk has dynamic run time). You're #3 and 1 are both subsets of static run time. Its an extremely intersting, if very dense book that talks a lot about template theory. And has plenty of code examples that make me cry for what they're doing to the language. They like template abuse. Gabe _________________________________________________________________ Get the power of Windows + Web with the new Windows Live. http://www.windowslive.com?ocid=TXT_TAGHM_Wave2_powerofwindows_012008 -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg
