On Thu, 2006-10-05 at 21:16 +1000, Jonathan Kelly wrote:
[]

Some comments:

> #import <flx.flxh>;
> 
> open List;
> open C_hack;
> 
> struct DLL_List[T] {
>     next : &DLL_List[T];
>     prev : &DLL_List[T];
>     item : T;
> }
> 
> fun eq[T]: T * T -> bool = "$1==$2";
> 
> fun eq[T] (x:T) (y:T):bool =
> {
>     return eq[T](x, y);
> }

As in C++ you can write:

        return eq(x,y);

here. There's no need to specify the T if it can be deduced.

> fun new_DLL_List[T] (n:T):&DLL_List[T] =
> {
>     var x : DLL_List[T];
>     x.next = &x;
>     x.prev = &x;
>     x.item = n;
>     return &x;
> }

This will work, but it retains the whole function stack frame,
not just a DLL_List object. 

There is no 'new' operator :) I think I had better add one!
[That's a serious bug .. but as usual a use case is required,
looks like this is one :]

> proc add_Link[T] (nxt:&DLL_List[T], lst:&DLL_List[T])
> {
>     (*nxt).prev = lst;

You can use

        next .-> prev = lst;

The . is unfortunate but necessary because a->b is a function
type, and is right associative and the wrong precedence.


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to