Lightweight name spacing or shadowing - anything that can help me load conflicting code?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Lightweight name spacing or shadowing - anything that can help me load conflicting code?

Tim Mackinnon
Hi - as I work through the different strands fo exercism (which has been a great project to kick different corners of Pharo) - I’ve hit an area where I’m wondering if there might be some useful tricks/techniques/ideas to help …

Essentially - I want to make mentoring easier (so hopefully people on this list might consider being a Pharo Exercism mentor). While there are basic review tools on exercism.io - reading code in Tonel only gets you so far…

So there is an endpoint for mentors to load in code (much like we already read in the exercises for users, and then use the TonelReader to parse and compile the code so its ready to run - a nice property of recent Pharo changes is that its quite happy to compile missing classes/methods and let you later fill those in, inside the debugger - it makes TDD awesome).

However - it would be nice if mentors could have the current solutions loading in an image, and then could load in the users submission (via a tool hitting the endpoint - and doing the same TonelReader stuff).

The issue of course is that you have a name clash - their solution and the reference solution.

So I could possibly walk the ast of the parsed solution and adjust the names (putting a user prefix) - and possibly the refactoring tools will also let me detect references to those names and then let adjust those too (I also will have the thorny issue of extension methods - although its a rare edge case I could ignore).

But I’m wondering if there is something neater that might work? Can I load these as “shadow classes/methods” somehow (when you browse Monticello package versions I recall you could see code in a browser - and I guess iceberg does that too?). This might work - although it doesn’t let me run the code and see any errors - but it might be good enough.

Or is there some way of having a cheap alternate Smalltalk context where I can load that code so it doesn’t collide. I guess this is edging on full namespaces - but I think my problem might be more confined and possibly doable more easily (than a general namespace solution that has to work for everything).

Anyone have any thoughts - pointers? I know namespaces is very controversial, but maybe this might be simpler?

Tim