What is undefined?

Discussion in 'Ruby' started by Seebs, Aug 14, 2011.

  1. Seebs

    Seebs Guest

    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
    --
    Copyright 2011, all wrongs reversed. Peter Seebach /
    http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
    http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
    I am not speaking for my employer, although they do rent some of my opinions.
    Seebs, Aug 14, 2011
    #1
    1. Advertising

  2. On 15.08.2011 00:37, Seebs wrote:
    > 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#kOEgDIzD-Ao/trunk/lib/ruby/error.c&q=Qundef%20package:ruby%20lang:^c$%20file: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%20package:ruby%20lang:^c$&type=cs

    Or search through sources with something like

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

    Kind regards

    robert

    --
    remember.guy do |as, often| as.you_can - without end
    http://blog.rubybestpractices.com/
    Robert Klemme, Aug 15, 2011
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas
    Replies:
    5
    Views:
    539
    Mike Treseler
    May 31, 2005
  2. Gene Mat

    NET::NNTP Undefined value error

    Gene Mat, Jul 8, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,693
    Gene Mat
    Jul 8, 2003
  3. Mantorok Redgormor
    Replies:
    70
    Views:
    1,734
    Dan Pop
    Feb 17, 2004
  4. VK
    Replies:
    45
    Views:
    579
    Dr John Stockton
    Sep 12, 2006
  5. -Lost
    Replies:
    13
    Views:
    359
    Richard Cornford
    Jan 31, 2007
Loading...

Share This Page