What is undefined?

S

Seebs

Poking around, I ran into an interesting thing; nil.object_id == 0x4, but
there's another magical object_id, 0x6, which shows up in the Ruby source
as "Qundef".

.... But what does it *do*? How have I managed to use Ruby for a few things
here and there and never once encounter this value? It it used purely
internally, and never exposed to Ruby code, or what?

(And if you could tell me where I should have gone to look this up, that'd
be cool too; I tried a couple of times to find stuff but eventually gave
up on finding anything other than code snippets and patches which were
focused on explaining some other aspect of the interpreter code.)

-s
 
R

Robert Klemme

Poking around, I ran into an interesting thing; nil.object_id == 0x4, but
there's another magical object_id, 0x6, which shows up in the Ruby source
as "Qundef".

... But what does it *do*? How have I managed to use Ruby for a few things
here and there and never once encounter this value? It it used purely
internally, and never exposed to Ruby code, or what?

You'll find this in error.c:

if (x == Qundef) {
rb_bug("undef leaked to the Ruby space");
}

http://www.google.com/codesearch#kO...kage:ruby lang:^c$ file:error.c&type=cs&l=284
(And if you could tell me where I should have gone to look this up, that'd
be cool too; I tried a couple of times to find stuff but eventually gave
up on finding anything other than code snippets and patches which were
focused on explaining some other aspect of the interpreter code.)

Try this:

http://www.google.com/codesearch#search/&q=Qundef package:ruby lang:^c$&type=cs

Or search through sources with something like

$ find . -type f -name '*.c' -print0 \
| xargs -r0 fgrep -n Qundef

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top