clever-lang/clever — Issue #148: Reflection ideas
Author: rgsilva
Created: 2012-03-02 13:06:19+00:00
State: open

As I was talking to @felipensp and @pedrofaria today, I was wondering about this: imagine a main file (```main.clv```) which the user may edit as he/she needs. Eventually he/she will want to load some "plugins", which are basically some clever code that will be called using ```ReflectionFunction```.

Just to illustrate the idea, consider that ```p1.clv``` is this:

// p1.clv
Void xyz() { ... }

And ```p2.clv```:

// p2.clv
Void xyz() { ... }

And, finally, ```main.clv```:

import 'p1.clv' as foo;
import 'p2.clv' as bar;

Well, xyz() function won't be an issue since ```p1``` has a different alias from ```p2```, but what if ```p1``` needs to get the ReflectionFunction from it's own ```xyz``` function without the need of knowing it's own alias? Of course I could create some init function to define a internal variable with the alias specified by the user - something like this:

foo::init("foo");
bar::init("bar");

But that's kinda ugly. So, my idea is to find some way of getting the ```ReflectionFunction``` by it's identifier considering the current file. If we don't consider the current file only and the entire current code, on ```p2``` it might get confused on why ```xyz``` function we want: the ```p1```'s or ```p2```'s.

Anyway, I hope I explained the problem well enough! I was wondering about this when I was thinking about how to implement the plugin system on my IRC bot project.