pharo-users@lists.pharo.org

Any question about pharo is welcome

View all threads

Finding references to non existent classes in Pharo

TM
Tim Mackinnon
Sun, Mar 10, 2024 12:43 PM

Hi - I was convinced in earlier Pharo’s, if you had a code reference to a non existent class you could find it by searching for references to its symbol name eg #MyMissingClass allReferences (or find references in the UI). This doesn’t seem to work in Pharo 11?  I loaded a package with a missing class, and when running something it complained about the missing class (it was an announcement), but I couldn't find an easy way to find it in my code to correct it? I ended up creating the fake class to then find references to it (as I then had a class), which seems way over the top?

I haven't had a chance to try this in Pharo 12, but shouldn't what I have done work? Or is there some new way to do this? I asked on Discord users, but didn't get a reply other than it rang a bell.

I know there has been a lot of work in the area of how things are represented and I wonder if something has got broken by mistake?

Tim

Hi - I was convinced in earlier Pharo’s, if you had a code reference to a non existent class you could find it by searching for references to its symbol name eg #MyMissingClass allReferences (or find references in the UI). This doesn’t seem to work in Pharo 11? I loaded a package with a missing class, and when running something it complained about the missing class (it was an announcement), but I couldn't find an easy way to find it in my code to correct it? I ended up creating the fake class to then find references to it (as I then had a class), which seems way over the top? I haven't had a chance to try this in Pharo 12, but shouldn't what I have done work? Or is there some new way to do this? I asked on Discord users, but didn't get a reply other than it rang a bell. I know there has been a lot of work in the area of how things are represented and I wonder if something has got broken by mistake? Tim
RW
Russ Whaley
Sun, Mar 10, 2024 6:03 PM

Tim,
Another anomaly I found with the above, even with my code that does not
reference the missing classes - but is contained within the same package of
classes that do reference the missing classes (clear?)... my application
crashes with an error that the reference could not be found. This may be
something introduced after build #913 - where I wasn't getting these
errors... and by build #1258 they appeared (may have also appeared earlier,
but I don't recall).

I had hoped to use the allReferences you listed above, but I had to run
through all my classes and methods to find missing classes - the methods
are highlighted, but lots of methods are highlighted for various reasons.
When I found the offending methods - I had to "comment out" the references
to get the method to then save... most of these were maintenance methods
that are only still around for reference/documentation... I need to find
another way :)

It sure would be good to be able to see ANY missing references in one call
so I could run that periodically to keep things clean.

On Sun, Mar 10, 2024 at 8:43 AM Tim Mackinnon Tim@testit.works wrote:

Hi - I was convinced in earlier Pharo’s, if you had a code reference to a
non existent class you could find it by searching for references to its
symbol name eg #MyMissingClass allReferences (or find references in the
UI). This doesn’t seem to work in Pharo 11?  I loaded a package with a
missing class, and when running something it complained about the missing
class (it was an announcement), but I couldn't find an easy way to find it
in my code to correct it? I ended up creating the fake class to then find
references to it (as I then had a class), which seems way over the top?

I haven't had a chance to try this in Pharo 12, but shouldn't what I have
done work? Or is there some new way to do this? I asked on Discord users,
but didn't get a reply other than it rang a bell.

I know there has been a lot of work in the area of how things are
represented and I wonder if something has got broken by mistake?

Tim

--
Russ Whaley
whaley.russ@gmail.com

Tim, Another anomaly I found with the above, even with my code that does not reference the missing classes - but is contained within the same package of classes that do reference the missing classes (clear?)... my application crashes with an error that the reference could not be found. This may be something introduced after build #913 - where I wasn't getting these errors... and by build #1258 they appeared (may have also appeared earlier, but I don't recall). I had hoped to use the allReferences you listed above, but I had to run through all my classes and methods to find missing classes - the methods are highlighted, but lots of methods are highlighted for various reasons. When I found the offending methods - I had to "comment out" the references to get the method to then save... most of these were maintenance methods that are only still around for reference/documentation... I need to find another way :) It sure would be good to be able to see ANY missing references in one call so I could run that periodically to keep things clean. On Sun, Mar 10, 2024 at 8:43 AM Tim Mackinnon <Tim@testit.works> wrote: > Hi - I was convinced in earlier Pharo’s, if you had a code reference to a > non existent class you could find it by searching for references to its > symbol name eg #MyMissingClass allReferences (or find references in the > UI). This doesn’t seem to work in Pharo 11? I loaded a package with a > missing class, and when running something it complained about the missing > class (it was an announcement), but I couldn't find an easy way to find it > in my code to correct it? I ended up creating the fake class to then find > references to it (as I then had a class), which seems way over the top? > > I haven't had a chance to try this in Pharo 12, but shouldn't what I have > done work? Or is there some new way to do this? I asked on Discord users, > but didn't get a reply other than it rang a bell. > > I know there has been a lot of work in the area of how things are > represented and I wonder if something has got broken by mistake? > > Tim > -- Russ Whaley whaley.russ@gmail.com
RS
Richard Sargent
Sun, Mar 10, 2024 7:43 PM

If you can locate one example, you may be able to manually examine the
compiled method itself to see what distinguishes it in terms of the
reference to a missing object. e.g. what's in the literal pool for a method
which references a non-existent class? You could create one such example
explicitly and then use what you  learn from that to track down the real
ones.

VW has a MethodCollector class which allows a variety of selection options
for methods, including an arbitrary block of clode. I don't know if Pharo
has something comparable. Worst case scenario, you use a poor mon's
approach. It is easy enough to enumerate all classes and traverse their
class and instance methods. That would pretty much be what you would want
from a MethodCollector anyway when using an arbitrary block for selection.

VW also has an Undeclared namespace. I know Pharo doesn't have namespaces,
per se, but it may still track undeclared references in some manner.

On Sun, Mar 10, 2024 at 11:04 AM Russ Whaley whaley.russ@gmail.com wrote:

Tim,
Another anomaly I found with the above, even with my code that does not
reference the missing classes - but is contained within the same package of
classes that do reference the missing classes (clear?)... my application
crashes with an error that the reference could not be found. This may be
something introduced after build #913 - where I wasn't getting these
errors... and by build #1258 they appeared (may have also appeared earlier,
but I don't recall).

I had hoped to use the allReferences you listed above, but I had to run
through all my classes and methods to find missing classes - the methods
are highlighted, but lots of methods are highlighted for various reasons.
When I found the offending methods - I had to "comment out" the references
to get the method to then save... most of these were maintenance methods
that are only still around for reference/documentation... I need to find
another way :)

It sure would be good to be able to see ANY missing references in one call
so I could run that periodically to keep things clean.

On Sun, Mar 10, 2024 at 8:43 AM Tim Mackinnon Tim@testit.works wrote:

Hi - I was convinced in earlier Pharo’s, if you had a code reference to a
non existent class you could find it by searching for references to its
symbol name eg #MyMissingClass allReferences (or find references in the
UI). This doesn’t seem to work in Pharo 11?  I loaded a package with a
missing class, and when running something it complained about the missing
class (it was an announcement), but I couldn't find an easy way to find it
in my code to correct it? I ended up creating the fake class to then find
references to it (as I then had a class), which seems way over the top?

I haven't had a chance to try this in Pharo 12, but shouldn't what I have
done work? Or is there some new way to do this? I asked on Discord users,
but didn't get a reply other than it rang a bell.

I know there has been a lot of work in the area of how things are
represented and I wonder if something has got broken by mistake?

Tim

--
Russ Whaley
whaley.russ@gmail.com

*If* you can locate one example, you may be able to manually examine the compiled method itself to see what distinguishes it in terms of the reference to a missing object. e.g. what's in the literal pool for a method which references a non-existent class? You could create one such example explicitly and then use what you learn from that to track down the real ones. VW has a MethodCollector class which allows a variety of selection options for methods, including an arbitrary block of clode. I don't know if Pharo has something comparable. Worst case scenario, you use a poor mon's approach. It is easy enough to enumerate all classes and traverse their class and instance methods. That would pretty much be what you would want from a MethodCollector anyway when using an arbitrary block for selection. VW also has an Undeclared namespace. I know Pharo doesn't have namespaces, per se, but it may still track undeclared references in some manner. On Sun, Mar 10, 2024 at 11:04 AM Russ Whaley <whaley.russ@gmail.com> wrote: > Tim, > Another anomaly I found with the above, even with my code that does not > reference the missing classes - but is contained within the same package of > classes that do reference the missing classes (clear?)... my application > crashes with an error that the reference could not be found. This may be > something introduced after build #913 - where I wasn't getting these > errors... and by build #1258 they appeared (may have also appeared earlier, > but I don't recall). > > I had hoped to use the allReferences you listed above, but I had to run > through all my classes and methods to find missing classes - the methods > are highlighted, but lots of methods are highlighted for various reasons. > When I found the offending methods - I had to "comment out" the references > to get the method to then save... most of these were maintenance methods > that are only still around for reference/documentation... I need to find > another way :) > > It sure would be good to be able to see ANY missing references in one call > so I could run that periodically to keep things clean. > > On Sun, Mar 10, 2024 at 8:43 AM Tim Mackinnon <Tim@testit.works> wrote: > >> Hi - I was convinced in earlier Pharo’s, if you had a code reference to a >> non existent class you could find it by searching for references to its >> symbol name eg #MyMissingClass allReferences (or find references in the >> UI). This doesn’t seem to work in Pharo 11? I loaded a package with a >> missing class, and when running something it complained about the missing >> class (it was an announcement), but I couldn't find an easy way to find it >> in my code to correct it? I ended up creating the fake class to then find >> references to it (as I then had a class), which seems way over the top? >> >> I haven't had a chance to try this in Pharo 12, but shouldn't what I have >> done work? Or is there some new way to do this? I asked on Discord users, >> but didn't get a reply other than it rang a bell. >> >> I know there has been a lot of work in the area of how things are >> represented and I wonder if something has got broken by mistake? >> >> Tim >> > > > -- > Russ Whaley > whaley.russ@gmail.com >
RO
Richard O'Keefe
Sun, Mar 10, 2024 8:56 PM

I created a method referring to a non-existent "Snark" class.
To my astonishment, "Code Search|References to it" quietly failed to
do anything visible.
It didn't find it, and it didn't say that it couldn't find it.
However, "Code Search|Method source with it" DID find the reference.
Pharo 9 and Pharo 11 both do this, although the on-screen interface is
different.

In Squeak, "References to it" worked fine, BUT when I created the
method I wasn't
offered the option of leaving "Snark" undeclared; the closest was
"Declare global".

Smalltalk/X offered me the option of "Continue" with an undeclared variable,
and then "References to it" worked perfectly.

On Mon, 11 Mar 2024 at 01:43, Tim Mackinnon Tim@testit.works wrote:

Hi - I was convinced in earlier Pharo’s, if you had a code reference to a non existent class you could find it by searching for references to its symbol name eg #MyMissingClass allReferences (or find references in the UI). This doesn’t seem to work in Pharo 11?  I loaded a package with a missing class, and when running something it complained about the missing class (it was an announcement), but I couldn't find an easy way to find it in my code to correct it? I ended up creating the fake class to then find references to it (as I then had a class), which seems way over the top?

I haven't had a chance to try this in Pharo 12, but shouldn't what I have done work? Or is there some new way to do this? I asked on Discord users, but didn't get a reply other than it rang a bell.

I know there has been a lot of work in the area of how things are represented and I wonder if something has got broken by mistake?

Tim

I created a method referring to a non-existent "Snark" class. To my astonishment, "Code Search|References to it" quietly failed to do anything visible. It didn't find it, and it didn't say that it couldn't find it. However, "Code Search|Method source with it" DID find the reference. Pharo 9 and Pharo 11 both do this, although the on-screen interface is different. In Squeak, "References to it" worked fine, BUT when I created the method I wasn't offered the option of leaving "Snark" undeclared; the closest was "Declare global". Smalltalk/X offered me the option of "Continue" with an undeclared variable, and then "References to it" worked perfectly. On Mon, 11 Mar 2024 at 01:43, Tim Mackinnon <Tim@testit.works> wrote: > > Hi - I was convinced in earlier Pharo’s, if you had a code reference to a non existent class you could find it by searching for references to its symbol name eg #MyMissingClass allReferences (or find references in the UI). This doesn’t seem to work in Pharo 11? I loaded a package with a missing class, and when running something it complained about the missing class (it was an announcement), but I couldn't find an easy way to find it in my code to correct it? I ended up creating the fake class to then find references to it (as I then had a class), which seems way over the top? > > I haven't had a chance to try this in Pharo 12, but shouldn't what I have done work? Or is there some new way to do this? I asked on Discord users, but didn't get a reply other than it rang a bell. > > I know there has been a lot of work in the area of how things are represented and I wonder if something has got broken by mistake? > > Tim
TM
Tim Mackinnon
Mon, Mar 11, 2024 8:59 AM

So it seems my expectation wasn't unreasonable (I expected Pharo to do the same as Smalltalk/X - given you can leave an undeclared reference). Perhaps Marcus might be able to comment on this, and I'll go and see if its been written up as an existing bug and if its also present in Pharo 12 now that its in stabilisation mode.

Appreciate those that chipped in - these are features that we need to ensure aren't lost (of course I recall the days when you couldn't save anything broken - and that was a PITA).

Tim

On Sun, 10 Mar 2024, at 8:56 PM, Richard O'Keefe wrote:

I created a method referring to a non-existent "Snark" class.
To my astonishment, "Code Search|References to it" quietly failed to
do anything visible.
It didn't find it, and it didn't say that it couldn't find it.
However, "Code Search|Method source with it" DID find the reference.
Pharo 9 and Pharo 11 both do this, although the on-screen interface is
different.

In Squeak, "References to it" worked fine, BUT when I created the
method I wasn't
offered the option of leaving "Snark" undeclared; the closest was
"Declare global".

Smalltalk/X offered me the option of "Continue" with an undeclared variable,
and then "References to it" worked perfectly.

On Mon, 11 Mar 2024 at 01:43, Tim Mackinnon Tim@testit.works wrote:

Hi - I was convinced in earlier Pharo’s, if you had a code reference to a non existent class you could find it by searching for references to its symbol name eg #MyMissingClass allReferences (or find references in the UI). This doesn’t seem to work in Pharo 11?  I loaded a package with a missing class, and when running something it complained about the missing class (it was an announcement), but I couldn't find an easy way to find it in my code to correct it? I ended up creating the fake class to then find references to it (as I then had a class), which seems way over the top?

I haven't had a chance to try this in Pharo 12, but shouldn't what I have done work? Or is there some new way to do this? I asked on Discord users, but didn't get a reply other than it rang a bell.

I know there has been a lot of work in the area of how things are represented and I wonder if something has got broken by mistake?

Tim

So it seems my expectation wasn't unreasonable (I expected Pharo to do the same as Smalltalk/X - given you can leave an undeclared reference). Perhaps Marcus might be able to comment on this, and I'll go and see if its been written up as an existing bug and if its also present in Pharo 12 now that its in stabilisation mode. Appreciate those that chipped in - these are features that we need to ensure aren't lost (of course I recall the days when you couldn't save anything broken - and that was a PITA). Tim On Sun, 10 Mar 2024, at 8:56 PM, Richard O'Keefe wrote: > I created a method referring to a non-existent "Snark" class. > To my astonishment, "Code Search|References to it" quietly failed to > do anything visible. > It didn't find it, and it didn't say that it couldn't find it. > However, "Code Search|Method source with it" DID find the reference. > Pharo 9 and Pharo 11 both do this, although the on-screen interface is > different. > > In Squeak, "References to it" worked fine, BUT when I created the > method I wasn't > offered the option of leaving "Snark" undeclared; the closest was > "Declare global". > > Smalltalk/X offered me the option of "Continue" with an undeclared variable, > and then "References to it" worked perfectly. > > > > On Mon, 11 Mar 2024 at 01:43, Tim Mackinnon <Tim@testit.works> wrote: >> >> Hi - I was convinced in earlier Pharo’s, if you had a code reference to a non existent class you could find it by searching for references to its symbol name eg #MyMissingClass allReferences (or find references in the UI). This doesn’t seem to work in Pharo 11? I loaded a package with a missing class, and when running something it complained about the missing class (it was an announcement), but I couldn't find an easy way to find it in my code to correct it? I ended up creating the fake class to then find references to it (as I then had a class), which seems way over the top? >> >> I haven't had a chance to try this in Pharo 12, but shouldn't what I have done work? Or is there some new way to do this? I asked on Discord users, but didn't get a reply other than it rang a bell. >> >> I know there has been a lot of work in the area of how things are represented and I wonder if something has got broken by mistake? >> >> Tim