Re: [Vala] Generics and Contract Programming

2011-06-24 Thread Chris Molozian

Ah ok, it was the "of T" that I wasn't sure how to do.

Thank you,

Chris


On 06/24/11 13:48, Nicolas wrote:

Hi Chris,

1) For assertations, try this:

[indent=4]

def static foo (ref args : array of string, opts : T, ...) of T
requires (args.length > 1)
// do something

init
print "hello world"

2) For generics, try this:

[indent=4]

class Wrapper of G : GLib.Object

data : private G

def set_data(data : G)
this.data = data

def get_data() : G
return this.data

init
var wrapper = new Wrapper of string
wrapper.set_data("test")
var data = wrapper.get_data()

Regards,
Nicolas.

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Generics and Contract Programming

2011-06-24 Thread Nicolas

Hi Chris,

1) For assertations, try this:

[indent=4]

def static foo (ref args : array of string, opts : T, ...) of T
requires (args.length > 1)
// do something

init
print "hello world"

2) For generics, try this:

[indent=4]

class Wrapper of G : GLib.Object

data : private G

def set_data(data : G)
this.data = data

def get_data() : G
return this.data

init
var wrapper = new Wrapper of string
wrapper.set_data("test")
var data = wrapper.get_data()

Regards,
Nicolas.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Generics and Contract Programming

2011-06-24 Thread Chris Molozian

Hey,

I'm unable to figure out how to write comparable code to Vala in Genie. 
How do I write Generic  
and Contract code 
 in 
Genie? e.g.


static void foo(ref string[] args, T opts, ...)
requires (args.length > 1) {
// do something
}

Regards,

Chris

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list