zbraniecki/l20n — Issue #10: Finalize the scope chain within L20n entity resolving schema
Author: zbraniecki
Created: 2012-02-01 10:24:36+00:00
State: open

In L20n we have a number of scope frames:
- resource frame (entities coming from external resource files)
- context frame (entities provided by a programmer for the whole l20n context to use)
- entity frame (entities provided by a programmer for a given entity request to use)
- system frame (provides system variables/methods, currently things like getent, getattr, getattrs, getmacro)
- globals frame (global entities that are getters that provide some environment information to the localizer like operating system, time of the day, day of the week etc.)

The way l20n resolves the entities on the low level is that we use a local function (like getent) with a set of objects that contain entities.

This is a proposal for a list of separate objects and scope chain order that I'd like to use.

First, we will have three separate objects:
- system (system frame)
- globals (globals frame)
- environment (resources frame, context frame, entity frame)

For the environment object I suggest the following chain order:
1) resources frame
2) context frame
3) entity frame

It basically means that if the entity is defined in all frames, the one from entity frame will be resolved, then comes context frame and resources frame is the last one.

Globals have to be recognized by LOL compiler and redirected into "getglobal" function.

The alternative would be to put globals as a frame within environment object and place it on its scope chain, but since I'd like to ensure that there is no conflict between resource provided entities like "time", "hour" etc. and globals, I believe that we should mark globals in LOL and resolve them separately.

Another topic for discussion is if we agree on the chain order.