Lucifers,

I recently discovered an old branch on my MacBook that I rebased and put on GitHub:

    https://github.com/nwellnhof/lucy-clownfish/tree/cfc_symbol

In this branch, I began to refactor or even eliminate the CFCSymbol class. The original motivation came from thinking about how to reimplement the Clownfish compiler as a Clownfish project itself.

The CFCSymbol struct in master looks like this:

    struct CFCSymbol {
        CFCBase base;
        struct CFCParcel *parcel;
        char *exposure;
        char *class_name;
        char *class_nickname;
        char *micro_sym;
        char *short_sym;
        char *full_sym;
    };

Some observations:

1. `micro_sym` is kind of a misnomer these days. It should simply be `name`.

2. `short_sym` and `full_sym` are cached values. They can be computed using `name` and the class the symbol lives in. If this class is always passed as an additional argument to the functions returning these values, `parcel` and `class_nickname` become unnecessary, too.

3. `class_name` is used by classes to store the class name. But if you think about it, classes should store the class name in the `name` (formerly `micro_sym`) slot. `class_name` is also used by methods to keep track of the class where they were defined first. But this is only needed for methods.

So a symbol is essentially just a name and an exposure specifier. This makes it questionable whether CFCSymbol is useful as a base class at all. I lean towards eliminating CFCSymbol completely.

Nick

Reply via email to