Skip to content

Commit cae79f0

Browse files
Benoit Tigeotbenoittgt
authored andcommitted
Add answer for what is allocated for Koichi
1 parent 4abeab2 commit cae79f0

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,78 @@ I will add more questions in the future using pull requests so feel free to watc
104104
* "hi".freeze.object_id == "hi".freeze.object_id # => true
105105
```
106106

107+
And from an email of Koichi Sasada.
108+
109+
> Ruby has internal types and all objects are belong to only one type.
110+
111+
> The followings are all types.
112+
*from include/ruby/ruby.h*
113+
```c
114+
#define T_NONE RUBY_T_NONE
115+
#define T_NIL RUBY_T_NIL
116+
#define T_OBJECT RUBY_T_OBJECT
117+
#define T_CLASS RUBY_T_CLASS
118+
#define T_ICLASS RUBY_T_ICLASS
119+
#define T_MODULE RUBY_T_MODULE
120+
#define T_FLOAT RUBY_T_FLOAT
121+
#define T_STRING RUBY_T_STRING
122+
#define T_REGEXP RUBY_T_REGEXP
123+
#define T_ARRAY RUBY_T_ARRAY
124+
#define T_HASH RUBY_T_HASH
125+
#define T_STRUCT RUBY_T_STRUCT
126+
#define T_BIGNUM RUBY_T_BIGNUM
127+
#define T_FILE RUBY_T_FILE
128+
#define T_FIXNUM RUBY_T_FIXNUM
129+
#define T_TRUE RUBY_T_TRUE
130+
#define T_FALSE RUBY_T_FALSE
131+
#define T_DATA RUBY_T_DATA
132+
#define T_MATCH RUBY_T_MATCH
133+
#define T_SYMBOL RUBY_T_SYMBOL
134+
#define T_RATIONAL RUBY_T_RATIONAL
135+
#define T_COMPLEX RUBY_T_COMPLEX
136+
#define T_IMEMO RUBY_T_IMEMO
137+
#define T_UNDEF RUBY_T_UNDEF
138+
#define T_NODE RUBY_T_NODE
139+
#define T_ZOMBIE RUBY_T_ZOMBIE
140+
```
141+
142+
> We call types as T_xxx.
143+
144+
```
145+
Internal:
146+
T_NONE (reserved, not used)
147+
T_DATA
148+
T_IMEMO
149+
T_NODE
150+
T_ZOMBIE
151+
152+
Not allocated:
153+
T_NIL (nil)
154+
T_FIXNUM (small integers)
155+
T_TRUE (true)
156+
T_FALSE (false)
157+
T_UNDEF (internal use)
158+
159+
Allocated (normal)
160+
T_OBJECT
161+
T_CLASS
162+
T_ICLASS (internal use, to implement Module#include)
163+
T_MODULE
164+
T_FLOAT (now Ruby has flonum tech so that most of Float values
165+
are not allocated on 64 bit CPU)
166+
T_STRING
167+
T_REGEXP
168+
T_ARRAY
169+
T_HASH
170+
T_STRUCT
171+
T_BIGNUM (Integer representation)
172+
T_FILE
173+
T_MATCH
174+
T_SYMBOL (there are two symbols: allocated or not allocated)
175+
T_RATIONAL
176+
T_COMPLEX
177+
```
178+
107179
#### What is garbage collected **[Not Answered]** ?
108180
109181
What is garbage collected or not ?
@@ -271,4 +343,4 @@ Youtube video playlist : https://www.youtube.com/playlist?list=PLXvaGTBVk36uIVBG
271343
* [GoRuCo 2010 - Aman Gupta - memprof: the ruby level memory profiler](https://vimeo.com/12748731)
272344

273345
## Tanks 💕
274-
And I would love to thanks especially Richard Schneems, Aaron Patterson, Sam Saffron...
346+
And I would love to thanks especially Richard Schneems, Aaron Patterson, Sam Saffron, Nate Berkopec, Koichi Sasada...

0 commit comments

Comments
 (0)