Hi,

> This is my first time here so I hope this is the right place to ask
> questions.

It is. :)

> I want to be able to compile these methods programatically without
> interruptions (using method source strings only) and gather all compiler
> errors that occur. What would be the best way to go about this?

It is certainly a way.

Compilation errors will raise SyntaxErrorNotifications that you can capture, 
e.g.

sthClass := Object subclass: #Something.
[ sthClass compile: '^^' classified: 'protocol-name' ]
        on: SyntaxErrorNotification
        do: [ :err | err inspect ]

> Also: How do I control in which package a compiled method ends up if the
> target class is in a different package (Method extension)?

Methods are stored in protocols (accessing, initialization, as yet 
unclassified).
If you however start the name with an asterisk *, then the method will become 
an extension method and will be stored in the package name following the 
asterisk.


e.g.

sthClass := Object subclass: #Something.
sthClass compile: 'methodName self lives somewhere else' classified: 
'*SomewhereElse'.

> 
> Any help would be greatly appreciated!

I would (shameless self-promotion) also recommend looking at this 
https://github.com/peteruhnak/pharo-changes-builder , so you could review the 
changes before actually compiling them.

Peter

Reply via email to