What are the serious problems caused by undefined object_id and __send__ objects on classes?

If I have not defined all the instance methods for the class, I get the following warnings:

warning: undefining `object_id' may cause serious problems warning: undefining `__send__' may cause serious problems 

What are some examples of โ€œserious problemsโ€ that may arise?

(In particular, I am also curious if this has any significance for garbage collection?)

+4
source share
1 answer

In short, these methods are used for meta-goals (for example, error reporting), as well as for ordinary purposes, so they are more important than other methods.

When something goes wrong, Ruby returns an error message and return paths. By default, an error message displays a scan of the intruder object. With the exception of a few special classes, such as String and Numeric , validation displays the identifier of the object. To correctly display error messages, it is important to have object_id . If it has not been defined, then the error display procedure itself will cause an error that must be displayed, which causes an infinite loop that cannot be reported. In such a situation, you cannot say what is going wrong. This is serious.

Perhaps the same can be said for __send__ . This is the underlying method of send for most classes, and is crucial when sending instructions to objects.

+4
source

Source: https://habr.com/ru/post/1492738/


All Articles