Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Eliminating Intermediate Array Allocations (tenderlovemaking.com)
70 points by ksec on Oct 2, 2024 | hide | past | favorite | 3 comments


Does Ruby not have a way of monkey-patching builtins? Does the compiler check for this?


Almost everything in (MRI) Ruby can be modified on-the-fly (which is itself problematic), except compiled-in methods and classes have some (lots) limitations on runtime modification of built-in things.

For example, here's one way to instantly break most programs:

    String.class_eval { undef_method :initialize }
While it might be possible with some other hackery to restore this, it's not guaranteed. In general, if you're modifying core Ruby stuff on the fly, it should be done safer on a limited basis with refinements. https://docs.ruby-lang.org/en/2.5.0/syntax/refinements_rdoc....


this is a great look at how to poke around under ruby's blankets! i wish it were so ready-to-hand in every environment




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: