No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] Workaround for "value of parameter could be non-positional argument"
From: Gustaf Neumann <neumann_at_wu.ac.at>
Date: Thu, 21 Jun 2012 16:01:14 +0200
Some background: if one has a code like
set value -v
Test new -value $value
even the tcl extension developer has no means to distinguish between a
variable containing a value and constant like:
Test new -value -v
in practice, statements like the one above are c common source of
problem, so nsf spits out in the case of a fully unknown argument the
warning you mentioned. So, getting the warning is a feature, not a bug :)
The simplest way to get rid of the message is to turn of debug. by
default, the debug level of nsf is 1, setting it to 0 will remove these
messages
nsf::configure debug 0
Test new -value -v
This will of course get rid of all warnings (we had no warnings in XOTcl
1.*).
An alternative option is to provide a value type for the property, such
as e.g. integer, object, ... which are for your example most probable
not suitable types. However, nsf contains predefined support for all
value types definable by "string is ...", or one can use application
specific value checkers; so we can get rid of the message by saying that
the permissible values must be e.g. printable. Setting a different value
type helps because the default value-checker (for unspecified values)
spits out the warning.
# turn debug on again
nsf::configure debug 1
# define the property to accept printable values
nx::Class create Test {
:property value:required,print
}
Test new -value -v
Hope this helps and explains things...
-gustaf neumann
Am 21.06.12 10:22, schrieb Arthur Schreiber:
> Hello Gustaf,
>
> what is the recommended way to work around the warning that is put out by
> code like this:
>
> nx::Class create Test {
> :property value:required
> }
>
> set value "-h"
> Test new -value $value
> # => Warning: value '-h' of parameter '-expected' could be a non-positional
> argument during:
> # ::nsf::__#0l configure -expected -h
>
>
> Kind regards,
> Arthur
>
Date: Thu, 21 Jun 2012 16:01:14 +0200
Some background: if one has a code like
set value -v
Test new -value $value
even the tcl extension developer has no means to distinguish between a
variable containing a value and constant like:
Test new -value -v
in practice, statements like the one above are c common source of
problem, so nsf spits out in the case of a fully unknown argument the
warning you mentioned. So, getting the warning is a feature, not a bug :)
The simplest way to get rid of the message is to turn of debug. by
default, the debug level of nsf is 1, setting it to 0 will remove these
messages
nsf::configure debug 0
Test new -value -v
This will of course get rid of all warnings (we had no warnings in XOTcl
1.*).
An alternative option is to provide a value type for the property, such
as e.g. integer, object, ... which are for your example most probable
not suitable types. However, nsf contains predefined support for all
value types definable by "string is ...", or one can use application
specific value checkers; so we can get rid of the message by saying that
the permissible values must be e.g. printable. Setting a different value
type helps because the default value-checker (for unspecified values)
spits out the warning.
# turn debug on again
nsf::configure debug 1
# define the property to accept printable values
nx::Class create Test {
:property value:required,print
}
Test new -value -v
Hope this helps and explains things...
-gustaf neumann
Am 21.06.12 10:22, schrieb Arthur Schreiber:
> Hello Gustaf,
>
> what is the recommended way to work around the warning that is put out by
> code like this:
>
> nx::Class create Test {
> :property value:required
> }
>
> set value "-h"
> Test new -value $value
> # => Warning: value '-h' of parameter '-expected' could be a non-positional
> argument during:
> # ::nsf::__#0l configure -expected -h
>
>
> Kind regards,
> Arthur
>
-- Univ.Prof. Dr. Gustaf Neumann Institute of Information Systems and New Media WU Vienna Augasse 2-6, A-1090 Vienna, AUSTRIA