src/Pure/name.ML
author haftmann
Thu, 20 Nov 2008 14:51:40 +0100
changeset 28860 b1d46059d502
parent 28821 78a6ed46ad04
child 28863 32e83a854e5e
permissions -rw-r--r--
name spaces and name bindings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/name.ML
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
     3
    Author:     Makarius
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
     4
28075
a45ce1bae4e0 added type binding -- generic name bindings;
wenzelm
parents: 24849
diff changeset
     5
Names of basic logical entities (variables etc.).  Generic name bindings.
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
     6
*)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
     7
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
     8
signature NAME =
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
     9
sig
24849
193a10e6bf90 added uu, aT;
wenzelm
parents: 21565
diff changeset
    10
  val uu: string
193a10e6bf90 added uu, aT;
wenzelm
parents: 21565
diff changeset
    11
  val aT: string
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    12
  val bound: int -> string
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    13
  val is_bound: string -> bool
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    14
  val internal: string -> string
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    15
  val dest_internal: string -> string
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    16
  val skolem: string -> string
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    17
  val dest_skolem: string -> string
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    18
  val clean_index: string * int -> string * int
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    19
  val clean: string -> string
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    20
  type context
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    21
  val context: context
20158
b71f4f4c6b1e export make_context, is_declared;
wenzelm
parents: 20121
diff changeset
    22
  val make_context: string list -> context
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    23
  val declare: string -> context -> context
20158
b71f4f4c6b1e export make_context, is_declared;
wenzelm
parents: 20121
diff changeset
    24
  val is_declared: context -> string -> bool
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    25
  val invents: context -> string -> int -> string list
20192
956cd30ef3be renamed Name.give_names to Name.names and moved Name.alphanum to Symbol.alphanum
haftmann
parents: 20174
diff changeset
    26
  val names: context -> string -> 'a list -> (string * 'a) list
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    27
  val invent_list: string list -> string -> int -> string list
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    28
  val variants: string list -> context -> string list * context
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    29
  val variant_list: string list -> string list -> string list
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    30
  val variant: string list -> string -> string
28860
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
    31
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
    32
  include NAME_BINDING
28725
4a71cc58b203 explicit interpretation prefix in Name.binding
haftmann
parents: 28108
diff changeset
    33
  val add_prefix: bool -> string -> binding -> binding
28821
78a6ed46ad04 Name.name_with_prefix (temporarily)
haftmann
parents: 28792
diff changeset
    34
  val map_prefix: ((string * bool) list -> binding -> binding) -> binding -> binding
28860
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
    35
  val name_of: binding -> string (*FIMXE legacy*)
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
    36
  val map_name: (string -> string) -> binding -> binding (*FIMXE legacy*)
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
    37
  val qualified: string -> binding -> binding (*FIMXE legacy*)
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
    38
  val display: binding -> string
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
    39
  val namify: NameSpace.naming -> binding -> NameSpace.naming * string (*FIMXE legacy*)
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    40
end;
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    41
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    42
structure Name: NAME =
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    43
struct
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    44
28860
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
    45
open NameSpace;
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
    46
24849
193a10e6bf90 added uu, aT;
wenzelm
parents: 21565
diff changeset
    47
(** common defaults **)
193a10e6bf90 added uu, aT;
wenzelm
parents: 21565
diff changeset
    48
193a10e6bf90 added uu, aT;
wenzelm
parents: 21565
diff changeset
    49
val uu = "uu";
193a10e6bf90 added uu, aT;
wenzelm
parents: 21565
diff changeset
    50
val aT = "'a";
193a10e6bf90 added uu, aT;
wenzelm
parents: 21565
diff changeset
    51
193a10e6bf90 added uu, aT;
wenzelm
parents: 21565
diff changeset
    52
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    53
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    54
(** special variable names **)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    55
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    56
(* encoded bounds *)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    57
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    58
(*names for numbered variables --
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    59
  preserves order wrt. int_ord vs. string_ord, avoids allocating new strings*)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    60
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    61
val small_int = Vector.tabulate (1000, fn i =>
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    62
  let val leading = if i < 10 then "00" else if i < 100 then "0" else ""
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    63
  in ":" ^ leading ^ string_of_int i end);
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    64
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    65
fun bound n =
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    66
  if n < 1000 then Vector.sub (small_int, n)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    67
  else ":" ^ bound (n div 1000) ^ Vector.sub (small_int, n mod 1000);
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    68
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    69
val is_bound = String.isPrefix ":";
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    70
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    71
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    72
(* internal names *)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    73
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    74
val internal = suffix "_";
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    75
val dest_internal = unsuffix "_";
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    76
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    77
val skolem = suffix "__";
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    78
val dest_skolem = unsuffix "__";
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    79
20099
bc3f9cb33645 clean: no special treatment of empty name;
wenzelm
parents: 20089
diff changeset
    80
fun clean_index (x, i) =
bc3f9cb33645 clean: no special treatment of empty name;
wenzelm
parents: 20089
diff changeset
    81
  (case try dest_internal x of
bc3f9cb33645 clean: no special treatment of empty name;
wenzelm
parents: 20089
diff changeset
    82
    NONE => (x, i)
bc3f9cb33645 clean: no special treatment of empty name;
wenzelm
parents: 20089
diff changeset
    83
  | SOME x' => clean_index (x', i + 1));
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    84
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    85
fun clean x = #1 (clean_index (x, 0));
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    86
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    87
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    88
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    89
(** generating fresh names **)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    90
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    91
(* context *)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    92
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    93
datatype context =
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    94
  Context of string option Symtab.table;    (*declared names with latest renaming*)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
    95
20099
bc3f9cb33645 clean: no special treatment of empty name;
wenzelm
parents: 20089
diff changeset
    96
fun declare x (Context tab) =
bc3f9cb33645 clean: no special treatment of empty name;
wenzelm
parents: 20089
diff changeset
    97
  Context (Symtab.default (clean x, NONE) tab);
bc3f9cb33645 clean: no special treatment of empty name;
wenzelm
parents: 20089
diff changeset
    98
bc3f9cb33645 clean: no special treatment of empty name;
wenzelm
parents: 20089
diff changeset
    99
fun declare_renaming (x, x') (Context tab) =
bc3f9cb33645 clean: no special treatment of empty name;
wenzelm
parents: 20089
diff changeset
   100
  Context (Symtab.update (clean x, SOME (clean x')) tab);
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   101
20158
b71f4f4c6b1e export make_context, is_declared;
wenzelm
parents: 20121
diff changeset
   102
fun is_declared (Context tab) = Symtab.defined tab;
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   103
fun declared (Context tab) = Symtab.lookup tab;
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   104
20121
848fc1a1d355 do not export make_context;
wenzelm
parents: 20104
diff changeset
   105
val context = Context Symtab.empty |> fold declare ["", "'"];
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   106
fun make_context used = fold declare used context;
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   107
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   108
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   109
(* invents *)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   110
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   111
fun invents ctxt =
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   112
  let
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   113
    fun invs _ 0 = []
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   114
      | invs x n =
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   115
          let val x' = Symbol.bump_string x in
20158
b71f4f4c6b1e export make_context, is_declared;
wenzelm
parents: 20121
diff changeset
   116
            if is_declared ctxt x then invs x' n
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   117
            else x :: invs x' (n - 1)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   118
          end;
20099
bc3f9cb33645 clean: no special treatment of empty name;
wenzelm
parents: 20089
diff changeset
   119
  in invs o clean end;
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   120
20198
wenzelm
parents: 20192
diff changeset
   121
fun names ctxt x xs = invents ctxt x (length xs) ~~ xs;
wenzelm
parents: 20192
diff changeset
   122
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   123
val invent_list = invents o make_context;
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   124
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   125
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   126
(* variants *)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   127
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   128
(*makes a variant of a name distinct from already used names in a
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   129
  context; preserves a suffix of underscores "_"*)
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   130
val variants = fold_map (fn name => fn ctxt =>
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   131
  let
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   132
    fun vary x =
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   133
      (case declared ctxt x of
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   134
        NONE => x
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   135
      | SOME x' => vary (Symbol.bump_string (the_default x x')));
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   136
20121
848fc1a1d355 do not export make_context;
wenzelm
parents: 20104
diff changeset
   137
    val (x, n) = clean_index (name, 0);
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   138
    val (x', ctxt') =
20158
b71f4f4c6b1e export make_context, is_declared;
wenzelm
parents: 20121
diff changeset
   139
      if not (is_declared ctxt x) then (x, declare x ctxt)
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   140
      else
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   141
        let
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   142
          val x0 = Symbol.bump_init x;
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   143
          val x' = vary x0;
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   144
          val ctxt' = ctxt
21565
bd28361f4c5b simplified '?' operator;
wenzelm
parents: 20198
diff changeset
   145
            |> x0 <> x' ? declare_renaming (x0, x')
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   146
            |> declare x';
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   147
        in (x', ctxt') end;
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   148
  in (x' ^ replicate_string n "_", ctxt') end);
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   149
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   150
fun variant_list used names = #1 (make_context used |> variants names);
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   151
fun variant used = singleton (variant_list used);
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   152
28075
a45ce1bae4e0 added type binding -- generic name bindings;
wenzelm
parents: 24849
diff changeset
   153
a45ce1bae4e0 added type binding -- generic name bindings;
wenzelm
parents: 24849
diff changeset
   154
(** generic name bindings **)
a45ce1bae4e0 added type binding -- generic name bindings;
wenzelm
parents: 24849
diff changeset
   155
28860
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   156
fun add_prefix sticky prfx b = if prfx = "" then error "empty name prefix"
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   157
  else (map_binding o apfst) (cons (prfx, sticky)) b;
28075
a45ce1bae4e0 added type binding -- generic name bindings;
wenzelm
parents: 24849
diff changeset
   158
28860
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   159
val prefix_of = fst o dest_binding;
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   160
val name_of = snd o dest_binding;
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   161
val map_name = map_binding o apsnd;
28108
1b08ed83b79e added qualified: string -> binding -> binding;
wenzelm
parents: 28075
diff changeset
   162
val qualified = map_name o NameSpace.qualified;
28075
a45ce1bae4e0 added type binding -- generic name bindings;
wenzelm
parents: 24849
diff changeset
   163
28860
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   164
fun map_prefix f b =
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   165
  let
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   166
    val (prefix, name) = dest_binding b;
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   167
    val pos = pos_of b;
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   168
  in f prefix (binding_pos (name, pos)) end;
28792
1d80cee865de namify and name_decl combinators
haftmann
parents: 28737
diff changeset
   169
28860
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   170
fun namify naming b =
28792
1d80cee865de namify and name_decl combinators
haftmann
parents: 28737
diff changeset
   171
  let
28860
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   172
    val (prefix, name) = dest_binding b
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   173
    fun mk_prefix (prfx, true) = sticky_prefix prfx
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   174
      | mk_prefix (prfx, false) = add_path prfx;
28792
1d80cee865de namify and name_decl combinators
haftmann
parents: 28737
diff changeset
   175
    val naming' = fold mk_prefix prefix naming;
28860
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   176
  in (naming', full naming' name) end;
28792
1d80cee865de namify and name_decl combinators
haftmann
parents: 28737
diff changeset
   177
28860
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   178
fun display b =
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   179
  let
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   180
    val (prefix, name) = dest_binding b
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   181
    fun mk_prefix (prfx, true) = prfx
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   182
      | mk_prefix (prfx, false) = enclose "(" ")" prfx
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   183
  in if not (! NameSpace.long_names) orelse null prefix orelse name = "" then name
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   184
    else NameSpace.implode (map mk_prefix prefix) ^ ":" ^ name
b1d46059d502 name spaces and name bindings
haftmann
parents: 28821
diff changeset
   185
  end;
28737
8cbb7cfcfb5b diagnostic output for name bindings
haftmann
parents: 28725
diff changeset
   186
20089
d757ebadb0a2 Names of basic logical entities (variables etc.).
wenzelm
parents:
diff changeset
   187
end;