[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-dbus
Subject:    Re: Default value for `in` parameter
From:       Thiago Macieira <thiago () kde ! org>
Date:       2023-01-28 16:03:28
Message-ID: 20684129.0c2gjJ1VT2 () tjmaciei-mobl5
[Download RAW message or body]

On Saturday, 28 January 2023 04:01:14 PST Charles Wong wrote:
> Hi,
> 
> Is this the  right place to ask dbus questions?
> 
> For example, there is a dbus config (is from
> https://gjs.guide/guides/gio/dbus.html#high-level-proxies):
> ```xml
> <method name="ComplexMethod">
>     <arg type="b" direction="in" name="input"/>
>     <arg type="u" direction="out" name="length"/>
> </method>
> ```
> 
> Is it possible to set a default value to parameter `input` and mark it as
> unrequired?

No, it's not. Please understand the introspection is a completely optional 
step. What you're suggestion would require a client to parse the XML to 
discover the default value.

However, the client can just place the call with fewer arguments. If the 
destination service knows how to deal with that, then the problem is solved.

This would be like "overloading" in C++, where you can have multiple methods 
with the same names but different parameters. The wire protocol permits this 
and many C++-based applications have such methods. It's also permitted and 
permissible in the XML introspection by the schema, but it is discouraged for 
compatibility reasons. For your own service and clients, you can do it, but 
just remember this won't be accepted for use in widely-standardised services.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic