Fair enough - it's a functional workaround at least. I'm going to submit a
pull request to add a warning to the doxygen about this as it is currently
incorrect.

On Thu, Mar 10, 2016 at 8:14 PM, Martin Braun <martin.br...@ettus.com>
wrote:

> Yeah, we had some discussions about making the dicts more explicit, but
> eventually didn't. So this code is currently all you can do.
>
> Cheers,
> M
>
> On 03/10/2016 06:59 PM, Jacob Gilbert wrote:
> > Looks like this is known to at least some other folks. Here is a fix
> > borrowed from:
> >
> https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/lib/usrp_block_impl.cc#L459
> >
> > void block::msg_handler(pmt::pmt_t msg)
> > {
> >   try {
> >   pmt::pmt_t keys = pmt::dict_keys(msg);
> >   } catch (const pmt::wrong_type &e) {
> >   msg = pmt::dict_add(pmt::make_dict(), pmt::car(msg), pmt::cdr(msg));
> >   }
> >
> > <<< rest of message handler here... input msg will be a dictionary >>>
> > }
> >
> >
> > On Thu, Mar 10, 2016 at 9:26 AM, Jacob Gilbert
> > <mrjacobagilb...@gmail.com <mailto:mrjacobagilb...@gmail.com>> wrote:
> >
> >     It appears that PMT dictionaries and pairs are treated identically
> >     when it comes to using the pmt::is_<type>() checking functions.
> >
> >     Example:
> >
> >           pmt::pmt_t test_pair = pmt::cons(pmt::mp("pair"), pmt::mp(1));
> >           pmt::pmt_t test_dict = pmt::dict_add(pmt::make_dict(),
> >     pmt::mp("dict"), pmt::mp(1));
> >
> >           if (pmt::is_pair(test_pair)) std::cout << "Pair is a pair" <<
> >     std::endl;
> >           if (pmt::is_pair(test_dict)) std::cout << "Dict is a pair" <<
> >     std::endl;
> >           if (pmt::is_dict(test_pair)) std::cout << "Pair is a dict" <<
> >     std::endl;
> >           if (pmt::is_dict(test_dict)) std::cout << "Dict is a dict" <<
> >     std::endl;
> >
> >     output is:
> >
> >     Pair is a pair
> >     Dict is a pair
> >     Pair is a dict
> >     Dict is a dict
> >
> >     Naturally this causes issues if you attempt to use these PMTs (eg:
> >     get the keys from a pair). I'm not sure if this is an issue with GNU
> >     Radio or with some external PMT handling library, but at a minimum
> >     it seems like the doxygen
> >     (
> http://gnuradio.org/doc/doxygen/namespacepmt.html#a936ecb38da9a2a1bb107c090e194700f
> )
> >
> >     "PMT_API bool pmt::is_pair (const pmt_t &obj)   Return true if obj
> >     is a pair, else false."
> >
> >     should be updated to reflect this issue for both pmt::is_pair() and
> >     pmt::is_dict().
> >
> >     Jacob
> >
> >
> >
> >
> > _______________________________________________
> > Discuss-gnuradio mailing list
> > Discuss-gnuradio@gnu.org
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> >
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to