0

In reference to chapter 6 of your book "Language Implementation Patterns"; what is the best practice/pattern for storing and retrieving values for each symbol.

Every symbol has a name, a type and a scope. However; where do you store the actual value?

I.e. symbol "n" of type "integer" has a value of 42.

user2310417
  • 311
  • 3
  • 3
  • A bit confusing, but maybe you are mixing the compile time symbol table with the actual runtime environment? – Mephy Nov 18 '14 at 23:04

1 Answers1

1

What the symbol contains and how it contains that information is entirely your choice. In an untyped language the symbol could be just an object with term name and value attributes. For typing, add type and kind attributes.

Or the symbol object could contain just name and reference attributes, where the ref points into a separate table that contains additional attributes, including a reference that might point into a heap, immutables pool, or stack that actually stores the literal value.

This answer provides an example of a scoped, name and value symbol table.

Community
  • 1
  • 1
GRosenberg
  • 5,843
  • 2
  • 19
  • 23