Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /archive/mlprof.1/basics/symbol.sml
ViewVC logotype

View of /archive/mlprof.1/basics/symbol.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4054 - (download) (annotate)
Wed Feb 4 20:42:42 2015 UTC (4 years, 5 months ago) by dbm
File size: 603 byte(s)
Initial import of archive (of early versions of sml/nj)
(* symbol.sml *)

signature SYMBOL = sig
    type symbol
    val eq: symbol * symbol -> bool
    and new: string -> symbol
    and name: symbol -> string
    and number: symbol -> int
end;

structure Symbol : SYMBOL = 
struct
    datatype symbol = symbol of {name: string, number: int};
    val nextNumber = ref (~1);	(* symbol counter *)
    fun eq (symbol{number=n1,...}, symbol{number=n2,...}) = (n1 = n2)
    fun new (str: string) =
	(nextNumber := !nextNumber + 1;
	 symbol{name = str, number = !nextNumber})
    fun name (symbol{name,...}) = name
    fun number (symbol{number,...}) = number
end;

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0