The difference is slightly subtle, and it doesn't make a difference in all situations.
The undefined value is a value, whereas the empty handle means that there was no value. For instance, if a property handler returns v8::Undefined() then that means that there was a property and the value of that property was v8::Undefined(). If it returns v8::Handle<v8::Value>() then there was no property and lookup continues further up the prototype chain. As a rule of thumb you should always use v8::Undefined unless you have good reason to return an empty handle since the vm may handle empty handles subtly differently, and if it really does just convert it to undefined then writing it explicitly is clearer. On Sun, Sep 7, 2008 at 11:32 PM, Bryan White <[EMAIL PROTECTED]> wrote: > > In poking around in process.cc I have noticed that two different > expressions are used to return nothing: > > return v8::Undefined(); > > return v8::Handle<v8::Value>(); > > The second form, while more verbose, looks more efficient because the > constructor is inlined and trivial. > > v8::Undefined() returns a Handle<Primitive> > Its implementation looks more complex. > > It there any reason to use v8::Undefined()? > > -- > Bryan White > > > > --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
