Re: [Vala] nullable generic types



On Mon, Apr 05, 2010 at 03:53:12PM -0700, Adam Dingle wrote:
Jan,

HashMap<int, int> m = ...;
int? i = m.get(5);
Now i receives the value 0 (not null) if the element is absent.

It returns T, which is int, NOT int?, so you don't expect it to
return null,
do you?

Actually in hashmap.vala in libgee the get() method is defined like this:

public class HashMap<K,V> : Gee.AbstractMap<K,V> {
   ...
   public override V? get (K key) {

So yes, I might expect the method to return null, given this
definition. But
when Vala generates the .vapi file for libgee it strips the nullable
qualifier,
so gee-1.0.vapi contains this:

       public override V @get (K key);

Your message seems to say that the behavior I've observed when
instantiating a
generic with 'int' is indeed by design, and that's fine.  But I'm
still not sure
why V? in the .vala file becomes V in the .vapi file - do you
believe this is a bug?

Jürg resolved it as NOTABUG:
        https://bugzilla.gnome.org/show_bug.cgi?id=605490

PS. Please folllow RFC 1855, especially the following excerpt:
     "Be brief without being overly terse.  When replying to a message,
      include enough original material to be understood but no more. It
      is extremely bad form to simply reply to a message by including
      all the previous message: edit out all the irrelevant material."
    and don't do any kind of top posting (or explain why you *must* do
    it). Thank you.

-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.

Attachment: pgpGUoPQOppBD.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]