Gautham, I think you might be misunderstanding how the Maybe<> API is
supposed to be used. When used correctly, it is absolutely safe and will
never crash.

- Maybe::FromJust() / MaybeLocal::ToLocalChecked() are intended for when
you know for sure that the Maybe / MaybeLocal is not empty. Usually, the
only case when you would know that is when you've just checked.
- Maybe::IsNothing() / Maybe::IsJust() / MaybeLocal::IsEmpty() are intended
for doing precisely that check.

Typical usage looks like:

MaybeLocal<Value> result = ...;
if (result.IsEmpty()) {
  // Handle error case, e.g. print a warning.
  return false;
} else {
  // .ToLocalChecked is safe to use here :-)
  do_something_with(result.ToLocalChecked());
}

For convenience, there are also the Maybe::FromMaybe() /
MaybeLocal::ToLocal() helpers:

Maybe<int> maybe_x = ...;
int x = maybe_x.FromMaybe(-1);
// same as:
// int x = maybe_x.IsJust() ? maybe_x.FromJust() : -1;

Of course you can also use Private Symbols if you prefer; but there's
really no reason to avoid private fields for stability reasons.

Hope this helps,
Jakob

On Fri, Jul 14, 2017 at 12:00 AM, Ben Noordhuis <i...@bnoordhuis.nl> wrote:

> On Fri, Jul 14, 2017 at 5:52 AM, Gautham B A
> <gautham.bangal...@gmail.com> wrote:
> > No, .ToLocalChecked() is called by my code, not from V8.
> >
> > I would like to know if the APIs under v8::Private namespace has been
> battle
> > tested.
>
> Node.js uses them and I'm fairly sure Chromium does too, so yes, I
> think you can say it's battle tested.
>
> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to