List & Nodes

Monkey Forums/Monkey Programming/List & Nodes

degac(Posted 2011) [#1]
Ok, I'm stuck with this thing


I get the error
Compiler error: Duplicate identifier 'Node' found in module 'map' and module 'list'.


the method AddLast return a 'Node' object so what's wrong?


Warpy(Posted 2011) [#2]
Ooerr, that's not good! It's a namespace problem: the class Node is defined in both std.list and std.map, so you need to say which one you want.

Do that by writing
Field mylink:list.Node<type>



therevills(Posted 2011) [#3]
What are nodes used for?


degac(Posted 2011) [#4]
Thanks Warpy! Another thing learned...

@therevills:
They are the equivalent of BlitzMax's LINKS: they are the 'link' (or the node) to an object in a list


Xaron(Posted 2011) [#5]
Shouldn't be Monkey aware of that? I mean Node is defined in both list and map BUT it has only one template parameter in list and two parameters in map so Monkey should be able to distinguish between them without the need to add the namespace?


marksibly(Posted 2011) [#6]
Hi,

> Shouldn't be Monkey aware of that?

No, symbols in imported modules are only 'auto imported' if there are NO duplicates.

You can use the new Alias to deal with this too:

Alias Node=list.Node

...or even...

Alias MapNode=map.Node
Alias ListNode=list.Node

...at the top of your code.


Xaron(Posted 2011) [#7]
Ah alright, thanks for that Mark.