Hi Erick,
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Erick Tryzelaar
> Sent: Wed 04 October 2006 1:28 AM
> To: Jonathan Kelly
> Cc: felix
> Subject: Re: [Felix-language] comparing pointers
>
> Jonathan Kelly wrote:
> > Hi,
> >
> > I have a list of pointer types, and need to see if the
> current pointer
> > I'm working on is in the list, so I need a comparison
> function to send
> > to mem, but I can't seem to compare pointers: is it possible? If it
> > isn't, how do I handle this?
> >
>
>
> This should work:
>
> fun eq[T]: ptr[T] * ptr[*] -> bool = "$1==$2"
>
I was guessing it would be something like that ...
>
> But I'm not sure if John wants this exposed, as it probably ends up
> placing restrictions on garbage collection. John would know more. What
> are you trying to do?
>
It's a learning exercise. I'm implementing a fibonacci heap which is a doubly
linked circular list of trees. I'm probably going to do the trees as a
list[list[T]]. Plenty of learning oportunities there! :)
So when I'm walking the list I need to make sure I haven't got in a loop. The
data structure is
struct DLL_List[T] {
next : &DLL_List[T];
prev : &DLL_List[T];
item : T
}
While I'm here, is there a way to create a new struct without it being a
variable. Currently I get new DLL_List's from a function that returns a pointer
to a local variable. That's a bit heavy, as it includes the stack frame, if I'm
understanding it properly. (But it's cool to be able to do something that would
send progammers of lesser language into fits! lol)
fun New_dll(data:T):&DLL_List[T] =
{
var node : DLL_List[T];
node.next = &node;
node.prev = &node;
node.item = data;
return &node;
}
Cheers,
Jonathan.
---------------------------------------------------------------------
CAUTION: The information contained in this e-mail is confidential and
may be legally privileged. If the reader of this message is not the
intended recipient you are hereby notified that any use,
dissemination, distribution, or reproduction of this message is
prohibited. If you have received this message in error please forward
this message to [EMAIL PROTECTED] and delete all copies
of this message.
If you wish to have us block your email address from receiving any
future emails from this organisation please forward this email with
your request to [EMAIL PROTECTED]
You can also contact the Lion Nathan company responsible for sending
this message by calling our IT helpdesk on +61 1300 300320
or you can reply directly by email to the sender above. Thank you.
---------------------------------------------------------------------
-------------------------------------------------------------------------
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