请问以上输出信息代表什么? 1.是进程吗? 2.是进程的地址吗? 3.该地址可以记录多个数据吗?
不是进程,应该是 32 位机器上的 lambda, 后面这个是 lambda 对象的地址,不能记录多个数据
这个数据和用 object_id 算的地址相同:
[1] pry(main)> l=->{}
=> #<Proc:0x007fe47494d008@(pry):1 (lambda)>
[2] pry(main)> (l.object_id<<1).to_s 16
=> "7fe47494d008"
附 object_id 的计算规则
/*
* 32-bit VALUE space
* MSB ------------------------ LSB
* false 00000000000000000000000000000000
* true 00000000000000000000000000000010
* nil 00000000000000000000000000000100
* undef 00000000000000000000000000000110
* symbol ssssssssssssssssssssssss00001110
* object oooooooooooooooooooooooooooooo00 = 0 (mod sizeof(RVALUE))
* fixnum fffffffffffffffffffffffffffffff1
*
* object_id space
* LSB
* false 00000000000000000000000000000000
* true 00000000000000000000000000000010
* nil 00000000000000000000000000000100
* undef 00000000000000000000000000000110
* symbol 000SSSSSSSSSSSSSSSSSSSSSSSSSSS0 S...S % A = 4 (S...S = s...
* object oooooooooooooooooooooooooooooo0 o...o % A = 0
* fixnum fffffffffffffffffffffffffffffff1 bignum if required
*
* where A = sizeof(RVALUE)/4
*
* sizeof(RVALUE) is
* 20 if 32-bit, double is 4-byte aligned
* 24 if 32-bit, double is 8-byte aligned
* 40 if 64-bit
*/
剛剛找到了這裡 http://ruby-doc.org/core-1.9.3/Object.html#method-i-object_id 可以點開看那段源碼,就是 @luikore 的那段
@ghosTM55 这位也是大神啊,好像记得上海 ruby 活动中有个人的笔记本上贴着 Shanghai Linux User Group LOGO。应该是你吧!