Jonathan Kelly wrote:
> Jonathan Kelly wrote:
>
>> Hi,
>>
>> are directly recursive structures not supported, or am I doing something
>> silly?
>>
>> //------------
>>
>> struct DLL_Node[T] {
>> next : &DDL_Node[T];
>> node : &T;
>> };
>> //------------
>>
>> $ flx t2/fibheap.flx
>> CLIENT ERROR
>> [lookup_name_in_env]: Name 'DDL_Node' not found in environment (depth 2)
>> In t2/fibheap.flx: line 4, cols 13 to 24
>> 3: struct DLL_Node[T] {
>> 4: next : &DDL_Node[T];
>> ************
>> 5: node : &T;
>>
>> -------------------------------------------------------------------------
>> 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
>>
>>
>>
>
> OK, so I thought perhaps mutual recursion, just to make my head hurt ...
>
> //------------
> #import <flx.flxh>;
>
> struct DLL_List[T] {
> node : DLL_Node[T];
> }
>
> struct DLL_Node[T] {
> next : &DLL_List[T];
> prev : &DLL_List[T];
> this : T;
> }
>
> fun new_DLL_List[T] (n:T):&DLL_List[T] =
> {
> var x : DLL_List[T];
> return &x;
> }
>
> fun new_DLL_Node[T] (n:T):&DLL_Node[T] = {
> var x : DLL_Node[T];
> x.this = n;
> return &x;
> }
>
> var lst1 : DLL_List[int];
>
> var lst2 = new_DLL_List[int] (11);
> //------------
>
> but this gives the following error.
>
> $ flx t2/fibheap.flx
> SYSTEM FAILURE
> [C func body, vars] Can't find index 4128
>
> -------------------------------------------------------------------------
> 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
>
>
Making progress! :)
//------------
#import <flx.flxh>;
struct DLL_List[T] {
node : DLL_Node[T];
}
struct DLL_Node[T] {
next : &DLL_List[T];
prev : &DLL_List[T];
item : T;
}
fun new_DLL_List[T] (n:T):&DLL_List[T] =
{
var x : DLL_List[T];
x.node.next = &x;
x.node.prev = &x;
x.node.item = n;
return &x;
}
proc print[T]:T="std::cout << $1;";
proc pr_list[T](lst : &DLL_List[T])
{
print "List(";
print[T] (*lst).node.item;
print ")\n";
}
var lst1 : DLL_List[int];
var lst2 = new_DLL_List[int] (11);
pr_list[int] (lst2);
//------------
$ flx t2/fibheap.flx
Info: resolving vtable for flx::rtl::con_tby linking to
__imp___ZTVN3flx3rtl5con_tE (auto-import)
List(11)
cheers,
Jonathan.
-------------------------------------------------------------------------
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