pharo-project / pharo

Pharo is a dynamic reflective pure object-oriented language supporting live programming inspired by Smalltalk.
http://pharo.org
Other
1.21k stars 356 forks source link

compile: .... methods should return CompiledMethod object #12880

Open demarey opened 1 year ago

demarey commented 1 year ago

Strangely, all compile: .... methods return a selector. They should return the CompiledMethod object.

privat commented 1 year ago

Do you have an example?

(Smalltalk compiler compile: 'foo ^1') class >>> CompiledMethod 
demarey commented 1 year ago
ClassDescription>>#compile:classified:notifying:
String compile: 'foo' classified: 'foo' notifying: nil >>> "#foo"
privat commented 1 year ago

My guess it's that a legacy thing and since that there are a lot of clients that expect that such methods return selectors there is no real gain to change that. Maybe @MarcusDenker knows the history better.

MarcusDenker commented 1 year ago

yes, this is legacy.. I wonder if it is not better to add new APIs and keep the old ones compatible

privat commented 1 year ago

I opened a meta-issue #12883 to rant about the compilation API for instance :)

privat commented 1 year ago

My position on this specific issue: compile:* is legacy, maybe we could deprecate it? The way forward is the compiler message. But the API is still under heavy changes. It could be a Pahro12 goal

String compile: 'foo' classified: 'foo' notifying: nil >>> "#foo"

should become something like

String compiler protocol: 'foo'; install: 'foo' >>> aCompiledMethod