Re: [Vala] automatic basic type conversions
- From: Hans Vercammen <hveso3 gmail com>
- To: pancake <pancake youterm com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] automatic basic type conversions
- Date: Fri, 30 Jan 2009 08:44:07 +0100
On Tue, 2009-01-27 at 12:12 +0100, pancake wrote:
Actually Vala forces you to pass the correct type for assignations ,
argument passing in functions, etc..
I think this should be a warning instead of an error. And Vala should
know about which basic
types can be automatically casted (and show a warning) or an error if
they cannot be converted.
For example.
If I have a string and i need a uint8* the cast is possible.
Other basic type conversions that are interesting are between types with
precission loss:
double -> float
int -> char
int -> uint32
...
In the api bindings i'm writing i use uint32 values for length arguments
and i have to cast them
all the time because vala is unable to convert from long to uint32.
I understand that vala should provide a minimal code for making this
conversion before calling the
function, because a negative value should be handled in a different way
(like only pass possitive
value, or so..)
What do you think we should do for this kind of conversions?
In my opinion, I think that any conversion that could be done implicitly
without warning should be allowed, otherwise it should be explicit (so
an error). As far as I know this should already be possible for implicit
conversions where there is no conflict.
However, I think it would be nice to have some kind of warning levels in
vala that could be turned on/off when requested. Something in the sense
of -Werror, -Wall, -Wshadow etc. Maybe it's possible to combine these
things for your case.
I have had some bad experiences in the past with ignoring these kind of
warnings, where I thought ok well; the situation would never occur.
Depending on your compiler optimization and platform, this could cause
nasty runtime errors :) Compilers are probably better these days,
however using -Werror can still save you a lot of trouble.
Regards,
Hans
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]