Le jeudi 29 janvier 2015 à 17:46 +0100, yannick inizan a écrit :
> add an 'v != null' assertion to avoid GLib Critical error :)
> 
> 2015-01-29 17:42 GMT+01:00 Guillaume Poirier-Morency
> <[email protected]>:
>         Le jeudi 29 janvier 2015 à 16:58 +0100, yannick inizan a
>         écrit :
>         > the old safe method :
>         >
>         >
>         > public static void main (string[] args) {
>         > Value? v = "toto";
>         > Value val = {};
>         > val.init (v.type());
>         > v.copy (ref val);
>         > print ("%s\n", (string)val);
>         > }
>         >
>         >
>         > p.s. : sorry for last message (*$£% gmail)
>         >
>         > 2015-01-29 16:48 GMT+01:00 Guillaume Poirier-Morency
>         > <[email protected]>:
>         >         Le jeudi 29 janvier 2015 à 15:30 +0100, yannick
>         inizan a
>         >         écrit :
>         >         > Vala translate your cast to a get_<type> function
>         of your
>         >         value.
>         >         >
>         >         > ex:
>         >         > Value v = "toto";
>         >         > var val = (string)v; //equals to 'var val =
>         v.get_string();'
>         >         >
>         >         > so (Value)my_val is impossible because GLib.Value
>         doesn't
>         >         have a
>         >         > get_value function.
>         >         >
>         >         > 2015-01-29 15:16 GMT+01:00 Guillaume
>         Poirier-Morency
>         >         > <[email protected]>:
>         >         >         I am working on Valum, a web
>         micro-framework written
>         >         in Vala
>         >         >         https://github.com/antono/valum
>         >         >
>         >         >         valac is generating very strange code that
>         doesn't
>         >         compile.
>         >         >
>         >         >         Part of the framework is about offering
>         facilities
>         >         to push
>         >         >         arbitrary
>         >         >         values into CTPL template environment.
>         >         >
>         >         >         At some point, I try to case a Value? to a
>         non-null
>         >         Value (I
>         >         >         have of
>         >         >         course tested the null case, I just want
>         it to pass
>         >         under
>         >         >         --enable-experimental-non-null)
>         >         >
>         >         >                 vala --version
>         >         >
>         >         >                 Vala 0.26.1
>         >         >
>         >         >         Here's the use case:
>         >         >
>         >         >                 Value? v;
>         >         >                 var val = (Value) v;
>         >         >
>         >         >         The error:
>         >         >
>         >         >
>         >         >                 lvalue required as unary ‘&’
>         operand
>         >         >
>         >         >         I attached the full log and the bug is
>         easily
>         >         reproducible
>         >         >         (the sample
>         >         >         does it).
>         >         >
>         >         >         --
>         >         >         Guillaume Poirier-Morency
>         >         <[email protected]>
>         >         >
>         >         >
>          _______________________________________________
>         >         >         vala-list mailing list
>         >         >         [email protected]
>         >         >
>          https://mail.gnome.org/mailman/listinfo/vala-list
>         >         >
>         >         >
>         >         >
>         >
>         >
>         >         Thanks for the answer!
>         >
>         >         That kind of code should be detected by Vala
>         compiler as an
>         >         error.
>         >
>         >         What approach would you recommend to cast "Value?"
>         to
>         >         "Value" ?
>         >
>         >         It's not that bad if it is not yet possible, but I
>         would
>         >         really like to
>         >         build the whole projet with
>         --enable-experimental-non-null ;)
>         >
>         >
>         >         --
>         >         Guillaume Poirier-Morency
>         <[email protected]>
>         >
>         >
>         
>         
>         Great! That should do the trick for now :)
>         --
>         Guillaume Poirier-Morency <[email protected]>
> 
> 

Another of my concern on the matter..

        assert_null (null);
        
Doesn't work very nicely. Is it because Vala has a defined null? like
Python has for None? and that function checks for a NULL pointer?
-- 
Guillaume Poirier-Morency <[email protected]>

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to