At present felix has various platform dependent type aliases, including
int64, size, etc.

The existence of these aliases is causing problems: some of Michaels web code
is assuming lengths of type size are uint which works for him on a 32 bit 
machine
but fails for me on a 64 bit machine.

The only reliable way to make this work is to always cast every alias to
a fixed type, or, fixed type to an alias (or alias to alias or whatever).
EG

        len s - 1u

works on 32 bit machine because len s is type size which is alias for uint.
But on 64 bit machine its an alias for ulong so he code breaks.

A possible solution is simply to make all those type abstract,
thus enforcing a cast everywhere.

I have to explain why this was NOT done originally: I started off wanting
int32, int64 as the abstractions and int,long etc as typedefs.

But this does not work because on most platforms two of the C integer
types (eg int, long) are the same size, but they're different types.

With all abstractions, the code required so many casts as to be
unreadable.

Three things change the balance.

1. Contructor style conversions and operator dot:

        var k = C_hack::cast[int] 1L;
        var i = int 1L;
        var j =  1L.int;

The first case is ugly. The second is better but may require some
parens in more complex cases.

The third case really clinches it:

        "Hello".len.int

just looks ok!  In fact:

        1.size

looks so nice I'm thinking of getting rid of all the extra weird constants:

        1uz  // who knows that's a type size?

2. Typesets:

        fun f: !ints -> float = "(float)$1";

where !ints just means any integer type. Note that typesets ONLY work
properly with C bindings. The overloading system attempts to propagate
some of the typeset stuff but it isn't guaranteed.

3. Working typeclasses

Which can easily provide all the operations needed (instead of having
to define +, - * / etc for size, ptrdiff, etc etc).

The stricter regimen will require  a bit more programming, i.e. you'll have to 
do a little more casting. But it will be consistent. And we can restrict the 
operations
so that, for example, you can't multiple two ptrdiff together.


--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to