On Sep 10, 2006, at 8:09 PM, skaller wrote:
> On Sun, 2006-09-10 at 14:55 -0400, Peter Tanski wrote:
>> On Sep 10, 2006, at 11:54 AM, skaller wrote:
>
>> instance CppContainer (Vector T) {
>> }
>>
I just realised something: you are using the same construct for a
typeclass name throughout the program, so it must have the same syntax:
instance CppContainer[Vector T] { ... }
fun vec_func[T, where CppContainer[Vector T]]
>> -- the parenthesised form is both readable and kindable (Vector has
>> kind (* -> *), T has kind *)
>
> No, what I mean is syntactically kindable, that is,
> not dependent on lookup.
You just blew my mind. I have been working with C, C++ and Haskell
so much I simply assume lookup is a normal thing; I know how it is
implemented in Haskell, at least, and that is not so difficult but it
is slow. In a novel way you may have solved another potential
problem with typeclasses: by overloading them similar to functions:
module M:
typeclass Serialisable[T] { }
module N:
typeclass Serialisable[U] { }
You may resolve potential conflicts by essentially overloading the
typeclass name between modules. I think this would only be a good
policy if you required namespace overloading for typeclass names:
fun new_function1[T, where N.Serialisable T]
fun new_function2[T, where M.Serialisable T]
(Otherwise you are overloading a rule that by its nature should be
universal for all types that conform to it; but in very large
programs namespace overloading may be necessary.)
I will note for the record that when I described the implementation
of typeclasses (with lists of typeclasses and their instantiated
types, super-types, etc.) for type-checking, this list is built
during parsing and is used for lookup as well.
I have been eating my words while attempting a uniform syntax here
and I have to say that what you have created so far is quite compact
and powerful. Certain combinations are simply not legible as they
contain a series of completely different token types:
fun new_function[T, where CppContainer T] (x:T, y:T):T = { ... }
contains:
(1) ordinary words (your eyes read them)
(2) special symbols (you parse and equate them)
(3) variable symbols (you remember them like symbol-words)
Like most programming, it relies on punctuation but this is an
extreme form of punctuation, here.
Maybe it would be easier to retain only some of the information and
not make it so compact; or split up the tokens in a less compact but
more readable way. I am still working on it, but in a preliminary
way this seems (to me) a little more readable:
fun new_function : (in T, CppContainer[T]) => x:T -> y:T -> T is
{
}
Of course, this means overloading, such as:
new_function[T, CppContainer[T]]
would be a special case.
BTW, if you use such overloading, typeclasses are not necessary, they
are simply convenient.
-Pete
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language