Comments (3)
Object#object_id
implementation: GH-9
from artichoke.
[2.6.3] > BasicObject.class
=> Class
[2.6.3] > Object.class
=> Class
[2.6.3] > Module.class
=> Class
[2.6.3] > Class.class
=> Class
[2.6.3] > Kernel.class
=> Module
[2.6.3] > Class.ancestors
=> [Class, Module, Object, Kernel, BasicObject]
There are some circular references here. To avoid them:
- Ancestors is used for vtable calculations. It should be a list of
ObjectId
s. - Classes should store an owned reference to their super-class except for
Class
. Use an enum to help here. - Instances should store an owned pointer to their
Class
. This ensures that they maintain their class if the constant naming the class is removed. This will allow the class to get collected only if all of its instances become unreachable. - Modules and classes should store a reference to their enclosing
Module
orClass
scope. - Modules and classes have an internal name property that is distinct from the constants they are assigned to.
[2.6.3] > module A; class B; end; end
=> nil
[2.6.3] > inst = A::B.new
=> #<A::B:0x00007fe939a08460>
[2.6.3] > inst.class
=> A::B
[2.6.3] > Object.send(:remove_const, :A)
=> A
[2.6.3] > inst.class
=> A::B
[2.6.3] > inst.class.name
=> "A::B"
from artichoke.
Hash
mutable iteration:
- Deletions while iterating are allowed.
- Insertions while iterating are not.
$ irb
[3.0.1] > h = { a: "a", b: "b", c: "c" }
=> {:a=>"a", :b=>"b", :c=>"c"}
[3.0.1] > del = true
=> true
[3.0.1] > h.each_value { |v| puts v ; h.delete(:a) if del ; ins = true if del ; del = false ; h[:a] = "aaa" if ins }
a
(irb):3:in `block in <main>': can't add a new key into hash during iteration (RuntimeError)
from (irb):3:in `each_value'
from (irb):3:in `<main>'
from /usr/local/var/rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in `<top (required)>'
from /usr/local/var/rbenv/versions/3.0.1/bin/irb:23:in `load'
from /usr/local/var/rbenv/versions/3.0.1/bin/irb:23:in `<main>'
[3.0.1] > h.each_key { |v| puts v ; h.delete(:a) if del ; ins = true if del ; del = false ; h[:a] = "aaa" if ins }
b
c
=> {:b=>"b", :c=>"c"}
[3.0.1] > h = { a: "a", b: "b", c: "c" }
=> {:a=>"a", :b=>"b", :c=>"c"}
[3.0.1] > del = true
=> true
[3.0.1] > h.each_key { |v| puts v ; h.delete(:a) if del ; ins = true if del ; del = false ; h[:a] = "aaa" if ins }
a
(irb):7:in `block in <main>': can't add a new key into hash during iteration (RuntimeError)
from (irb):7:in `each_key'
from (irb):7:in `<main>'
from /usr/local/var/rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in `<top (required)>'
from /usr/local/var/rbenv/versions/3.0.1/bin/irb:23:in `load'
from /usr/local/var/rbenv/versions/3.0.1/bin/irb:23:in `<main>'
[3.0.1] > h = { a: "a", b: "b", c: "c" }
=> {:a=>"a", :b=>"b", :c=>"c"}
[3.0.1] > del = true
=> true
[3.0.1] > h.each_key { |v| puts v ; h.delete(:b) if del ; ins = true if del ; del = false }
a
c
=> {:a=>"a", :c=>"c"}
from artichoke.
Related Issues (20)
- Tests in `spec-runner/vendor/ruby` are not for MRI 3.1.2 HOT 2
- Build Rust crate for truncating floats to ints aka `RB_FIXABLE`
- Add support for `Regexp` needles to `String#byteindex` HOT 4
- `String#index` and `String#rindex` should return character offsets instead of byte offsets
- Add `byteindex` and `byterindex` methods to `spinoso-string`
- Add support for `Regexp` needles to `String#index` and `String#rindex` HOT 7
- Creating Time with `Time.utc` or `Time.local` should wrap 60 seconds around if not a valid leap second HOT 8
- spinoso-time error enum contains private, unreported types
- Parse difference with MRI for un-parenthesized method calls with an un-bracketed hash argument HOT 1
- scolapasta-path incorrectly mutates verbatim paths on Windows
- MatchData#offset returns byte offset instead of utf8 char offset for utf8 strings
- Dependabot cannot parse `rust-toolchain` file HOT 2
- Evaluate Profile-Guided Optimization (PGO) HOT 3
- `spinoso_string::String::chars` does not yield encoded strings
- `String#chars` is slow
- Embed a Windows manifest file in Artichoke binaries
- `Kernel#p` when given no arguments triggers a Rust unsafe precondition violation HOT 1
- Naming of internal packages HOT 2
- Awareness opportunity: add to asdf/mise plugin HOT 1
- Private vulnerability reporting HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from artichoke.