Method: Heist::Runtime::Macro::Expansion#rename

Defined in:
lib/runtime/callable/macro/expansion.rb

#rename(id) ⇒ Object

Returns a new Identifier that does clash with any of the names visible in the Expansion‘s calling scope.



171
172
173
174
175
176
# File 'lib/runtime/callable/macro/expansion.rb', line 171

def rename(id)
  return id unless @calling_scope.defined?(id)
  i = 1
  i += 1 while @calling_scope.defined?("#{id}#{i}")
  Identifier.new("#{id}#{i}", id)
end