On Sep 8, 2006, at 9:49 PM, skaller wrote:
> ... I mean, the C++ committee changed things and
> they DID have 100K users out there screaming :)
Not there's an interesting but of history :)
> Anyhow given that basic idea -- plus the fact that
> I decided at the outset to scrub the C++ type notation --
> I'm not against quite significant redesign of the syntax.
Regarding C++ template type notation, why did you choose square
brackets for the list of predicates, instead of angle brackets? That
is, why did you choose this:
fun function[T] ...
instead of
fun function<T>?
Two notes on this: first, if you are using capital letters for types,
angle brackets are more readable; second--this is just an aside from
symbolic logic to explain the usage--"predicates" are sometimes
characterised as "modadic relations" because they are a relation
between a term and a single variable; this doesn't have anything to
do with "monads," of course.
> But -- and you must promise not to scream here -- the
> 'most important' use of typeclasses is actually to automate
> wrapping C++ types. In this case 'the whole point' is
> in the defaults:
>
> typeclass Iterator[i,t] {
> proc advance: i = "++$1";
> fun deref: i -> t = "*$1";
> fun eq: i * i -> 2 = "$1==$2";
> }
>
> This is actually the very first thing I want to do :)
That's a great way to start! To clarify, you want to be able to
create a general typeclass with default definitions, then derive
instances of that typeclass for each C++ type you want to import to
Felix?
> You may note: change the word 'typeclass' to 'module'
> and the above actually works NOW.
>
> The problem is, it is fully parametric.. it will happily
> generate Iterator[float, double] which will then fail
> at C++ compiler time .. instead of Felix compile time.
So you need to find a way to restrict the range of types that may
declare themselves instances of the typeclass/module?
I hate to say this because it means you only need modules but here it
is anyway: typeclasses are also fully parametric. The way to
restrict the instantiation is to create include any additional
constraints in the function signatures (generally, the typeclass
context). For iterators, which are abstractions of pointers, you
might use:
(1) make a class/module covering the most general operations on the
types, for example:
typeclass ForeignCppType[T] { }
--put any general Cpp-functions for all Cpp types here; for one thing
it will give the Cpp-Felix type generator some functions to work with
(2) create a data type to cover the general operation (iterators are
abstractions of pointers):
union Ptr a = Ptr Addr
(3) create a typeclass for each Iterator-function, like I did in my
email the day before yesterday, but parameterise each typeclass's
function over the more general class (or with the general type):
typeclass WriteableIterator[T] {
fun write[T where ForeignCppType[T]] (x:T) -> (y:T) ...
OR
fun write[T where ForeignCppType[T]] (x:(Ptr T)) -> (y:(Ptr T)) ...
}
> and one is very tempted to rip off Haskell and allow
>
> a `add` b
>
> if only we weren't so short of punctuation :)
What punctuation does `add` cover?
-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