Is it possible to define global hash maps?

I define a hash map, using

new-hashtable => variableHashMap

but I want to put something to this hashmap from rule a, and get from this hashmap from rule b.

When I try to put to hash map, using

<hashtable-put(|"Key", "Value")> variableHashMap, 

I get the error “Variable variableHashMap is not defined”.

Can you help me about this thing?

Note: question asked by @hilal on the mailinglist.

Asked by Eelco Visser on 21 January 2013 at 11:20

The idiomatic way for doing this is to use dynamic rules:

rule-a =
  ?VarDef(x, t); rules( TypeOf : x -> t )

rule-b:
  Var(x) -> Var(x{t})
  where <TypeOf> x => t 

Update: this is a hypothetical example that assumes that constructors VarDef and Var are defined in the signature of your program.

Answered by Eelco Visser on 21 January 2013 at 11:21

Thanks for your answer.

When I try this, I get the error Constructor VarDef/2 not declared. Should I define VarDef or is it a built-in rule/strategy?

Answered by Hilal Cora on 21 January 2013 at 12:39

@hilal: see my update. (Note that using answers for commenting on answers is not appropriate, we need a separate commenting mechanism.)

Answered by Eelco Visser on 21 January 2013 at 12:56