Ramana Kumar wrote:
The compiler does maintain the declaration location of identifiers and in
the experimental IDE it's possible to click on an identifier and go to the
source file where it was declared.
I'd love if the locations stored by the compiler were exposed by a
procedure too, since I'd rather avoid an IDE.
Actually I think the information can be got at but in a rather indirect
way by using the displayVal/displayStruct etc functions. They produce
information about how to pretty print values and also information in the
"context" about where the value was declared. This is intended for use
by the IDE when printing the information but it could be extracted
programmatically.
Poly/ML 5.3 Release
>
local
open PolyML
open NameSpace
in
fun getVal name = displayVal(valOf(#lookupVal globalNameSpace
name), 1000(*depth*), globalNameSpace)
end;
> # # # # # val getVal = fn : string -> PolyML.pretty
> PolyML.print_depth 100;
val it = () : unit
> getVal "rev";
val it =
PrettyBlock
(3, false, [],
[PrettyBlock
(0, false, [],
[PrettyString "val", PrettyBreak (1, 0),
PrettyBlock
(0, false,
[ContextLocation
{file = "./basis/List.sml", endLine = 188, startLine = 188,
endPosition = 0, startPosition = 0}], [PrettyString "rev"]),
PrettyBreak (1, 0), PrettyString "="]), PrettyBreak (1, 0),
PrettyString "fn", PrettyBreak (1, 0),
PrettyBlock
(3, false, [],
[PrettyString ":", PrettyBreak (1, 3),
PrettyBlock
(0, false, [],
[PrettyBlock
(0, false, [],
[PrettyString "'a", PrettyBreak (1, 0),
PrettyBlock
(0, false,
[ContextLocation
{file = "Standard Basis", endLine = 0, startLine = 0,
endPosition = 0, startPosition = 0}],
[PrettyString "list"])]), PrettyBreak (1, 0),
PrettyString "->", PrettyBreak (1, 0),
PrettyBlock
(0, false, [],
[PrettyString "'a", PrettyBreak (1, 0),
PrettyBlock
(0, false,
[ContextLocation
{file = "Standard Basis", endLine = 0, startLine = 0,
endPosition = 0, startPosition = 0}],
[PrettyString "list"])])])])]) : PolyML.pretty
>
The location information is in the first ContextLocation entry. The
others refer to the locations of the "list" type constructors.
Again, it's possible that there are hooks already to do this but they aren't
easily accessible. All this could be done with time but it really requires
someone to work on improving all this.
Are there many developers? Who can join them?
Well, I'm the only one doing very much developing and it depends on
fitting it around other work. Lucas Dixon has been working on the jEdit
plugin and various other people have made contributions. It would be
good to get more people involved. The best way to get started is to
find some feature that you yourself want and try and write it. I'll do
what I can to help.
Regards,
David
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml