Handle validity test

29 views
Skip to first unread message

Nil Geisweiller

unread,
Jan 19, 2017, 3:20:14 AM1/19/17
to opencog
Hi,

we have multiple ways to test whether a Handle is valid. I've
encountered the followings

1. if (h) then ...

2. if (h != nullptr) then ...

3. if (h.is_defined()) then ...

4. if (h != Handle::UNDEFINED) then ...

there might be more but that's the ones I can recall.

First question: Are they all strictly equivalent?

Second question: can we agree on a canonical way to do that and stick
with it?

Since `if (h)` is the shortest I would suggest to go with that, but
there might be reasons to go with something else, like more long term
reasons, etc.

I'll update the wikipage with the conclusion of this thread. Thanks for
you help.

Nil

Linas Vepstas

unread,
Jan 19, 2017, 4:50:24 PM1/19/17
to opencog
I believe that they are now strictly equivalent, although that was not
the case half a year ago. Back when handles held UUID's, then a
handle could be a null pointer, but holding a valid UUID. and
vice-versa -- a pointer could be non-null, but the UUID invalid.
Resolving the one form into the other was complicated -- this
confusion was one of the strong motivators for removing UUID's from
the handle.

Getting rid of h.is_defined() and Handle::UNDEFINED seems reasonable.

There's some other obsolete code as well: stuff that is marked with
DEPRECATED_ATOMSPACE_CALLS also should be cleaned up. Currently I
think its only the pattern miner that still uses these. Its been 5+
years now that these have been deprecated...

-- Linas
> --
> You received this message because you are subscribed to the Google Groups
> "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to opencog+u...@googlegroups.com.
> To post to this group, send email to ope...@googlegroups.com.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/a171e4aa-c840-6ac5-94ac-64be9174d087%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Nil Geisweiller

unread,
Jan 20, 2017, 1:47:17 AM1/20/17
to ope...@googlegroups.com
Thanks, I have updated the wiki accordingly

http://wiki.opencog.org/w/Development_standards#Handle_validity_test

Nil
Reply all
Reply to author
Forward
0 new messages