On 01/04/2018 07:08 PM, Michael Davidsaver wrote:
> On 01/03/2018 09:34 PM, renato sanhueza wrote:
>> I am toying with pvAccess and I want to implement a RPC that
>> returns nothing (void). Reading the Java API I found that all RPC
>> should return a PVStructure. I tried to return an un-instantiated
>> PVStructure, but sending a Null causes an exception. What would be
>> the best way of implement a void method?
>
> A Structure need not have any members. An empty structure is as
> close to void as the PVData type system supports.
It depends on what you expect of the void data type.
An empty structure (as a type) has exactly one value: the empty
structure. This is not the same as void in C/C++, which has /no/ value
at all (you cannot assign the result of a function that returns void to
a variable). I may remember this wrongly, but I thought pvData also
supports (tagged) unions. I would say that an empty /union/, i.e. one
with no choices at all, more faithfully represents the C/C++ void.
I am pretty much aware that the distinction is mostly academic and not
of much practical relevance... ;-)
Cheers
Ben
--
"Make it so they have to reboot after every typo." ― Scott Adams
Attachment:
signature.asc
Description: OpenPGP digital signature
- References:
- void return value in RPC renato sanhueza
- Re: void return value in RPC Michael Davidsaver
- Navigate by Date:
- Prev:
Re: Build pvaPy for Python 3 Siniša Veseli
- Next:
Re: Build pvaPy for Python 3 renato sanhueza
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
<2018>
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: void return value in RPC Michael Davidsaver
- Next:
Build pvaPy for Python 3 renato sanhueza
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
<2018>
2019
2020
2021
2022
2023
2024
|